public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/3] Do a refactoring in linemap (PR preprocessor/90382).
  2019-05-14  8:07 [PATCH 0/3] Fix linemap assertation connected to PR preprocessor/90382 marxin
@ 2019-05-14  8:07 ` marxin
  2019-05-14 11:30   ` Nathan Sidwell
  2019-05-14  8:07 ` [PATCH 2/3] Fix min_location usage in line-map.c " marxin
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: marxin @ 2019-05-14  8:07 UTC (permalink / raw)
  To: gcc-patches

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


libcpp/ChangeLog:

2019-05-13  Martin Liska  <mliska@suse.cz>

	PR preprocessor/90382
	* include/line-map.h (get_data_from_adhoc_loc): Add const to
	the first argument.
	(get_location_from_adhoc_loc): Likewise.
	* line-map.c(get_data_from_adhoc_loc):  Add const to
	the first argument.
	(get_location_from_adhoc_loc): Likewise.
	(get_combined_adhoc_loc): Use get_location_from_adhoc_loc
	(or get_data_from_adhoc_loc).
	(get_range_from_adhoc_loc): Likewise.
	(get_pure_location): Likewise.
	(linemap_position_for_loc_and_offset): Likewise.
	(linemap_lookup): Likewise.
	(linemap_ordinary_map_lookup): Likewise.
	(linemap_macro_map_lookup): Likewise.
	(linemap_get_expansion_line): Likewise.
	(linemap_get_expansion_filename): Likewise.
	(linemap_location_in_system_header_p): Likewise.
	(linemap_location_from_macro_expansion_p): Likewise.
	(linemap_macro_loc_to_exp_point): Likewise.
	(linemap_resolve_location): Likewise.
	(linemap_unwind_toward_expansion): Likewise.
	(linemap_unwind_to_first_non_reserved_loc): Likewise.
	(linemap_expand_location): Likewise.
	(linemap_dump_location): Likewise.
---
 libcpp/include/line-map.h |  4 ++--
 libcpp/line-map.c         | 48 ++++++++++++++++-----------------------
 2 files changed, 22 insertions(+), 30 deletions(-)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Do-a-refactoring-in-linemap-PR-preprocessor-90382.patch --]
[-- Type: text/x-patch; name="0001-Do-a-refactoring-in-linemap-PR-preprocessor-90382.patch", Size: 7856 bytes --]

diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index 6c77c288855..7649700e8a5 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
@@ -1054,8 +1054,8 @@ extern location_t get_combined_adhoc_loc (struct line_maps *,
 					       location_t,
 					       source_range,
 					       void *);
-extern void *get_data_from_adhoc_loc (struct line_maps *, location_t);
-extern location_t get_location_from_adhoc_loc (struct line_maps *,
+extern void *get_data_from_adhoc_loc (const struct line_maps *, location_t);
+extern location_t get_location_from_adhoc_loc (const struct line_maps *,
 						    location_t);
 
 extern source_range get_range_from_loc (line_maps *set, location_t loc);
diff --git a/libcpp/line-map.c b/libcpp/line-map.c
index b73f5067c24..e1fc0e9faf4 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -163,8 +163,7 @@ get_combined_adhoc_loc (struct line_maps *set,
   struct location_adhoc_data **slot;
 
   if (IS_ADHOC_LOC (locus))
-    locus
-      = set->location_adhoc_data_map.data[locus & MAX_LOCATION_T].locus;
+    locus = get_location_from_adhoc_loc (set, locus);
   if (locus == 0 && data == NULL)
     return 0;
 
@@ -243,7 +242,7 @@ get_combined_adhoc_loc (struct line_maps *set,
 /* Return the data for the adhoc loc.  */
 
 void *
-get_data_from_adhoc_loc (struct line_maps *set, location_t loc)
+get_data_from_adhoc_loc (const struct line_maps *set, location_t loc)
 {
   linemap_assert (IS_ADHOC_LOC (loc));
   return set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].data;
@@ -252,7 +251,7 @@ get_data_from_adhoc_loc (struct line_maps *set, location_t loc)
 /* Return the location for the adhoc loc.  */
 
 location_t
-get_location_from_adhoc_loc (struct line_maps *set, location_t loc)
+get_location_from_adhoc_loc (const struct line_maps *set, location_t loc)
 {
   linemap_assert (IS_ADHOC_LOC (loc));
   return set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus;
@@ -261,7 +260,7 @@ get_location_from_adhoc_loc (struct line_maps *set, location_t loc)
 /* Return the source_range for adhoc location LOC.  */
 
 static source_range
-get_range_from_adhoc_loc (struct line_maps *set, location_t loc)
+get_range_from_adhoc_loc (const struct line_maps *set, location_t loc)
 {
   linemap_assert (IS_ADHOC_LOC (loc));
   return set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].src_range;
@@ -321,8 +320,7 @@ location_t
 get_pure_location (line_maps *set, location_t loc)
 {
   if (IS_ADHOC_LOC (loc))
-    loc
-      = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus;
+    loc = get_location_from_adhoc_loc (set, loc);
 
   if (loc >= LINEMAPS_MACRO_LOWEST_LOCATION (set))
     return loc;
@@ -872,7 +870,7 @@ linemap_position_for_loc_and_offset (struct line_maps *set,
   const line_map_ordinary * map = NULL;
 
   if (IS_ADHOC_LOC (loc))
-    loc = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus;
+    loc = get_location_from_adhoc_loc (set, loc);
 
   /* This function does not support virtual locations yet.  */
   if (linemap_location_from_macro_expansion_p (set, loc))
@@ -934,7 +932,7 @@ const struct line_map*
 linemap_lookup (struct line_maps *set, location_t line)
 {
   if (IS_ADHOC_LOC (line))
-    line = set->location_adhoc_data_map.data[line & MAX_LOCATION_T].locus;
+    line = get_location_from_adhoc_loc (set, line);
   if (linemap_location_from_macro_expansion_p (set, line))
     return linemap_macro_map_lookup (set, line);
   return linemap_ordinary_map_lookup (set, line);
@@ -952,7 +950,7 @@ linemap_ordinary_map_lookup (struct line_maps *set, location_t line)
   const line_map_ordinary *cached, *result;
 
   if (IS_ADHOC_LOC (line))
-    line = set->location_adhoc_data_map.data[line & MAX_LOCATION_T].locus;
+    line = get_location_from_adhoc_loc (set, line);
 
   if (set ==  NULL || line < RESERVED_LOCATION_COUNT)
     return NULL;
@@ -1000,7 +998,7 @@ linemap_macro_map_lookup (struct line_maps *set, location_t line)
   const struct line_map_macro *cached, *result;
 
   if (IS_ADHOC_LOC (line))
-    line = set->location_adhoc_data_map.data[line & MAX_LOCATION_T].locus;
+    line = get_location_from_adhoc_loc (set, line);
 
   linemap_assert (line >= LINEMAPS_MACRO_LOWEST_LOCATION (set));
 
@@ -1130,8 +1128,7 @@ linemap_get_expansion_line (struct line_maps *set,
   const line_map_ordinary *map = NULL;
 
   if (IS_ADHOC_LOC (location))
-    location = set->location_adhoc_data_map.data[location
-						 & MAX_LOCATION_T].locus;
+    location = get_location_from_adhoc_loc (set, location);
 
   if (location < RESERVED_LOCATION_COUNT)
     return 0;
@@ -1158,8 +1155,7 @@ linemap_get_expansion_filename (struct line_maps *set,
   const struct line_map_ordinary *map = NULL;
 
   if (IS_ADHOC_LOC (location))
-    location = set->location_adhoc_data_map.data[location
-						 & MAX_LOCATION_T].locus;
+    location = get_location_from_adhoc_loc (set, location);
 
   if (location < RESERVED_LOCATION_COUNT)
     return NULL;
@@ -1196,8 +1192,7 @@ linemap_location_in_system_header_p (struct line_maps *set,
   const struct line_map *map = NULL;
 
   if (IS_ADHOC_LOC (location))
-    location = set->location_adhoc_data_map.data[location
-						 & MAX_LOCATION_T].locus;
+    location = get_location_from_adhoc_loc (set, location);
 
   if (location < RESERVED_LOCATION_COUNT)
     return false;
@@ -1240,8 +1235,7 @@ linemap_location_from_macro_expansion_p (const struct line_maps *set,
 					 location_t location)
 {
   if (IS_ADHOC_LOC (location))
-    location = set->location_adhoc_data_map.data[location
-						 & MAX_LOCATION_T].locus;
+    location = get_location_from_adhoc_loc (set, location);
 
   return IS_MACRO_LOC (location);
 }
@@ -1467,8 +1461,7 @@ linemap_macro_loc_to_exp_point (struct line_maps *set,
   struct line_map *map;
 
   if (IS_ADHOC_LOC (location))
-    location = set->location_adhoc_data_map.data[location
-						 & MAX_LOCATION_T].locus;
+    location = get_location_from_adhoc_loc (set, location);
 
   linemap_assert (set && location >= RESERVED_LOCATION_COUNT);
 
@@ -1542,7 +1535,7 @@ linemap_resolve_location (struct line_maps *set,
 {
   location_t locus = loc;
   if (IS_ADHOC_LOC (loc))
-    locus = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus;
+    locus = get_location_from_adhoc_loc (set, loc);
 
   if (locus < RESERVED_LOCATION_COUNT)
     {
@@ -1624,7 +1617,7 @@ linemap_unwind_toward_expansion (struct line_maps *set,
   const struct line_map *resolved_map;
 
   if (IS_ADHOC_LOC (loc))
-    loc = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus;
+    loc = get_location_from_adhoc_loc (set, loc);
 
   resolved_location =
     linemap_macro_map_loc_unwind_toward_spelling (set, macro_map, loc);
@@ -1664,7 +1657,7 @@ linemap_unwind_to_first_non_reserved_loc (struct line_maps *set,
   const line_map_ordinary *map1 = NULL;
 
   if (IS_ADHOC_LOC (loc))
-    loc = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus;
+    loc = get_location_from_adhoc_loc (set, loc);
 
   map0 = linemap_lookup (set, loc);
   if (!linemap_macro_expansion_map_p (map0))
@@ -1709,9 +1702,8 @@ linemap_expand_location (struct line_maps *set,
   memset (&xloc, 0, sizeof (xloc));
   if (IS_ADHOC_LOC (loc))
     {
-      xloc.data
-	= set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].data;
-      loc = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus;
+      xloc.data = get_data_from_adhoc_loc (set, loc);
+      loc = get_location_from_adhoc_loc (set, loc);
     }
 
   if (loc < RESERVED_LOCATION_COUNT)
@@ -1815,7 +1807,7 @@ linemap_dump_location (struct line_maps *set,
   int l = -1, c = -1, s = -1, e = -1;
 
   if (IS_ADHOC_LOC (loc))
-    loc = set->location_adhoc_data_map.data[loc & MAX_LOCATION_T].locus;
+    loc = get_location_from_adhoc_loc (set, loc);
 
   if (loc == 0)
     return;

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

* [PATCH 3/3] /cp 2018-05-14 Paolo Carlini <paolo.carlini@oracle.com>
  2019-05-14  8:07 [PATCH 0/3] Fix linemap assertation connected to PR preprocessor/90382 marxin
  2019-05-14  8:07 ` [PATCH 1/3] Do a refactoring in linemap (PR preprocessor/90382) marxin
  2019-05-14  8:07 ` [PATCH 2/3] Fix min_location usage in line-map.c " marxin
@ 2019-05-14  8:07 ` paolo
  2019-05-14 11:33 ` Martin Liška
  3 siblings, 0 replies; 7+ messages in thread
From: paolo @ 2019-05-14  8:07 UTC (permalink / raw)
  To: gcc-patches

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


	* 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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0003-cp-2018-05-14-Paolo-Carlini-paolo.carlini-oracle.com.patch --]
[-- Type: text/x-patch; name="0003-cp-2018-05-14-Paolo-Carlini-paolo.carlini-oracle.com.patch", Size: 1137 bytes --]

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

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

* [PATCH 0/3] Fix linemap assertation connected to PR preprocessor/90382.
@ 2019-05-14  8:07 marxin
  2019-05-14  8:07 ` [PATCH 1/3] Do a refactoring in linemap (PR preprocessor/90382) marxin
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: marxin @ 2019-05-14  8:07 UTC (permalink / raw)
  To: gcc-patches

