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: Paste warning mandatory


Zack and I agreed we should make the inability to paste 2 tokens a
mandatory warning, apart for assembler.  Now we have an integrated
preprocessor, this is especially important: it's treated as 2 tokens
regardless; not putting a space between them doesn't help any more.
Until now, there was an (undocumented) option -Wno-paste to suppress
these warnings.

Of course, as it is still a warning, it is suppressed in system
headers.

In future, maybe the next non-minor GCC revision after 3.0, it might
be worth making this a hard error, after people have had a chance to
adjust their code with the current warnings.

Neil.

	* cppinit.c (cpp_reader_init): Remove handling of warn_paste
	command line options.
	(cpp_handle_option): Similarly.
	* cpplib.h (struct cpp_options): Remove warn_paste.
	* cppmacro.c (paste_tokens): Apart from assembler, make
	unpasteable token warning mandatory.

Index: cppinit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppinit.c,v
retrieving revision 1.119
diff -u -p -r1.119 cppinit.c
--- cppinit.c	2000/11/26 17:31:09	1.119
+++ cppinit.c	2000/11/27 18:46:19
@@ -536,7 +536,6 @@ cpp_reader_init (pfile, lang)
     }
 
   CPP_OPTION (pfile, warn_import) = 1;
-  CPP_OPTION (pfile, warn_paste) = 1;
   CPP_OPTION (pfile, discard_comments) = 1;
   CPP_OPTION (pfile, show_column) = 1;
   CPP_OPTION (pfile, tabstop) = 8;
@@ -972,10 +971,6 @@ cpp_start_read (pfile, fname)
   if (CPP_OPTION (pfile, cplusplus))
     CPP_OPTION (pfile, warn_traditional) = 0;
 
-  /* Do not warn about invalid token pasting if -lang-asm.  */
-  if (CPP_OPTION (pfile, lang) == CLK_ASM)
-    CPP_OPTION (pfile, warn_paste) = 0;
-
   /* Set this if it hasn't been set already. */
   if (CPP_OPTION (pfile, user_label_prefix) == NULL)
     CPP_OPTION (pfile, user_label_prefix) = USER_LABEL_PREFIX;
@@ -1690,8 +1685,6 @@ cpp_handle_option (pfile, argc, argv)
 	    CPP_OPTION (pfile, warn_undef) = 1;
 	  else if (!strcmp (argv[i], "-Wimport"))
 	    CPP_OPTION (pfile, warn_import) = 1;
-	  else if (!strcmp (argv[i], "-Wpaste"))
-	    CPP_OPTION (pfile, warn_paste) = 1;
 	  else if (!strcmp (argv[i], "-Werror"))
 	    CPP_OPTION (pfile, warnings_are_errors) = 1;
 	  else if (!strcmp (argv[i], "-Wsystem-headers"))
@@ -1708,8 +1701,6 @@ cpp_handle_option (pfile, argc, argv)
 	    CPP_OPTION (pfile, warn_undef) = 0;
 	  else if (!strcmp (argv[i], "-Wno-import"))
 	    CPP_OPTION (pfile, warn_import) = 0;
-	  else if (!strcmp (argv[i], "-Wno-paste"))
-	    CPP_OPTION (pfile, warn_paste) = 0;
 	  else if (!strcmp (argv[i], "-Wno-error"))
 	    CPP_OPTION (pfile, warnings_are_errors) = 0;
 	  else if (!strcmp (argv[i], "-Wno-system-headers"))
Index: cpplib.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplib.h,v
retrieving revision 1.140
diff -u -p -r1.140 cpplib.h
--- cpplib.h	2000/11/27 08:00:03	1.140
+++ cpplib.h	2000/11/27 18:46:29
@@ -367,10 +367,6 @@ struct cpp_options
      traditional C.  */
   unsigned char warn_traditional;
 
-  /* Nonzero means warn if ## is applied to two tokens that cannot be
-     pasted together.  */
-  unsigned char warn_paste;
-
   /* Nonzero means turn warnings into errors.  */
   unsigned char warnings_are_errors;
 
Index: cppmacro.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppmacro.c,v
retrieving revision 1.30
diff -u -p -r1.30 cppmacro.c
--- cppmacro.c	2000/11/26 19:30:27	1.30
+++ cppmacro.c	2000/11/27 18:46:29
@@ -379,17 +379,20 @@ paste_tokens (pfile, lhs, rhs)
   
   if (type == CPP_EOF)
     {
-      if (CPP_OPTION (pfile, warn_paste))
+      /* Mandatory warning for all apart from assembler.  */
+      if (CPP_OPTION (pfile, lang) != CLK_ASM)
 	cpp_warning (pfile,
 	 "pasting \"%s\" and \"%s\" does not give a valid preprocessing token",
 		     cpp_token_as_text (pfile, lhs),
 		     cpp_token_as_text (pfile, rhs));
 
       /* The standard states that behaviour is undefined.  By the
-	 principle of least surpise, we step back before the RHS, and
-	 mark it to prevent macro expansion.  Tests in the testsuite
-	 rely on clearing PREV_WHITE here, though you could argue we
-	 should actually set it.  */
+         principle of least surpise, we step back before the RHS, and
+         mark it to prevent macro expansion.  Tests in the testsuite
+         rely on clearing PREV_WHITE here, though you could argue we
+         should actually set it.  Assembler can have '.' in labels and
+         so requires that we don't insert spaces there.  Maybe we should
+	 change this to put out a space unless it's assembler.  */
       rhs->flags &= ~PREV_WHITE;
       rhs->flags |= NO_EXPAND;
       return 1;


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