public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paolo Carlini <paolo.carlini@oracle.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Cc: Jason Merrill <jason@redhat.com>
Subject: [C++ Patch] Locations related grokdeclarator tweak
Date: Fri, 18 Jan 2019 11:13:00 -0000	[thread overview]
Message-ID: <f290cde0-5a44-5902-72bc-080595da2f78@oracle.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 274 bytes --]

Hi,

a tweak to typespec_loc, where the existing conditional turns out to be 
just a special case of the full min_location that we want in order to do 
the right thing for testcases like diagnostic/trailing1.C. Tested 
x86_64-linux.

Thanks, Paolo.

//////////////////////


[-- Attachment #2: CL_locs_28 --]
[-- Type: text/plain, Size: 248 bytes --]

/cp
2018-01-18  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl.c (grokdeclarator): Fix value assigned to typespec_loc, use
	min_location.

/testsuite
2018-01-18  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/diagnostic/trailing1.C: New.

[-- Attachment #3: patch_locs_28 --]
[-- Type: text/plain, Size: 1234 bytes --]

Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 268062)
+++ cp/decl.c	(working copy)
@@ -10341,9 +10341,9 @@ grokdeclarator (const cp_declarator *declarator,
 
   location_t typespec_loc = smallest_type_quals_location (type_quals,
 						      declspecs->locations);
+  typespec_loc = min_location (typespec_loc,
+			       declspecs->locations[ds_type_spec]);
   if (typespec_loc == UNKNOWN_LOCATION)
-    typespec_loc = declspecs->locations[ds_type_spec];
-  if (typespec_loc == UNKNOWN_LOCATION)
     typespec_loc = input_location;
 
   /* Look inside a declarator for the name being declared
Index: testsuite/g++.dg/diagnostic/trailing1.C
===================================================================
--- testsuite/g++.dg/diagnostic/trailing1.C	(nonexistent)
+++ testsuite/g++.dg/diagnostic/trailing1.C	(working copy)
@@ -0,0 +1,5 @@
+// { dg-do compile { target c++11 } }
+
+int const foo1() -> double;  // { dg-error "1:.foo1. function with trailing return type" }
+int volatile foo2() -> double;  // { dg-error "1:.foo2. function with trailing return type" }
+int const volatile foo3() -> double;  // { dg-error "1:.foo3. function with trailing return type" }

             reply	other threads:[~2019-01-18 11:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-18 11:13 Paolo Carlini [this message]
2019-01-21 17:22 ` Jason Merrill
2019-01-21 17:38   ` Paolo Carlini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f290cde0-5a44-5902-72bc-080595da2f78@oracle.com \
    --to=paolo.carlini@oracle.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).