Hi.

I'm sending series of 3 patches where first part is a refactoring in
order to use get_location_from_adhoc_loc and get_data_from_adhoc_loc.
Second part is dealing with the ICE and is about using
of get_location_from_adhoc_loc for IS_ADHOC_LOC.
Last one is reappliation of Paolo's patch.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready for trunk?
Thanks,
Martin

marxin (2):
  Do a refactoring in linemap (PR preprocessor/90382).
  Fix min_location usage in line-map.c (PR preprocessor/90382).

paolo (1):
  /cp 2018-05-14 Paolo Carlini <paolo.carlini@oracle.com>

 gcc/cp/decl.c                               |  4 +-
 gcc/testsuite/g++.dg/diagnostic/trailing1.C |  5 ++
 libcpp/include/line-map.h                   |  4 +-
 libcpp/line-map.c                           | 57 ++++++++++-----------
 4 files changed, 36 insertions(+), 34 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/diagnostic/trailing1.C

-- 
2.21.0

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

* [PATCH 2/3] Fix min_location usage in line-map.c (PR preprocessor/90382).
  2019-05-14  8:07 [PATCH 0/3] Fix linemap assertation connected to PR preprocessor/90382 marxin
  2019-05-14  8:07 ` [PATCH 1/3] Do a refactoring in linemap (PR preprocessor/90382) marxin
@ 2019-05-14  8:07 ` marxin
  2019-05-14 11:30   ` Nathan Sidwell
  2019-05-14  8:07 ` [PATCH 3/3] /cp 2018-05-14 Paolo Carlini <paolo.carlini@oracle.com> paolo
  2019-05-14 11:33 ` Martin Liška
  3 siblings, 1 reply; 7+ messages in thread
From: marxin @ 2019-05-14  8:07 UTC (permalink / raw)
  To: gcc-patches

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


libcpp/ChangeLog:

2019-05-13  Martin Liska  <mliska@suse.cz>

	PR preprocessor/90382
	* line-map.c (first_map_in_common_1): Handle ADHOC
	locations.
---
 libcpp/line-map.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-Fix-min_location-usage-in-line-map.c-PR-preprocessor.patch --]
[-- Type: text/x-patch; name="0002-Fix-min_location-usage-in-line-map.c-PR-preprocessor.patch", Size: 735 bytes --]

diff --git a/libcpp/line-map.c b/libcpp/line-map.c
index e1fc0e9faf4..31439f4aba3 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -1251,8 +1251,13 @@ first_map_in_common_1 (struct line_maps *set,
 		       location_t *loc1)
 {
   location_t l0 = *loc0, l1 = *loc1;
-  const struct line_map *map0 = linemap_lookup (set, l0),
-    *map1 = linemap_lookup (set, l1);
+  const struct line_map *map0 = linemap_lookup (set, l0);
+  if (IS_ADHOC_LOC (l0))
+    l0 = get_location_from_adhoc_loc (set, l0);
+
+  const struct line_map *map1 = linemap_lookup (set, l1);
+  if (IS_ADHOC_LOC (l1))
+    l1 = get_location_from_adhoc_loc (set, l1);
 
   while (linemap_macro_expansion_map_p (map0)
 	 && linemap_macro_expansion_map_p (map1)

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

* Re: [PATCH 2/3] Fix min_location usage in line-map.c (PR preprocessor/90382).
  2019-05-14  8:07 ` [PATCH 2/3] Fix min_location usage in line-map.c " marxin
