This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix #pragma implementation diagnostics (PR c++/69145, take 2)


On Thu, Jan 07, 2016 at 01:49:12PM +0100, Bernd Schmidt wrote:
> On 01/07/2016 10:05 AM, Jakub Jelinek wrote:
> >+  if (IS_ADHOC_LOC (location))
> >+    {
> >+      location &= MAX_SOURCE_LOCATION;
> >+      location
> >+	= pfile->line_table->location_adhoc_data_map.data[location].locus;
> >+    }
> 
> This looks like it is get_location_from_adhoc_loc.

I've also bootstrapped/regtested on x86_64-linux and i686-linux
following version:

2016-01-07  Jakub Jelinek  <jakub@redhat.com>

	PR c++/69145
	* files.c (cpp_included_before): If IS_ADHOC_LOC (location), lookup
	real location from the line_table.

	* g++.dg/ext/pr69145-1.C: New test.
	* g++.dg/ext/pr69145-2-very-long-filename.cc: New file.
	* g++.dg/ext/pr69145-2.h: New file.

--- libcpp/files.c.jj	2016-01-05 12:26:58.000000000 +0100
+++ libcpp/files.c	2016-01-07 19:41:11.841870958 +0100
@@ -1224,10 +1224,12 @@ bool
 cpp_included_before (cpp_reader *pfile, const char *fname,
 		     source_location location)
 {
-  struct cpp_file_hash_entry *entry;
+  struct cpp_file_hash_entry *entry
+    = (struct cpp_file_hash_entry *)
+      htab_find_with_hash (pfile->file_hash, fname, htab_hash_string (fname));
 
-  entry = (struct cpp_file_hash_entry *)
-     htab_find_with_hash (pfile->file_hash, fname, htab_hash_string (fname));
+  if (IS_ADHOC_LOC (location))
+    location = get_location_from_adhoc_loc (pfile->line_table, location);
 
   while (entry && (entry->start_dir == NULL || entry->u.file->err_no
 		   || entry->location > location))
--- gcc/testsuite/g++.dg/ext/pr69145-1.C.jj	2016-01-05 12:22:58.206729760 +0100
+++ gcc/testsuite/g++.dg/ext/pr69145-1.C	2016-01-05 12:22:52.017818392 +0100
@@ -0,0 +1,4 @@
+// PR c++/69145
+// { dg-do compile }
+#pragma implementation "pr69145-2-very-long-filename.cc" // { dg-bogus "appears after file is included" }
+#include "pr69145-2-very-long-filename.cc"
--- gcc/testsuite/g++.dg/ext/pr69145-2-very-long-filename.cc.jj	2016-01-05 12:23:47.151028824 +0100
+++ gcc/testsuite/g++.dg/ext/pr69145-2-very-long-filename.cc	2016-01-05 12:23:42.629093583 +0100
@@ -0,0 +1,3 @@
+// PR c++/69145
+// { dg-do compile } */
+#include "pr69145-2.h"
--- gcc/testsuite/g++.dg/ext/pr69145-2.h.jj	2016-01-05 12:23:49.963988539 +0100
+++ gcc/testsuite/g++.dg/ext/pr69145-2.h	2016-01-05 12:06:42.000000000 +0100
@@ -0,0 +1,3 @@
+#ifndef PR69145_2_H
+# define PR69145_2_H
+#endif


	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]