diff mbox

Fix linemap_location_before_p with adhoc locs (PR preprocessor/56824)

Message ID 20140206071643.GO12671@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Feb. 6, 2014, 7:16 a.m. UTC
Hi!

linemap_location_before_p (which is implemented as a call to
linemap_compare_locations) broke with the addition of IS_ADHOC_LOC,
because it doesn't look through those and thus can happily compare some
0x8....... number to normal locus and expect it to work.  Most of the other
line-map.c routines handle IS_ADHOC_LOC already, just not this function.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

The rest is just formatting cleanup, seeing opening [ at the end of
lines was just too much for me.

2014-02-06  Jakub Jelinek  <jakub@redhat.com>

	PR preprocessor/56824
	* line-map.c (get_combined_adhoc_loc, linemap_get_expansion_line,
	linemap_get_expansion_filename, linemap_location_in_system_header_p,
	linemap_location_from_macro_expansion_p,
	linemap_macro_loc_to_spelling_point, linemap_macro_loc_to_def_point,
	linemap_macro_loc_to_exp_point, linemap_expand_location): Fix
	formatting.
	(linemap_compare_locations): Look through adhoc locations for both
	l0 and l1.

	* gcc.dg/pr56824.c: New test.


	Jakub

Comments

Tom Tromey Feb. 7, 2014, 3:59 p.m. UTC | #1
>>>>> "Jakub" == Jakub Jelinek <jakub@redhat.com> writes:

Jakub> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.  Thanks.

Tom
diff mbox

Patch

--- libcpp/line-map.c.jj	2014-01-23 10:53:07.000000000 +0100
+++ libcpp/line-map.c	2014-02-05 15:07:41.558748559 +0100
@@ -106,8 +106,8 @@  get_combined_adhoc_loc (struct line_maps
   linemap_assert (data);
 
   if (IS_ADHOC_LOC (locus))
-    locus =
-	set->location_adhoc_data_map.data[locus & MAX_SOURCE_LOCATION].locus;
+    locus
+      = set->location_adhoc_data_map.data[locus & MAX_SOURCE_LOCATION].locus;
   if (locus == 0 && data == NULL)
     return 0;
   lb.locus = locus;
@@ -141,8 +141,8 @@  get_combined_adhoc_loc (struct line_maps
 	}
       *slot = set->location_adhoc_data_map.data
 	      + set->location_adhoc_data_map.curr_loc;
-      set->location_adhoc_data_map.data[
-	  set->location_adhoc_data_map.curr_loc++] = lb;
+      set->location_adhoc_data_map.data[set->location_adhoc_data_map.curr_loc++]
+	= lb;
     }
   return ((*slot) - set->location_adhoc_data_map.data) | 0x80000000;
 }
