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: Tidy up lang handling.


Gets rid of c89, which was confusing and being abused, in favour of a
flag extended_numbers.  Also, get rid of lang_asm flag, in favour of a
more general lang variable.

I may get rid of c99 for similar reasons soon.

Neil.

	* cpplib.h (struct cpp_reader): Remove lang_asm.
	(struct cpp_options): Remove c89. New members lang,
	extended_numbers.
	* cppexp.c (parse_number): Use them.
	* cpphash.h (VALID_SIGN): Use them.
	* cppinit.c (set_lang, cpp_start_read): Update.
	* cpplex.c (parse_string, _cpp_lex_token): Update.
	* cpplib.c (_cpp_handle_directive): Update.
	* cppmacro.c (parse_args): Update.
	* cppmain.c (scan_buffer): Update.

Index: cppexp.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppexp.c,v
retrieving revision 1.80
diff -u -p -r1.80 cppexp.c
--- cppexp.c	2000/11/20 18:27:30	1.80
+++ cppexp.c	2000/11/26 13:45:43
@@ -205,9 +205,7 @@ parse_number (pfile, tok)
 
       if (CPP_WTRADITIONAL (pfile) && sufftab[i].u)
 	cpp_warning (pfile, "traditional C rejects the `U' suffix");
-      if (CPP_OPTION (pfile, c89)
-	  && sufftab[i].l == 2
-	  && pfile->spec_nodes.n__STRICT_ANSI__->type == NT_MACRO)
+      if (sufftab[i].l == 2 && !CPP_OPTION (pfile, extended_numbers))
 	SYNTAX_ERROR ("too many 'l' suffixes in integer constant");
     }
   
Index: cpphash.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpphash.h,v
retrieving revision 1.80
diff -u -p -r1.80 cpphash.h
--- cpphash.h	2000/11/14 18:32:05	1.80
+++ cpphash.h	2000/11/26 13:45:43
@@ -26,7 +26,8 @@ Foundation, 59 Temple Place - Suite 330,
 #define VALID_SIGN(c, prevc) \
   (((c) == '+' || (c) == '-') && \
    ((prevc) == 'e' || (prevc) == 'E' \
-    || (((prevc) == 'p' || (prevc) == 'P') && !CPP_OPTION (pfile, c89))))
+    || (((prevc) == 'p' || (prevc) == 'P') \
+        && CPP_OPTION (pfile, extended_numbers))))
 
 /* Memory pools.  */
 #define ALIGN(size, align) (((size) + ((align) - 1)) & ~((align) - 1))
