public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ Patch] Locations related grokdeclarator tweak
@ 2019-01-18 11:13 Paolo Carlini
  2019-01-21 17:22 ` Jason Merrill
  0 siblings, 1 reply; 3+ messages in thread
From: Paolo Carlini @ 2019-01-18 11:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill

[-- 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" }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [C++ Patch] Locations related grokdeclarator tweak
  2019-01-18 11:13 [C++ Patch] Locations related grokdeclarator tweak Paolo Carlini
@ 2019-01-21 17:22 ` Jason Merrill
  2019-01-21 17:38   ` Paolo Carlini
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Merrill @ 2019-01-21 17:22 UTC (permalink / raw)
  To: Paolo Carlini, gcc-patches

On 1/18/19 6:13 AM, Paolo Carlini wrote:
> 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.

This is OK, but I don't think we want to keep messing with diagnostic 
locations now that we're in stage 4.  This isn't a regression fix, is it?

Jason

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [C++ Patch] Locations related grokdeclarator tweak
  2019-01-21 17:22 ` Jason Merrill
@ 2019-01-21 17:38   ` Paolo Carlini
  0 siblings, 0 replies; 3+ messages in thread
From: Paolo Carlini @ 2019-01-21 17:38 UTC (permalink / raw)
  To: Jason Merrill, gcc-patches

Hi,

On 21/01/19 18:22, Jason Merrill wrote:
> On 1/18/19 6:13 AM, Paolo Carlini wrote:
>> 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.
>
> This is OK, but I don't think we want to keep messing with diagnostic 
> locations now that we're in stage 4.  This isn't a regression fix, is it?

I agree, isn't a regression fix and probably we don't want to (further 
;) mess with locations in stage 4. In any case, I'm essentially done 
with most of the low hanging fruits, I continued for a while with what I 
had ready... Anyway, that said, what do you think, shall I schedule this 
one for next Stage 1?

Thanks! Paolo.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-21 17:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-18 11:13 [C++ Patch] Locations related grokdeclarator tweak Paolo Carlini
2019-01-21 17:22 ` Jason Merrill
2019-01-21 17:38   ` Paolo Carlini

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).