This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
patch for overzealous standard conformance / mangling .S files
- To: gcc-patches at gcc dot gnu dot org
- Subject: patch for overzealous standard conformance / mangling .S files
- From: Zack Weinberg <zack at wolery dot cumb dot org>
- Date: Thu, 11 May 2000 01:42:46 -0700
cpp would issue a hard error for # not followed by a macro argument
name in function-like macros. That caused problems with preprocessing
assembly language on some platforms; e.g. on MIPS, # may be needed to
introduce an integer literal.
This patch downgrades the error to a pedwarn, shuts it off entirely
when we're preprocessing assembly, and preserves the # in the output.
You'll need a patch to the testsuite drivers for 20000510-1.S to be
recognized - see "RFA: testsuite change" which appeared earlier today
(um, yesterday now). The patch is in CVS.
Bootstrapped on i386-linux, as usual.
zw
* cpphash.c (collect_funlike_expansion): Make "# is not
followed by a macro argument name" a pedwarn, not an error.
Preserve the # in the output. Suppress the warning if lang_asm.
===================================================================
Index: cpphash.c
--- cpphash.c 2000/05/10 19:11:02 1.87
+++ cpphash.c 2000/05/11 08:41:28
@@ -639,7 +639,22 @@ collect_funlike_expansion (pfile, list,
default:
norm:
if (last_token == STRIZE)
- cpp_error (pfile, "# is not followed by a macro argument name");
+ {
+ /* This is a mandatory diagnostic (6.10.3.2 para 1), but
+ in assembly language # may have some other
+ significance we don't know about, so suppress the
+ warning. */
+ if (! CPP_OPTION (pfile, lang_asm))
+ cpp_pedwarn (pfile,
+ "# is not followed by a macro argument name");
+ if (TOK_PREV_WHITE (list, i))
+ CPP_ADJUST_WRITTEN (pfile, -1);
+ if (TOK_PREV_WHITE (list, i-1))
+ CPP_PUTC (pfile, ' ');
+ CPP_PUTC (pfile, '#');
+ if (TOK_PREV_WHITE (list, i))
+ CPP_PUTC (pfile, ' ');
+ }
CPP_PUTS (pfile, tok, len);
last_token = NORM;
}
===================================================================
Index: testsuite/gcc.dg/20000510-1.S
--- testsuite/gcc.dg/20000510-1.S Tue May 5 13:32:27 1998
+++ testsuite/gcc.dg/20000510-1.S Thu May 11 01:41:28 2000
@@ -0,0 +1,20 @@
+/* Regression test - in assembly language, # may have some significance
+ other than 'stringize macro argument' and therefore must be preserved
+ in the output, and should not be warned about. */
+/* { dg-do preprocess } */
+
+#define foo() mov r0, #5 /* { dg-bogus "not followed" "spurious warning" } */
+
+entry:
+ foo()
+
+/*
+ { dg-final { if ![file exists 20000510-1.i] { return } } }
+ { dg-final { set tmp [grep 20000510-1.i # line] } }
+ { dg-final { if {[string length $tmp] > 0} \{ } }
+ { dg-final { pass "20000510-1.S: # preservation" } }
+ { dg-final { \} else \{ } }
+ { dg-final { fail "20000510-1.S: # preservation" } }
+ { dg-final { \} } }
+*/
+