Index: cppinit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppinit.c,v
retrieving revision 1.118
diff -u -p -r1.118 cppinit.c
--- cppinit.c	2000/11/26 10:48:49	1.118
+++ cppinit.c	2000/11/26 13:45:46
@@ -431,10 +431,10 @@ set_lang (pfile, lang)
 {
   struct cpp_pending *pend = CPP_OPTION (pfile, pending);
 
-  /* Default to zero.  */
-  CPP_OPTION (pfile, lang_asm) = 0;
+  /* Defaults.  */
   CPP_OPTION (pfile, objc) = 0;
   CPP_OPTION (pfile, cplusplus) = 0;
+  CPP_OPTION (pfile, extended_numbers) = 1; /* Allowed in GNU C and C99.  */
 
   switch (lang)
     {
@@ -444,7 +444,6 @@ set_lang (pfile, lang)
       CPP_OPTION (pfile, dollars_in_ident) = 1;
       CPP_OPTION (pfile, cplusplus_comments) = 1;
       CPP_OPTION (pfile, digraphs) = 1;
-      CPP_OPTION (pfile, c89) = 0;
       CPP_OPTION (pfile, c99) = 1;
       new_pending_directive (pend, "__STDC_VERSION__=199901L", cpp_define);
       break;
@@ -453,7 +452,6 @@ set_lang (pfile, lang)
       CPP_OPTION (pfile, dollars_in_ident) = 1;
       CPP_OPTION (pfile, cplusplus_comments) = 1;
       CPP_OPTION (pfile, digraphs) = 1;
-      CPP_OPTION (pfile, c89) = 1;
       CPP_OPTION (pfile, c99) = 0;
       break;
 
@@ -465,8 +463,8 @@ set_lang (pfile, lang)
       CPP_OPTION (pfile, dollars_in_ident) = 0;
       CPP_OPTION (pfile, cplusplus_comments) = 0;
       CPP_OPTION (pfile, digraphs) = lang == CLK_STDC94;
-      CPP_OPTION (pfile, c89) = 1;
       CPP_OPTION (pfile, c99) = 0;
+      CPP_OPTION (pfile, extended_numbers) = 0;
       new_pending_directive (pend, "__STRICT_ANSI__", cpp_define);
       break;
     case CLK_STDC99:
@@ -474,7 +472,6 @@ set_lang (pfile, lang)
       CPP_OPTION (pfile, dollars_in_ident) = 0;
       CPP_OPTION (pfile, cplusplus_comments) = 1;
       CPP_OPTION (pfile, digraphs) = 1;
-      CPP_OPTION (pfile, c89) = 0;
       CPP_OPTION (pfile, c99) = 1;
       new_pending_directive (pend, "__STRICT_ANSI__", cpp_define);
       new_pending_directive (pend, "__STDC_VERSION__=199901L", cpp_define);
@@ -489,7 +486,6 @@ set_lang (pfile, lang)
       CPP_OPTION (pfile, dollars_in_ident) = 1;
       CPP_OPTION (pfile, cplusplus_comments) = 1;
       CPP_OPTION (pfile, digraphs) = 1;
-      CPP_OPTION (pfile, c89) = 0;
       CPP_OPTION (pfile, c99) = 0;
       CPP_OPTION (pfile, objc) = 1;
       new_pending_directive (pend, "__OBJC__", cpp_define);
@@ -503,7 +499,6 @@ set_lang (pfile, lang)
       CPP_OPTION (pfile, dollars_in_ident) = lang == CLK_GNUCXX;
       CPP_OPTION (pfile, cplusplus_comments) = 1;
       CPP_OPTION (pfile, digraphs) = 1;
-      CPP_OPTION (pfile, c89) = 0;
       CPP_OPTION (pfile, c99) = 0;
       new_pending_directive (pend, "__cplusplus", cpp_define);
       break;
@@ -514,9 +509,7 @@ set_lang (pfile, lang)
       CPP_OPTION (pfile, dollars_in_ident) = 0;	/* Maybe not?  */
       CPP_OPTION (pfile, cplusplus_comments) = 1;
       CPP_OPTION (pfile, digraphs) = 0; 
-     CPP_OPTION (pfile, c89) = 0;
       CPP_OPTION (pfile, c99) = 0;
-      CPP_OPTION (pfile, lang_asm) = 1;
       new_pending_directive (pend, "__ASSEMBLER__", cpp_define);
       break;
     }
@@ -979,7 +972,7 @@ cpp_start_read (pfile, fname)
     CPP_OPTION (pfile, warn_traditional) = 0;
 
   /* Do not warn about invalid token pasting if -lang-asm.  */
-  if (CPP_OPTION (pfile, lang_asm))
+  if (CPP_OPTION (pfile, lang) == CLK_ASM)
     CPP_OPTION (pfile, warn_paste) = 0;
 
   /* Set this if it hasn't been set already. */
Index: cpplex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplex.c,v
retrieving revision 1.120
diff -u -p -r1.120 cpplex.c
--- cpplex.c	2000/11/22 20:36:10	1.120
+++ cpplex.c	2000/11/26 13:45:52
@@ -673,7 +673,7 @@ parse_string (pfile, token, terminator)
 	  /* In assembly language, silently terminate string and
 	     character literals at end of line.  This is a kludge
 	     around not knowing where comments are.  */
-	  if (CPP_OPTION (pfile, lang_asm) && terminator != '>')
+	  if (CPP_OPTION (pfile, lang) == CLK_ASM && terminator != '>')
 	    break;
 
 	  /* Character constants and header names may not extend over
@@ -1007,11 +1007,9 @@ _cpp_lex_token (pfile, result)
 	      && !CPP_IN_SYSTEM_HEADER (pfile))
 	    break;
 
-	  /* We silently allow C++ comments in system headers,
-	     irrespective of conformance mode, because lots of
-	     broken systems do that and trying to clean it up in
-	     fixincludes is a nightmare.  */
-	  if (CPP_OPTION (pfile, c89) && CPP_PEDANTIC (pfile)
+	  /* Warn about comments only if pedantically GNUC89, and not
+	     in system headers.  */
+	  if (CPP_OPTION (pfile, lang) == CLK_GNUC89 && CPP_PEDANTIC (pfile)
 	      && ! buffer->warned_cplusplus_comments)
 	    {
 	      cpp_pedwarn (pfile,
Index: cpplib.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplib.c,v
retrieving revision 1.221
diff -u -p -r1.221 cpplib.c
--- cpplib.c	2000/11/17 04:16:54	1.221
+++ cpplib.c	2000/11/26 13:45:57
@@ -293,7 +293,7 @@ _cpp_handle_directive (pfile, indented)
 	 skipped conditional groups.  Complain about this form if
 	 we're being pedantic, but not if this is regurgitated input
 	 (preprocessed or fed back in by the C++ frontend).  */
-      if (! buffer->was_skipping  && !CPP_OPTION (pfile, lang_asm))
+      if (! buffer->was_skipping && CPP_OPTION (pfile, lang) != CLK_ASM)
 	{
 	  dir = &dtable[T_LINE];
 	  _cpp_push_token (pfile, &dname, &pfile->directive_pos);
@@ -354,7 +354,7 @@ _cpp_handle_directive (pfile, indented)
 	 source: we don't know where the comments are, and # may
 	 introduce assembler pseudo-ops.  Don't complain about invalid
 	 directives in skipped conditional groups (6.10 p4).  */
-      if (CPP_OPTION (pfile, lang_asm))
+      if (CPP_OPTION (pfile, lang) == CLK_ASM)
 	{
 	  /* Output the # and lookahead token for the assembler.  */
 	  _cpp_push_token (pfile, &dname, &pfile->directive_pos);
Index: cpplib.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplib.h,v
retrieving revision 1.138
diff -u -p -r1.138 cpplib.h
--- cpplib.h	2000/11/22 20:36:10	1.138
+++ cpplib.h	2000/11/26 13:46:05
@@ -351,6 +351,9 @@ struct cpp_options
   /* -fleading_underscore sets this to "_".  */
   const char *user_label_prefix;
 
+  /* The language we're preprocessing.  */
+  enum c_lang lang;
+
   /* Non-0 means -v, so print the full set of include dirs.  */
   unsigned char verbose;
 
@@ -363,12 +366,6 @@ struct cpp_options
   /* Nonzero means handle #import, for objective C.  */
   unsigned char objc;
 
-  /* Nonzero means this is an assembly file, so ignore unrecognized
-     directives and the "# 33" form of #line, both of which are
-     probably comments.  Also, permit unbalanced ' strings (again,
-     likely to be in comments).  */
-  unsigned char lang_asm;
-
   /* Nonzero means don't copy comments into the output file.  */
   unsigned char discard_comments;
 
@@ -378,6 +375,9 @@ struct cpp_options
   /* Nonzero means process the ISO digraph sequences.  */
   unsigned char digraphs;
 
+  /* Nonzero means to allow hexadecimal floats and LL suffixes.  */
+  unsigned char extended_numbers;
+
   /* Nonzero means print the names of included files rather than the
      preprocessed output.  1 means just the #include "...", 2 means
      #include <...> as well.  */
@@ -446,9 +446,6 @@ struct cpp_options
 
   /* Nonzero means warn if undefined identifiers are evaluated in an #if.  */
   unsigned char warn_undef;
-
-  /* Nonzero for the 1989 C Standard, including corrigenda and amendments.  */
-  unsigned char c89;
 
   /* Nonzero for the 1999 C Standard, including corrigenda and amendments.  */
   unsigned char c99;
Index: cppmacro.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppmacro.c,v
retrieving revision 1.28
diff -u -p -r1.28 cppmacro.c
--- cppmacro.c	2000/11/20 23:59:26	1.28
+++ cppmacro.c	2000/11/26 13:46:06
@@ -564,7 +564,7 @@ parse_args (pfile, node)
 
       if (argc + 1 == macro->paramc && macro->var_args)
 	{
-	  if (CPP_OPTION (pfile, c99) && CPP_PEDANTIC (pfile))
+	  if (CPP_OPTION (pfile, lang) == CLK_STDC99 && CPP_PEDANTIC (pfile))
 	    cpp_pedwarn (pfile, "ISO C99 requires rest arguments to be used");
 	}
       else
@@ -1395,7 +1395,7 @@ _cpp_create_definition (pfile, node)
 	      macro->count--;
 	    }
 	  /* Let assembler get away with murder.  */
-	  else if (!CPP_OPTION (pfile, lang_asm))
+	  else if (CPP_OPTION (pfile, lang) != CLK_ASM)
 	    {
 	      ok = 0;
 	      cpp_error (pfile, "'#' is not followed by a macro parameter");
Index: cppmain.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppmain.c,v
retrieving revision 1.40
diff -u -p -r1.40 cppmain.c
--- cppmain.c	2000/11/20 18:27:31	1.40
+++ cppmain.c	2000/11/26 13:46:06
@@ -199,7 +199,7 @@ scan_buffer (pfile)
 	    }
 	  else if (print.printed
 		   && ! (token->flags & PREV_WHITE)
-		   && ! CPP_OPTION (pfile, lang_asm)
+		   && CPP_OPTION (pfile, lang) != CLK_ASM
 		   && cpp_avoid_paste (pfile, &tokens[1 - index], token))
 	    token->flags |= PREV_WHITE;
 

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