gcc -traditional doesn't pass recognition of system headers to cc1

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Mon Nov 20 14:11:00 GMT 2000


 > From: "Kaveh R. Ghazi" <ghazi@caip.rutgers.edu>
 > 
 > I've been testing tradcpp0 by compiling stage1 with gcc -traditional.
 > I came across a general problem, when I compile the following code on
 > solaris2.7:
 > 
 >  > #include <stdio.h>
 >  > int main(){ return 0;}
 > 
 > I get:
 > 
 >  > /teal/caip5/ghazi/gcc-testing/build/gcc/include/stdio.h:43: warning:
 >  > 	ignoring #pragma ident
 >  > /usr/include/sys/feature_tests.h:43: warning: ignoring #pragma ident
 >  > /usr/include/sys/isa_defs.h:43: warning: ignoring #pragma ident
 >  > /usr/include/sys/va_list.h:43: warning: ignoring #pragma ident
 >  > /usr/include/stdio_tag.h:28: warning: ignoring #pragma ident
 >  > /usr/include/stdio_impl.h:21: warning: ignoring #pragma ident
 > 
 > This seems to be because tradcpp0 does not put the "system header"
 > identifiers on # line markers in the .i file and so cc1 doesn't know
 > it should silence these.  I looked and the function that emits these
 > markers is `output_line_command' but it doesn't seem to have access to
 > the system_header_p variable which is local to `do_include'.
 > 
 > I could either add a system_header_p parameter downline in each
 > function until I get to output_line_command, or perhaps add the
 > a system_header_p member to FILE_BUF, but that might get hairy
 > catching all the places it gets initialized.  Thoughts?

After some more poking around, I noticed that `system_include_depth'
acts as a stack depth counter whenever `system_header_p' is set.  So
checking "system_include_depth > 0" is the same as checking
"system_header_p".

The nice part is that system_include_depth is a global var. :-)

Minimal manual testing shows the following patch does what I want.
Assuming full bootstrap & testsuite goes well and it passes a sanity
check, okay to install?

		Thanks,
		--Kaveh


2000-11-20  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* tradcpp.c (output_line_command): Mark system headers as such in
	`line' commands.

diff -rup orig/egcs-CVS20001120/gcc/tradcpp.c egcs-CVS20001120/gcc/tradcpp.c
--- orig/egcs-CVS20001120/gcc/tradcpp.c	Sun Nov 19 08:12:41 2000
+++ egcs-CVS20001120/gcc/tradcpp.c	Mon Nov 20 16:44:45 2000
@@ -3535,6 +3535,8 @@ output_line_command (ip, op, conditional
   sprintf (line_cmd_buf, "# %d \"%s\"", ip->lineno, ip->fname);
   if (file_change != same_file)
     strcat (line_cmd_buf, file_change == enter_file ? " 1" : " 2");
+  if (system_include_depth > 0)
+    strcat (line_cmd_buf, " 3");
   len = strlen (line_cmd_buf);
   line_cmd_buf[len++] = '\n';
   check_expand (op, len + 1);


More information about the Gcc-patches mailing list