@@ -833,8 +833,8 @@  linemap_get_expansion_line (struct line_
   const struct line_map *map = NULL;
 
   if (IS_ADHOC_LOC (location))
-    location = set->location_adhoc_data_map.data[
-	location & MAX_SOURCE_LOCATION].locus;
+    location = set->location_adhoc_data_map.data[location
+						 & MAX_SOURCE_LOCATION].locus;
 
   if (location < RESERVED_LOCATION_COUNT)
     return 0;
@@ -861,8 +861,8 @@  linemap_get_expansion_filename (struct l
   const struct line_map *map = NULL;
 
   if (IS_ADHOC_LOC (location))
-    location = set->location_adhoc_data_map.data[
-	location & MAX_SOURCE_LOCATION].locus;
+    location = set->location_adhoc_data_map.data[location
+						 & MAX_SOURCE_LOCATION].locus;
 
   if (location < RESERVED_LOCATION_COUNT)
     return NULL;
@@ -899,8 +899,8 @@  linemap_location_in_system_header_p (str
   const struct line_map *map = NULL;
 
   if (IS_ADHOC_LOC (location))
-    location = set->location_adhoc_data_map.data[
-	location & MAX_SOURCE_LOCATION].locus;
+    location = set->location_adhoc_data_map.data[location
+						 & MAX_SOURCE_LOCATION].locus;
 
   if (location < RESERVED_LOCATION_COUNT)
     return false;
@@ -942,8 +942,8 @@  linemap_location_from_macro_expansion_p
 					 source_location location)
 {
   if (IS_ADHOC_LOC (location))
-    location = set->location_adhoc_data_map.data[
-	location & MAX_SOURCE_LOCATION].locus;
+    location = set->location_adhoc_data_map.data[location
+						 & MAX_SOURCE_LOCATION].locus;
 
   linemap_assert (location <= MAX_SOURCE_LOCATION
 		  && (set->highest_location
@@ -1024,6 +1024,11 @@  linemap_compare_locations (struct line_m
   bool pre_virtual_p, post_virtual_p;
   source_location l0 = pre, l1 = post;
 
+  if (IS_ADHOC_LOC (l0))
+    l0 = set->location_adhoc_data_map.data[l0 & MAX_SOURCE_LOCATION].locus;
+  if (IS_ADHOC_LOC (l1))
+    l1 = set->location_adhoc_data_map.data[l1 & MAX_SOURCE_LOCATION].locus;
+
   if (l0 == l1)
     return 0;
 
@@ -1086,8 +1091,8 @@  linemap_macro_loc_to_spelling_point (str
   struct line_map *map;
 
   if (IS_ADHOC_LOC (location))
-    location = set->location_adhoc_data_map.data[
-	location & MAX_SOURCE_LOCATION].locus;
+    location = set->location_adhoc_data_map.data[location
+						 & MAX_SOURCE_LOCATION].locus;
 
   linemap_assert (set && location >= RESERVED_LOCATION_COUNT);
 
@@ -1124,8 +1129,8 @@  linemap_macro_loc_to_def_point (struct l
   struct line_map *map;
 
   if (IS_ADHOC_LOC (location))
-    location = set->location_adhoc_data_map.data[
-	location & MAX_SOURCE_LOCATION].locus;
+    location = set->location_adhoc_data_map.data[location
+						 & MAX_SOURCE_LOCATION].locus;
 
   linemap_assert (set && location >= RESERVED_LOCATION_COUNT);
 
@@ -1166,8 +1171,8 @@  linemap_macro_loc_to_exp_point (struct l
   struct line_map *map;
 
   if (IS_ADHOC_LOC (location))
-    location = set->location_adhoc_data_map.data[
-	location & MAX_SOURCE_LOCATION].locus;
+    location = set->location_adhoc_data_map.data[location
+						 & MAX_SOURCE_LOCATION].locus;
 
   linemap_assert (set && location >= RESERVED_LOCATION_COUNT);
 
@@ -1374,8 +1379,8 @@  linemap_expand_location (struct line_map
   if (IS_ADHOC_LOC (loc))
     {
       loc = set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].locus;
-      xloc.data = set->location_adhoc_data_map.data[
-	  loc & MAX_SOURCE_LOCATION].data;
+      xloc.data
+	= set->location_adhoc_data_map.data[loc & MAX_SOURCE_LOCATION].data;
     }
 
   if (loc < RESERVED_LOCATION_COUNT)
--- gcc/testsuite/gcc.dg/pr56824.c.jj	2014-02-05 15:10:12.105998456 +0100
+++ gcc/testsuite/gcc.dg/pr56824.c	2014-02-05 15:09:07.000000000 +0100
@@ -0,0 +1,18 @@ 
+/* PR preprocessor/56824 */
+/* { dg-do compile } */
+/* { dg-options "-Waggregate-return" } */
+
+struct S { int i; };
+struct S foo (void);
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Waggregate-return"
+
+int
+main ()
+{
+  foo ();
+  return 0;
+}
+
+#pragma GCC diagnostic pop