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.
//////////////////////
/cp
2018-01-18 Paolo Carlini <paolo.carl...@oracle.com>
* decl.c (grokdeclarator): Fix value assigned to typespec_loc, use
min_location.
/testsuite
2018-01-18 Paolo Carlini <paolo.carl...@oracle.com>
* g++.dg/diagnostic/trailing1.C: New.
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" }