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]

cpplib: Sync branch and mainline.


Various fixes and things have been applied to the mainline but
not to the branch.  These have had between 4 days and 2 weeks
of mainline usage without problems, so I think moving it over
to the branch is OK, and worthwhile.  Below is the patch I'm
bootstrapping at present.  As a recap, it fixes:-

o The tedious Glibc warnings
o The -dM and -dD macro printout regression from 2.95.2
o The everything included by a system header is also a system
  header annoyance
o Multiple language specifications would cause spurious macro
  definitions.
o Proper diagnostics when redefining or undefining certain
  special macros such as __STDC_HOSTED__.

I anticipate starting to make changes to cpplib that will not
go into the branch, so cpplib on the branch should be pretty
much finalised with this patch.

Neil.

	* cppinit.c (builtin_array): Update.
	(init_builtins): Flag builtins to warn if redefined or
	undefined.  Define __GXX_WEAK as a normal macro.
	* cpplib.c (do_undef): Warn if flagged NODE_WARN.
	* cpplib.h (NODE_WARN): New flag.
	* cppmacro.c (builtin_macro): Remove handling of __GXX_WEAK__.
	Handle __STDC__ as a builtin only on Solaris.
	(warn_of_redefinition): Renamed from check_macro_definition.
	Reverse sense of test.  Always warn if NODE_WARN.
	(_cpp_create_definition): Use warn_of_redefinition.  Flag
	any macro beginning with "__STDC_" to require a mandatory
	warning if redefined or undefined.
	* cppinit.c (set_lang):  Move builtin handling to...
	(init_builtins): ...here.
	(_cpp_create_reader): Move call to set_lang.
	* cppfiles.c (stack_include_file): Generate dependencies
	here, and manage include_count here too.
	(PRINT_THIS_DEP): Delete.
	(_cpp_execute_include): Do not generate dependencies here,
	apart from the case of a missing header.  Do not manage
	include_count.
	(_cpp_read_file): Leave dependency generation to
	stack_include_file.
	* cppexp.c (parse_number): Similarly.
	* cpplib.h (NODE_SYSHDR, cpp_sys_objmacro_p): New.
	* cppmacro.c (struct cpp_macro): New member node.
	(parse_args): Only warn about missing rest args if not
	a system macro.
	(funlike_invocation_p): Similarly for uninvoked funlike macros.
	(cpp_sys_objmacro_p): New.
	(_cpp_create_definition): Store the node with the macro defn.
	Remember if the macro is defined in a system header.

Index: gcc/cppexp.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppexp.c,v
retrieving revision 1.87
diff -u -p -r1.87 cppexp.c
--- cppexp.c	2001/02/07 18:32:41	1.87
+++ cppexp.c	2001/02/28 19:19:32
@@ -203,7 +203,9 @@ parse_number (pfile, tok)
 	goto invalid_suffix;
       op.unsignedp = sufftab[i].u;
 
-      if (CPP_WTRADITIONAL (pfile) && sufftab[i].u)
+      if (CPP_WTRADITIONAL (pfile)
+	  && sufftab[i].u
+	  && ! cpp_sys_objmacro_p (pfile))
 	cpp_warning (pfile, "traditional C rejects the `U' suffix");
       if (sufftab[i].l == 2 && CPP_OPTION (pfile, pedantic)
 	  && ! CPP_OPTION (pfile, c99))
Index: gcc/cppfiles.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppfiles.c,v
retrieving revision 1.101.4.2
diff -u -p -r1.101.4.2 cppfiles.c
--- cppfiles.c	2001/02/21 19:16:29	1.101.4.2
+++ cppfiles.c	2001/02/28 19:19:34
@@ -269,7 +269,21 @@ stack_include_file (pfile, inc)
 {
   size_t len = 0;
   cpp_buffer *fp;
+  int sysp, deps_sysp;
 
+  /* We'll try removing deps_sysp after the release of 3.0.  */
+  deps_sysp = pfile->system_include_depth != 0;
+  sysp = ((pfile->buffer && pfile->buffer->sysp)
+	  || (inc->foundhere && inc->foundhere->sysp));
+
+  /* For -M, add the file to the dependencies on its first inclusion.  */
+  if (CPP_OPTION (pfile, print_deps) > deps_sysp && !inc->include_count)
+    deps_add_dep (pfile->deps, inc->name);
+
+  /* We don't want multiple include guard advice for the main file.  */
+  if (pfile->buffer)
+    inc->include_count++;
+
   /* Not in cache?  */
   if (! inc->buffer)
     read_include_file (pfile, inc);
@@ -281,8 +295,7 @@ stack_include_file (pfile, inc)
   fp = cpp_push_buffer (pfile, inc->buffer, len, BUF_FILE, inc->name);
   fp->inc = inc;
   fp->inc->refcnt++;
-  if (inc->foundhere)
-    fp->sysp = inc->foundhere->sysp;
+  fp->sysp = sysp;
 
   /* The ->actual_dir field is only used when ignore_srcdir is not in effect;
      see do_include */
@@ -567,7 +580,6 @@ report_missing_guard (n, b)
   return 0;
 }
 
