Reapply r270597.
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 14 May 2019 11:43:55 +0000 (11:43 +0000)
committerMartin Liska <marxin@gcc.gnu.org>
Tue, 14 May 2019 11:43:55 +0000 (11:43 +0000)
2019-05-14  Paolo Carlini  <paolo.carlini@oracle.com>

PR preprocessor/90382
* decl.c (grokdeclarator): Fix value assigned to typespec_loc, use
min_location.
2019-05-14  Paolo Carlini  <paolo.carlini@oracle.com>

PR preprocessor/90382
* g++.dg/diagnostic/trailing1.C: New test.

From-SVN: r271164

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/diagnostic/trailing1.C [new file with mode: 0644]

index 812f9f5a6be74c26cfab0ccac487101753063e5c..d896e5d572a6df859e1b8a312a5e121f6ffeb191 100644 (file)
@@ -1,3 +1,9 @@
+2019-05-14  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR preprocessor/90382
+       * decl.c (grokdeclarator): Fix value assigned to typespec_loc, use
+       min_location.
+
 2019-05-13  Jason Merrill  <jason@redhat.com>
 
        Use releasing_vec more broadly.
index 86cfcbe0db56638a24bf0e3a7d2055cb7a991eb8..66dc4c4a2ce358bb6c41ce006754076780aaa1a8 100644 (file)
@@ -10424,8 +10424,8 @@ grokdeclarator (const cp_declarator *declarator,
 
   location_t typespec_loc = smallest_type_quals_location (type_quals,
                                                      declspecs->locations);
-  if (typespec_loc == UNKNOWN_LOCATION)
-    typespec_loc = declspecs->locations[ds_type_spec];
+  typespec_loc = min_location (typespec_loc,
+                              declspecs->locations[ds_type_spec]);
   if (typespec_loc == UNKNOWN_LOCATION)
     typespec_loc = input_location;
 
index f5ce72bddbf2db89c8ca87e0caaf0ebf0ee00f51..bec2168b75b8565b092407682d2fcf902b26aeaa 100644 (file)
@@ -1,3 +1,8 @@
+2019-05-14  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR preprocessor/90382
+       * g++.dg/diagnostic/trailing1.C: New test.
+
 2019-05-14  marxin  <mliska@suse.cz>
 
        PR middle-end/90340
diff --git a/gcc/testsuite/g++.dg/diagnostic/trailing1.C b/gcc/testsuite/g++.dg/diagnostic/trailing1.C
new file mode 100644 (file)
index 0000000..369781e
--- /dev/null
@@ -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" }