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]

Patch not to pedwarn for _Complex in system headers


Using various system headers with -std=iso9899:1990 -pedantic-errors
yields errors because of _Complex use in those headers.  While the
question of whether pedwarns should all be disabled in system headers
(rather than just being disabled when they are warnings, but not with
-pedantic-errors) should perhaps be revisited, this patch fixes this
particular issue for now with another individual check of
in_system_header.

Bootstrapped with no regressions on i686-pc-linux-gnu.  Applied to
mainline.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    joseph@codesourcery.com (CodeSourcery mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)

2004-10-05  Joseph S. Myers  <jsm@polyomino.org.uk>

	* c-decl.c (declspecs_add_type): Don't pedwarn for _Complex in
	system headers.

testsuite:
2004-10-05  Joseph S. Myers  <jsm@polyomino.org.uk>

	* gcc.dg/complex-2.c, gcc.dg/complex-2.h: New test.

diff -rupN GCC.orig/gcc/c-decl.c GCC/gcc/c-decl.c
--- GCC.orig/gcc/c-decl.c	2004-10-04 07:45:35.000000000 +0000
+++ GCC/gcc/c-decl.c	2004-10-05 10:28:08.000000000 +0000
@@ -6815,7 +6815,7 @@ declspecs_add_type (struct c_declspecs *
 	      break;
 	    case RID_COMPLEX:
 	      dupe = specs->complex_p;
-	      if (pedantic && !flag_isoc99)
+	      if (pedantic && !flag_isoc99 && !in_system_header)
 		pedwarn ("ISO C90 does not support complex types");
 	      if (specs->typespec_word == cts_void)
 		error ("both %<complex%> and %<void%> in "
diff -rupN GCC.orig/gcc/testsuite/gcc.dg/complex-2.c GCC/gcc/testsuite/gcc.dg/complex-2.c
--- GCC.orig/gcc/testsuite/gcc.dg/complex-2.c	1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/complex-2.c	2004-10-05 10:29:59.000000000 +0000
@@ -0,0 +1,7 @@
+/* Allow complex types in system headers even with -std=iso9899:1990
+   -pedantic-errors.  */
+/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
+
+#include "complex-2.h"
diff -rupN GCC.orig/gcc/testsuite/gcc.dg/complex-2.h GCC/gcc/testsuite/gcc.dg/complex-2.h
--- GCC.orig/gcc/testsuite/gcc.dg/complex-2.h	1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/complex-2.h	2004-10-05 10:30:38.000000000 +0000
@@ -0,0 +1,6 @@
+/* Allow complex types in system headers even with -std=iso9899:1990
+   -pedantic-errors.  Header file.  */
+
+#pragma GCC system_header
+
+_Complex double x;


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