[3/3] /cp 2018-05-14 Paolo Carlini <paolo.carlini@oracle.com>

Message ID 4930dba7-f9f6-ac4f-cda4-0314b85c425a@suse.cz
State New
Headers show
Series
  • Fix linemap assertation connected to PR preprocessor/90382.
Related show

Commit Message

Martin Liška May 14, 2019, 11:33 a.m.
Missing part 3/3.

Martin

Patch

From c026b716c0ee0595f0577b32e511dbdf7cf960a3 Mon Sep 17 00:00:00 2001
From: paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 26 Apr 2019 11:46:15 +0000
Subject: [PATCH 3/3] /cp 2018-05-14 Paolo Carlini <paolo.carlini@oracle.com>

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

/testsuite
2018-05-14  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/diagnostic/trailing1.C: New.
---
 gcc/cp/decl.c                               | 4 ++--
 gcc/testsuite/g++.dg/diagnostic/trailing1.C | 5 +++++
 2 files changed, 7 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/diagnostic/trailing1.C

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index a776f8fcd98..ec81888c1f1 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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;
 
diff --git a/gcc/testsuite/g++.dg/diagnostic/trailing1.C b/gcc/testsuite/g++.dg/diagnostic/trailing1.C
new file mode 100644
index 00000000000..369781e56d5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/diagnostic/trailing1.C
@@ -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" }
-- 
2.21.0