@ 2019-05-14 11:30   ` Nathan Sidwell
  0 siblings, 0 replies; 7+ messages in thread
From: Nathan Sidwell @ 2019-05-14 11:30 UTC (permalink / raw)
  To: marxin, gcc-patches

On 5/13/19 7:10 AM, marxin wrote:
> 
> libcpp/ChangeLog:
> 
> 2019-05-13  Martin Liska  <mliska@suse.cz>
> 
> 	PR preprocessor/90382
> 	* line-map.c (first_map_in_common_1): Handle ADHOC
> 	locations.
> ---

ok


-- 
Nathan Sidwell

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

* Re: [PATCH 1/3] Do a refactoring in linemap (PR preprocessor/90382).
  2019-05-14  8:07 ` [PATCH 1/3] Do a refactoring in linemap (PR preprocessor/90382) marxin
@ 2019-05-14 11:30   ` Nathan Sidwell
  0 siblings, 0 replies; 7+ messages in thread
From: Nathan Sidwell @ 2019-05-14 11:30 UTC (permalink / raw)
  To: marxin, gcc-patches

On 5/13/19 7:07 AM, marxin wrote:
> 
> libcpp/ChangeLog:
> 
> 2019-05-13  Martin Liska  <mliska@suse.cz>
> 
> 	PR preprocessor/90382
> 	* include/line-map.h (get_data_from_adhoc_loc): Add const to
> 	the first argument.
> 	(get_location_from_adhoc_loc): Likewise.
> 	* line-map.c(get_data_from_adhoc_loc):  Add const to
> 	the first argument.
> 	(get_location_from_adhoc_loc): Likewise.
> 	(get_combined_adhoc_loc): Use get_location_from_adhoc_loc
> 	(or get_data_from_adhoc_loc).
> 	(get_range_from_adhoc_loc): Likewise.
> 	(get_pure_location): Likewise.
> 	(linemap_position_for_loc_and_offset): Likewise.
> 	(linemap_lookup): Likewise.
> 	(linemap_ordinary_map_lookup): Likewise.
> 	(linemap_macro_map_lookup): Likewise.
> 	(linemap_get_expansion_line): Likewise.
> 	(linemap_get_expansion_filename): Likewise.
> 	(linemap_location_in_system_header_p): Likewise.
> 	(linemap_location_from_macro_expansion_p): Likewise.
> 	(linemap_macro_loc_to_exp_point): Likewise.
> 	(linemap_resolve_location): Likewise.
> 	(linemap_unwind_toward_expansion): Likewise.
> 	(linemap_unwind_to_first_non_reserved_loc): Likewise.
> 	(linemap_expand_location): Likewise.
> 	(linemap_dump_location): Likewise.
> ---
>   libcpp/include/line-map.h |  4 ++--
>   libcpp/line-map.c         | 48 ++++++++++++++++-----------------------
>   2 files changed, 22 insertions(+), 30 deletions(-)

ok.  Thanks for cleaning this up.

nathan

-- 
Nathan Sidwell

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

* [PATCH 3/3] /cp 2018-05-14 Paolo Carlini <paolo.carlini@oracle.com>
  2019-05-14  8:07 [PATCH 0/3] Fix linemap assertation connected to PR preprocessor/90382 marxin
                   ` (2 preceding siblings ...)
  2019-05-14  8:07 ` [PATCH 3/3] /cp 2018-05-14 Paolo Carlini <paolo.carlini@oracle.com> paolo
@ 2019-05-14 11:33 ` Martin Liška
  3 siblings, 0 replies; 7+ messages in thread
From: Martin Liška @ 2019-05-14 11:33 UTC (permalink / raw)
  To: gcc-patches

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

Missing part 3/3.

Martin

[-- Attachment #2: 0003-cp-2018-05-14-Paolo-Carlini-paolo.carlini-oracle.com.patch --]
[-- Type: text/x-patch, Size: 1810 bytes --]

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


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

end of thread, other threads:[~2019-05-14 11:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-14  8:07 [PATCH 0/3] Fix linemap assertation connected to PR preprocessor/90382 marxin
2019-05-14  8:07 ` [PATCH 1/3] Do a refactoring in linemap (PR preprocessor/90382) marxin
2019-05-14 11:30   ` Nathan Sidwell
2019-05-14  8:07 ` [PATCH 2/3] Fix min_location usage in line-map.c " marxin
2019-05-14 11:30   ` Nathan Sidwell
2019-05-14  8:07 ` [PATCH 3/3] /cp 2018-05-14 Paolo Carlini <paolo.carlini@oracle.com> paolo
2019-05-14 11:33 ` Martin Liška

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