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]

Fix preprocessor/8497 and preprocessor/8501


The new integrated traditional preprocessor has a couple of minor
issues, fixed with this patch and testcases.

Neil.

	* cpptrad.c (scan_out_logical_line): A '#' from a macro doesn't
	start a directive.  In assembler, #NUM is not a line directive.

Index: cpptrad.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpptrad.c,v
retrieving revision 1.27
diff -u -p -r1.27 cpptrad.c
--- cpptrad.c	23 Jul 2002 22:57:44 -0000	1.27
+++ cpptrad.c	8 Nov 2002 21:08:00 -0000
@@ -682,7 +682,10 @@ scan_out_logical_line (pfile, macro)
 	  break;
 
 	case '#':
-	  if (out - 1 == pfile->out.base && !pfile->state.in_directive)
+	  if (out - 1 == pfile->out.base
+	      /* A '#' from a macro doesn't start a directive.  */
+	      && !pfile->context->prev
+	      && !pfile->state.in_directive)
 	    {
 	      /* A directive.  With the way _cpp_handle_directive
 		 currently works, we only want to call it if either we
@@ -705,7 +708,8 @@ scan_out_logical_line (pfile, macro)
 		{
 		  bool do_it = false;
 
-		  if (is_numstart (*cur))
+		  if (is_numstart (*cur)
+		      && CPP_OPTION (pfile, lang) != CLK_ASM)
 		    do_it = true;
 		  else if (is_idstart (*cur))
 		    /* Check whether we know this directive, but don't
Index: testsuite/gcc.dg/cpp/trad/assembler.S
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/cpp/trad/assembler.S,v
retrieving revision 1.1
diff -u -p -r1.1 assembler.S
--- testsuite/gcc.dg/cpp/trad/assembler.S	24 Jun 2002 05:46:51 -0000	1.1
+++ testsuite/gcc.dg/cpp/trad/assembler.S	8 Nov 2002 21:08:02 -0000
@@ -4,6 +4,10 @@
 
 /* { dg-do preprocess } */
 
+#ifndef FOO
+#1			/* Once caused a bogus unterminated #ifndef.  */
+#endif
+		
 #define foo() mov r0, #5  /* { dg-bogus "not followed" "spurious warning" } */
 
 entry:
Index: testsuite/gcc.dg/cpp/trad/directive.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/cpp/trad/directive.c,v
retrieving revision 1.3
diff -u -p -r1.3 directive.c
--- testsuite/gcc.dg/cpp/trad/directive.c	2 Jul 2002 22:33:38 -0000	1.3
+++ testsuite/gcc.dg/cpp/trad/directive.c	8 Nov 2002 21:08:02 -0000
@@ -2,6 +2,9 @@
 
 /* { dg-do preprocess } */
 
+#define HASH #
+HASH
+
 /* There is a #error directive.  */
 
 #error bad	/* { dg-error "bad" } */


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