This is the mail archive of the gcc@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]

Re: How do I run "make check" in gcc with libstdc++-v3?


On Tue, May 16, 2000 at 01:27:19AM -0500, Loren James Rittle wrote:
> In article <20000515222748.L6082@wolery.cumb.org>, 
> Zack Weinberg <zack@wolery.cumb.org> writes:
> 
> >> [...]  The only ways I see to get rid of those
> >> failures is (1) to find libstdc++-v3 headers with -isystem instead of
> >> -I while testing [good luck finding the right order for -isystem
> >> arguments given the current interactions with -B]
> 
> > I just had an idea.  System-header-ness can be forced on with #line,
> > sort of - you'd write
> 
> > #line 2 "header.h" 3
> 
> > at the very top of the file, and that *should* suppress -pedantic
> > warnings in the rest of the file.
> 
> Sorry, but unless I did something else dumb, when in ``-ansi
> -pedantic-errors'' mode, this error results:
> 
> .../libstdc++-v3/bits/std_exception.h:33:33: garbage at end of `#line' command
> 
> when this line is seen:
> 
> #line 37 "bits/std_typeinfo.h" 3
> 
> However, it does remove the ISO C violation errors later when
> #include_next is processed. ;-)

Yep.  The trailing 3 is itself an extension and must be diagnosed in
-pedantic mode.  Another reason why that trick won't work in general.
This won't be a problem with a #pragma.

...
> Although I think we are just kludging something to circumvent other
> issues, #pragma system_header would solve the final issue at hand in
> conjunction with HJ's patch to allow `make check-g++' against
> libstdc++-v3 in place before final installation or any
> pre-install-of-headers step.

I do kinda agree that this is a kludge around other issues.  It is,
however, much much simpler than attempting to fix the Makefiles :)

Here's a patch.  I've compiled this and verified that it does what we
want inside the preprocessor, using a simple test:

-- ex.h --
#pragma system_header
#warning blah
-- ex.c --
#include "ex.h"
#warning blah"
---
$ ./cpp -pedantic ex.c /dev/null
In file included from ex.c:1:
ex.h:2:13: warning: #warning blah
ex.c:3:1: warning: ISO C does not allow #warning
ex.c:3:13: warning: #warning blah

We get the 'ISO C does not allow' complaint for the #warning in the
.c file, but not the header.

The compiler proper may not notice the change; I'm not sure how this
interacts with the linemarker output yet.

zw

===================================================================
Index: cpplib.c
--- cpplib.c	2000/05/15 22:44:22	1.165
+++ cpplib.c	2000/05/16 19:10:11
@@ -811,6 +811,7 @@ do_ident (pfile)
 static int do_pragma_once		PARAMS ((cpp_reader *));
 static int do_pragma_implementation	PARAMS ((cpp_reader *));
 static int do_pragma_poison		PARAMS ((cpp_reader *));
+static int do_pragma_system_header	PARAMS ((cpp_reader *));
 static int do_pragma_default		PARAMS ((cpp_reader *));
 
 static int
@@ -846,6 +847,8 @@ do_pragma (pfile)
     pop = do_pragma_implementation (pfile);
   else if (tokis ("poison"))
     pop = do_pragma_poison (pfile);
+  else if (tokis ("system_header"))
+    pop = do_pragma_system_header (pfile);
   else
     pop = do_pragma_default (pfile);
 #undef tokis
@@ -978,6 +981,25 @@ do_pragma_poison (pfile)
 	CPP_PUTC (pfile, ' ');
     }
   return !writeit;
+}
+
+/* Mark the current header as a system header.  This will suppress
+   some categories of warnings (notably those from -pedantic).  It is
+   intended for use in system libraries that cannot be implemented in
+   conforming C, but cannot be certain that their headers appear in a
+   system include directory.  To prevent abuse, it is rejected in the
+   primary source file.  */
+static int
+do_pragma_system_header (pfile)
+     cpp_reader *pfile;
+{
+  cpp_buffer *ip = cpp_file_buffer (pfile);
+  if (CPP_PREV_BUFFER (ip) == NULL)
+    cpp_warning (pfile, "#pragma system_header outside include file");
+  else
+    ip->system_header_p = 1;
+
+  return 1;
 }
  
 /* Just ignore #sccs, on systems where we define it at all.  */

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