-#define PRINT_THIS_DEP(p, b) (CPP_PRINT_DEPS(p) > (b||p->system_include_depth))
 void
 _cpp_execute_include (pfile, header, no_reinclude, include_next)
      cpp_reader *pfile;
@@ -580,6 +592,7 @@ _cpp_execute_include (pfile, header, no_
   unsigned int angle_brackets = header->type == CPP_HEADER_NAME;
   struct include_file *inc;
   char *fname;
+  int print_dep;
 
   /* Help protect #include or similar from recursion.  */
   if (pfile->buffer_stack_depth >= CPP_STACK_MAX)
@@ -637,20 +650,13 @@ _cpp_execute_include (pfile, header, no_
     }
 
   inc = find_include_file (pfile, fname, search_start);
-
   if (inc)
     {
-      /* For -M, add the file to the dependencies on its first inclusion. */
-      if (!inc->include_count && PRINT_THIS_DEP (pfile, angle_brackets))
-	deps_add_dep (pfile->deps, inc->name);
-      inc->include_count++;
-
-      /* Actually process the file.  */
-      stack_include_file (pfile, inc);
-
       if (angle_brackets)
 	pfile->system_include_depth++;
 
+      stack_include_file (pfile, inc);
+
       if (! DO_NOT_REREAD (inc))
 	{
 	  if (no_reinclude)
@@ -669,8 +675,10 @@ _cpp_execute_include (pfile, header, no_
       return;
     }
       
-  if (CPP_OPTION (pfile, print_deps_missing_files)
-      && PRINT_THIS_DEP (pfile, angle_brackets))
+  /* We will try making the RHS pfile->buffer->sysp after 3.0.  */
+  print_dep = CPP_PRINT_DEPS(pfile) > (angle_brackets
+				       || pfile->system_include_depth);
+  if (CPP_OPTION (pfile, print_deps_missing_files) && print_dep)
     {
       if (!angle_brackets || IS_ABSOLUTE_PATHNAME (fname))
 	deps_add_dep (pfile->deps, fname);
@@ -705,8 +713,7 @@ _cpp_execute_include (pfile, header, no_
      can't produce correct output, because there may be
      dependencies we need inside the missing file, and we don't
      know what directory this missing file exists in. */
-  else if (CPP_PRINT_DEPS (pfile)
-	   && ! PRINT_THIS_DEP (pfile, angle_brackets))
+  else if (CPP_PRINT_DEPS (pfile) && ! print_dep)
     cpp_warning (pfile, "No include path in which to find %s", fname);
   else
     cpp_error_from_errno (pfile, fname);
@@ -762,9 +769,6 @@ _cpp_read_file (pfile, fname)
       cpp_error_from_errno (pfile, fname);
       return 0;
     }
-
-  if (CPP_OPTION (pfile, print_deps))
-    deps_add_dep (pfile->deps, f->name);
 
   stack_include_file (pfile, f);
   return 1;
Index: gcc/cppinit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppinit.c,v
retrieving revision 1.147.2.1
diff -u -p -r1.147.2.1 cppinit.c
--- cppinit.c	2001/02/21 19:16:28	1.147.2.1
+++ cppinit.c	2001/02/28 19:19:44
@@ -371,8 +371,6 @@ set_lang (pfile, lang)
      cpp_reader *pfile;
      enum c_lang lang;
 {
-  struct cpp_pending *pend = CPP_OPTION (pfile, pending);
-
   /* Defaults.  */
   CPP_OPTION (pfile, lang) = lang;
   CPP_OPTION (pfile, objc) = 0;
@@ -388,7 +386,6 @@ set_lang (pfile, lang)
       CPP_OPTION (pfile, cplusplus_comments) = 1;
       CPP_OPTION (pfile, digraphs) = 1;
       CPP_OPTION (pfile, c99) = 1;
-      new_pending_directive (pend, "__STDC_VERSION__=199901L", cpp_define);
       break;
     case CLK_GNUC89:
       CPP_OPTION (pfile, trigraphs) = 0;
@@ -400,7 +397,6 @@ set_lang (pfile, lang)
 
       /* ISO C.  */
     case CLK_STDC94:
-      new_pending_directive (pend, "__STDC_VERSION__=199409L", cpp_define);
     case CLK_STDC89:
       CPP_OPTION (pfile, trigraphs) = 1;
       CPP_OPTION (pfile, dollars_in_ident) = 0;
@@ -408,7 +404,6 @@ set_lang (pfile, lang)
       CPP_OPTION (pfile, digraphs) = lang == CLK_STDC94;
       CPP_OPTION (pfile, c99) = 0;
       CPP_OPTION (pfile, extended_numbers) = 0;
-      new_pending_directive (pend, "__STRICT_ANSI__", cpp_define);
       break;
     case CLK_STDC99:
       CPP_OPTION (pfile, trigraphs) = 1;
@@ -416,13 +411,10 @@ set_lang (pfile, lang)
       CPP_OPTION (pfile, cplusplus_comments) = 1;
       CPP_OPTION (pfile, digraphs) = 1;
       CPP_OPTION (pfile, c99) = 1;
-      new_pending_directive (pend, "__STRICT_ANSI__", cpp_define);
-      new_pending_directive (pend, "__STDC_VERSION__=199901L", cpp_define);
       break;
 
       /* Objective C.  */
     case CLK_OBJCXX:
-      new_pending_directive (pend, "__cplusplus", cpp_define);
       CPP_OPTION (pfile, cplusplus) = 1;
     case CLK_OBJC:
       CPP_OPTION (pfile, trigraphs) = 0;
@@ -431,7 +423,6 @@ set_lang (pfile, lang)
       CPP_OPTION (pfile, digraphs) = 1;
       CPP_OPTION (pfile, c99) = 0;
       CPP_OPTION (pfile, objc) = 1;
-      new_pending_directive (pend, "__OBJC__", cpp_define);
       break;
 
       /* C++.  */
@@ -443,7 +434,6 @@ set_lang (pfile, lang)
       CPP_OPTION (pfile, cplusplus_comments) = 1;
       CPP_OPTION (pfile, digraphs) = 1;
       CPP_OPTION (pfile, c99) = 0;
-      new_pending_directive (pend, "__cplusplus", cpp_define);
       break;
 
       /* Assembler.  */
@@ -453,7 +443,6 @@ set_lang (pfile, lang)
       CPP_OPTION (pfile, cplusplus_comments) = 1;
       CPP_OPTION (pfile, digraphs) = 0; 
       CPP_OPTION (pfile, c99) = 0;
-      new_pending_directive (pend, "__ASSEMBLER__", cpp_define);
       break;
     }
 }
@@ -509,6 +498,7 @@ cpp_create_reader (lang)
 
   pfile = (cpp_reader *) xcalloc (1, sizeof (cpp_reader));
 
+  set_lang (pfile, lang);
   CPP_OPTION (pfile, warn_import) = 1;
   CPP_OPTION (pfile, discard_comments) = 1;
   CPP_OPTION (pfile, show_column) = 1;
@@ -518,9 +508,6 @@ cpp_create_reader (lang)
   CPP_OPTION (pfile, pending) =
     (struct cpp_pending *) xcalloc (1, sizeof (struct cpp_pending));
 
-  /* After creating pfile->pending.  */
-  set_lang (pfile, lang);
-
   /* It's simplest to just create this struct whether or not it will
      be needed.  */
   pfile->deps = deps_init ();
@@ -620,7 +607,9 @@ cpp_destroy (pfile)
 /* This structure defines one built-in identifier.  A node will be
    entered in the hash table under the name NAME, with value VALUE (if
    any).  If flags has OPERATOR, the node's operator field is used; if
-   flags has BUILTIN the node's builtin field is used.
+   flags has BUILTIN the node's builtin field is used.  Macros that are
+   known at build time should not be flagged BUILTIN, as then they do
+   not appear in macro dumps with e.g. -dM or -dD.
 
    Two values are not compile time constants, so we tag
    them in the FLAGS field instead:
@@ -645,7 +634,6 @@ struct builtin
 #define OPERATOR  	0x10
 
 #define B(n, t)       { U n, 0, t, 0, BUILTIN, sizeof n - 1 }
-#define BC(n, t)      { U n, 0, t, 0, BUILTIN | CPLUS, sizeof n - 1 }
 #define C(n, v)       { U n, v, 0, 0, 0, sizeof n - 1 }
 #define X(n, f)       { U n, 0, 0, 0, f, sizeof n - 1 }
 #define O(n, c, f)    { U n, 0, 0, c, OPERATOR | f, sizeof n - 1 }
@@ -657,8 +645,6 @@ static const struct builtin builtin_arra
   B("__BASE_FILE__",	 BT_BASE_FILE),
   B("__LINE__",		 BT_SPECLINE),
   B("__INCLUDE_LEVEL__", BT_INCLUDE_LEVEL),
-  B("__STDC__",		 BT_STDC),
-  BC("__GXX_WEAK__",     BT_WEAK),
 
   X("__VERSION__",		VERS),
   X("__USER_LABEL_PREFIX__",	ULP),
@@ -676,6 +662,11 @@ static const struct builtin builtin_arra
 #ifndef NO_BUILTIN_WINT_TYPE
   C("__WINT_TYPE__",		WINT_TYPE),
 #endif
+#ifdef STDC_0_IN_SYSTEM_HEADERS
+  B("__STDC__",		 BT_STDC),
+#else
+  C("__STDC__",		 "1"),
+#endif
 
   /* Named operators known to the preprocessor.  These cannot be #defined
      and always have their stated meaning.  They are treated like normal
@@ -727,7 +718,7 @@ init_builtins (pfile)
 	  else
 	    {
 	      hp->type = NT_MACRO;
-	      hp->flags |= NODE_BUILTIN;
+	      hp->flags |= NODE_BUILTIN | NODE_WARN;
 	      hp->value.builtin = b->builtin;
 	    }
 	}
@@ -757,6 +748,29 @@ init_builtins (pfile)
 	  _cpp_define_builtin (pfile, str);
 	}
     }
+
+  if (CPP_OPTION (pfile, cplusplus))
+    {
+      _cpp_define_builtin (pfile, "__cplusplus 1");
+      if (SUPPORTS_ONE_ONLY)
+	_cpp_define_builtin (pfile, "__GXX_WEAK__ 1");
+      else
+	_cpp_define_builtin (pfile, "__GXX_WEAK__ 0");
+    }
+  if (CPP_OPTION (pfile, objc))
+    _cpp_define_builtin (pfile, "__OBJC__ 1");
+
+  if (CPP_OPTION (pfile, lang) == CLK_STDC94)
+    _cpp_define_builtin (pfile, "__STDC_VERSION__ 199409L");
+  else if (CPP_OPTION (pfile, c99))
+    _cpp_define_builtin (pfile, "__STDC_VERSION__ 199901L");
+
+  if (CPP_OPTION (pfile, lang) == CLK_STDC89
+      || CPP_OPTION (pfile, lang) == CLK_STDC94
+      || CPP_OPTION (pfile, lang) == CLK_STDC99)
+    _cpp_define_builtin (pfile, "__STRICT_ANSI__ 1");
+  else if (CPP_OPTION (pfile, lang) == CLK_ASM)
+    _cpp_define_builtin (pfile, "__ASSEMBLER__ 1");
 }
 #undef BUILTIN
 #undef OPERATOR
Index: gcc/cpplib.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplib.c,v
retrieving revision 1.239
diff -u -p -r1.239 cpplib.c
--- cpplib.c	2001/01/31 07:56:07	1.239
+++ cpplib.c	2001/02/28 19:19:52
@@ -477,7 +477,7 @@ do_undef (pfile)
       if (pfile->cb.undef)
 	(*pfile->cb.undef) (pfile, node);
 
-      if (node->flags & NODE_BUILTIN)
+      if (node->flags & NODE_WARN)
 	cpp_warning (pfile, "undefining \"%s\"", node->name);
 
       _cpp_free_definition (node);
Index: gcc/cpplib.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplib.h,v
retrieving revision 1.163
diff -u -p -r1.163 cpplib.h
--- cpplib.h	2001/02/04 08:29:46	1.163
+++ cpplib.h	2001/02/28 19:19:55
@@ -444,6 +444,7 @@ enum cpp_buffer_type {BUF_FAKE, BUF_FILE
 #define NODE_POISONED	(1 << 1)	/* Poisoned identifier.  */
 #define NODE_BUILTIN	(1 << 2)	/* Builtin macro.  */
 #define NODE_DIAGNOSTIC (1 << 3)	/* Possible diagnostic when lexed.  */
+#define NODE_WARN	(1 << 4)	/* Warn if redefined or undefined.  */
 
 /* Different flavors of hash node.  */
 enum node_type
@@ -604,6 +605,7 @@ extern void cpp_forall_identifiers	PARAM
 extern void cpp_scan_buffer_nooutput	PARAMS ((cpp_reader *, int));
 extern void cpp_start_lookahead		PARAMS ((cpp_reader *));
 extern void cpp_stop_lookahead		PARAMS ((cpp_reader *, int));
+extern int  cpp_sys_objmacro_p		PARAMS ((cpp_reader *));
 
 /* In cppfiles.c */
 extern int cpp_included	PARAMS ((cpp_reader *, const char *));
Index: gcc/cppmacro.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppmacro.c,v
retrieving revision 1.44
diff -u -p -r1.44 cppmacro.c
--- cppmacro.c	2001/02/06 19:07:27	1.44
+++ cppmacro.c	2001/02/28 19:19:59
@@ -29,10 +29,6 @@ Foundation, 59 Temple Place - Suite 330,
 #include "cpplib.h"
 #include "cpphash.h"
 
-#ifndef STDC_0_IN_SYSTEM_HEADERS
-#define STDC_0_IN_SYSTEM_HEADERS 0 /* Boolean macro.  */
-#endif
-
 struct cpp_macro
 {
   cpp_hashnode **params;	/* Parameters, if any.  */
@@ -44,6 +40,7 @@ struct cpp_macro
   unsigned int fun_like : 1;	/* If a function-like macro.  */
   unsigned int variadic : 1;	/* If a variadic macro.  */
   unsigned int disabled : 1;	/* If macro is disabled.  */
+  unsigned int syshdr   : 1;	/* If macro defined in system header.  */
 };
 
 typedef struct macro_arg macro_arg;
@@ -91,9 +88,8 @@ static void free_lookahead PARAMS ((cpp_
 /* #define directive parsing and handling.  */
 
 static cpp_token *lex_expansion_token PARAMS ((cpp_reader *, cpp_macro *));
-static int check_macro_redefinition PARAMS ((cpp_reader *,
-					     const cpp_hashnode *,
-					     const cpp_macro *));
+static int warn_of_redefinition PARAMS ((cpp_reader *, const cpp_hashnode *,
+					 const cpp_macro *));
 static int save_parameter PARAMS ((cpp_reader *, cpp_macro *, cpp_hashnode *));
 static int parse_params PARAMS ((cpp_reader *, cpp_macro *));
 static void check_trad_stringification PARAMS ((cpp_reader *,
@@ -183,11 +179,8 @@ builtin_macro (pfile, token)
 
     case BT_STDC:
       {
-	int stdc = 1;
-
-	if (STDC_0_IN_SYSTEM_HEADERS && CPP_IN_SYSTEM_HEADER (pfile)
-	    && pfile->spec_nodes.n__STRICT_ANSI__->type == NT_VOID)
-	  stdc = 0;
+	int stdc = (!CPP_IN_SYSTEM_HEADER (pfile)
+		    || pfile->spec_nodes.n__STRICT_ANSI__->type != NT_VOID);
 	make_number_token (pfile, token, stdc);
       }
       break;
@@ -216,10 +209,6 @@ builtin_macro (pfile, token)
       *token = node->value.builtin == BT_DATE ? pfile->date: pfile->time;
       break;
 
-    case BT_WEAK:
-      make_number_token (pfile, token, SUPPORTS_ONE_ONLY);
-      break;
-
     default:
       cpp_ice (pfile, "invalid builtin macro \"%s\"", node->name);
       break;
@@ -562,7 +551,7 @@ parse_args (pfile, node)
 
       if (argc + 1 == macro->paramc && macro->variadic)
 	{
-	  if (CPP_PEDANTIC (pfile))
+	  if (CPP_PEDANTIC (pfile) && ! macro->syshdr)
 	    cpp_pedwarn (pfile, "ISO C99 requires rest arguments to be used");
 	}
       else
@@ -616,7 +605,7 @@ funlike_invocation_p (pfile, node, list)
 
   if (maybe_paren.type == CPP_OPEN_PAREN)
     args = parse_args (pfile, node);
-  else if (CPP_WTRADITIONAL (pfile))
+  else if (CPP_WTRADITIONAL (pfile) && ! node->value.macro->syshdr)
     cpp_warning (pfile,
 	 "function-like macro \"%s\" must be used with arguments in traditional C",
 		 node->name);
@@ -995,6 +984,18 @@ cpp_get_token (pfile, token)
     save_lookahead_token (pfile, token);
 }
 
+/* Returns true if we're expanding an object-like macro that was
+   defined in a system header.  Just checks the macro at the top of
+   the stack.  Used for diagnostic suppression.  */
+int
+cpp_sys_objmacro_p (pfile)
+     cpp_reader *pfile;
+{
+  cpp_macro *macro = pfile->context->macro;
+
+  return macro && ! macro->fun_like && macro->syshdr;
+}
+
 /* Read each token in, until EOF.  Directives are transparently
    processed.  */
 void
@@ -1165,19 +1166,25 @@ _cpp_push_token (pfile, token, pos)
 
 /* #define directive parsing and handling.  */
 
-/* Returns non-zero if a macro redefinition is trivial.  */
+/* Returns non-zero if a macro redefinition warning is required.  */
 static int
-check_macro_redefinition (pfile, node, macro2)
+warn_of_redefinition (pfile, node, macro2)
      cpp_reader *pfile;
      const cpp_hashnode *node;
      const cpp_macro *macro2;
 {
   const cpp_macro *macro1;
   unsigned int i;
+
+  /* Some redefinitions need to be warned about regardless.  */
+  if (node->flags & NODE_WARN)
+    return 1;
 
-  if (node->type != NT_MACRO || node->flags & NODE_BUILTIN)
-    return ! pfile->done_initializing;
+  if (! CPP_PEDANTIC (pfile))
+    return 0;
 
+  /* Redefinition of a macro is allowed if and only if the old and new
+     definitions are the same.  (6.10.3 paragraph 2). */
   macro1 = node->value.macro;
 
   /* The quick failures.  */
@@ -1185,19 +1192,19 @@ check_macro_redefinition (pfile, node, m
       || macro1->paramc != macro2->paramc
       || macro1->fun_like != macro2->fun_like
       || macro1->variadic != macro2->variadic)
-    return 0;
+    return 1;
 
   /* Check each token.  */
   for (i = 0; i < macro1->count; i++)
     if (! _cpp_equiv_tokens (&macro1->expansion[i], &macro2->expansion[i]))
-      return 0;
+      return 1;
 
   /* Check parameter spellings.  */
   for (i = 0; i < macro1->paramc; i++)
     if (macro1->params[i] != macro2->params[i])
-      return 0;
+      return 1;
 
-  return 1;
+  return 0;
 }
 
 /* Free the definition of hashnode H.  */
@@ -1453,22 +1460,21 @@ _cpp_create_definition (pfile, node)
 		     && macro->expansion[0].type == CPP_NAME
 		     && macro->expansion[0].val.node == node);
 
+  /* To suppress some diagnostics.  */
+  macro->syshdr = pfile->buffer->sysp != 0;
+
   /* Commit the memory.  */
   POOL_COMMIT (&pfile->macro_pool, macro->count * sizeof (cpp_token));
 
-  /* Redefinition of a macro is allowed if and only if the old and new
-     definitions are the same.  (6.10.3 paragraph 2). */
   if (node->type != NT_VOID)
     {
-      if (CPP_PEDANTIC (pfile)
-	  && !check_macro_redefinition (pfile, node, macro))
+      if (warn_of_redefinition (pfile, node, macro))
 	{
 	  cpp_pedwarn_with_line (pfile, pfile->directive_pos.line,
 				 pfile->directive_pos.col,
 				 "\"%s\" redefined", node->name);
 
-	  if (pfile->done_initializing && node->type == NT_MACRO
-	      && !(node->flags & NODE_BUILTIN))
+	  if (node->type == NT_MACRO && !(node->flags & NODE_BUILTIN))
 	    cpp_pedwarn_with_file_and_line (pfile,
 					    node->value.macro->file,
 					    node->value.macro->line, 1,
@@ -1480,6 +1486,8 @@ _cpp_create_definition (pfile, node)
   /* Enter definition in hash table.  */
   node->type = NT_MACRO;
   node->value.macro = macro;
+  if (! ustrncmp (node->name, DSC ("__STDC_")))
+    node->flags |= NODE_WARN;
 
  cleanup:
 


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