public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* PR24924 front end and preprocessor pedantic_errors settings should agree
@ 2007-01-27  9:12 Manuel López-Ibáñez
  2007-02-11 16:05 ` [PING^2] " Manuel López-Ibáñez
  0 siblings, 1 reply; 8+ messages in thread
From: Manuel López-Ibáñez @ 2007-01-27  9:12 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 629 bytes --]

:ADDPATCH c++:

This patch makes the preprocessor to give an error for pedwarns by
default unless fpermissive is given, when the language is a dialect of
C++.

Boostrapped and regression tested.

Does it look OK to you?


2007-01-27  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

  PR c++/24924
  * c-opts.c (c_common_post_options): Handle C++ post-processing here.
Set also -pedantic-errors by default for the  preprocessor unless
-fpermissive is given.

cp/
  * decl.c (cxx_init_decl_processing): Move command-line options
processing to c-opts.c.

testsuite/
  * g++.dg/cpp/pedantic-errors.C: New.
  * g++.dg/cpp/permissive.C: New.

[-- Attachment #2: pedantic-cpp-errors.diff --]
[-- Type: text/plain, Size: 2331 bytes --]

Index: gcc/testsuite/g++.dg/cpp/pedantic-errors.C
===================================================================
--- gcc/testsuite/g++.dg/cpp/pedantic-errors.C	(revision 0)
+++ gcc/testsuite/g++.dg/cpp/pedantic-errors.C	(revision 0)
@@ -0,0 +1,5 @@
+/* { dg-do preprocess } */
+/* { dg-options "-std=c++98" } */
+
+#if 1   
+#endif 1 /* { dg-error "error: extra tokens at end of #endif directive" } */
Index: gcc/testsuite/g++.dg/cpp/permissive.C
===================================================================
--- gcc/testsuite/g++.dg/cpp/permissive.C	(revision 0)
+++ gcc/testsuite/g++.dg/cpp/permissive.C	(revision 0)
@@ -0,0 +1,5 @@
+/* { dg-do preprocess } */
+/* { dg-options "-std=c++98 -fpermissive" } */
+
+#if 1   
+#endif 1 /* { dg-warning "warning: extra tokens at end of #endif directive" } */
Index: gcc/cp/decl.c
===================================================================
--- gcc/cp/decl.c	(revision 121039)
+++ gcc/cp/decl.c	(working copy)
@@ -3142,17 +3142,6 @@ cxx_init_decl_processing (void)
 
   current_lang_name = NULL_TREE;
 
-  /* Adjust various flags based on command-line settings.  */
-  if (!flag_permissive)
-    flag_pedantic_errors = 1;
-  if (!flag_no_inline)
-    {
-      flag_inline_trees = 1;
-      flag_no_inline = 1;
-    }
-  if (flag_inline_functions)
-    flag_inline_trees = 2;
-
   /* Force minimum function alignment if using the least significant
      bit of function pointers to store the virtual bit.  */
   if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn
Index: gcc/c-opts.c
===================================================================
--- gcc/c-opts.c	(revision 121039)
+++ gcc/c-opts.c	(working copy)
@@ -1060,6 +1060,23 @@ c_common_post_options (const char **pfil
   if (warn_overlength_strings == -1 || c_dialect_cxx ())
     warn_overlength_strings = 0;
 
+  /* Adjust various flags for C++ based on command-line settings.  */
+  if (c_dialect_cxx ())
+    {
+      if (!flag_permissive)
+	{
+	  flag_pedantic_errors = 1;
+	  cpp_opts->pedantic_errors = 1;
+	}
+      if (!flag_no_inline)
+	{
+	  flag_inline_trees = 1;
+	  flag_no_inline = 1;
+	}
+      if (flag_inline_functions)
+	flag_inline_trees = 2;
+    }
+
   /* Special format checking options don't work without -Wformat; warn if
      they are used.  */
   if (!warn_format)

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-03-15  5:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-27  9:12 PR24924 front end and preprocessor pedantic_errors settings should agree Manuel López-Ibáñez
2007-02-11 16:05 ` [PING^2] " Manuel López-Ibáñez
2007-02-19 23:36   ` [PING^3] " Manuel López-Ibáñez
2007-03-01 18:30     ` [PING^4] " Manuel López-Ibáñez
2007-03-14 22:58       ` [PING^5] " Manuel López-Ibáñez
2007-03-15  5:21         ` Ian Lance Taylor
2007-03-15  5:33           ` Mark Mitchell
2007-03-15  6:09         ` Mark Mitchell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).