* cpphash.c (macarg): Set it.
* cpplib.c (handle_directive): If no_directives is on and we
find a directive, issue an error and discard the line.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@31763
138bc75d-0d04-0410-961f-
82ee72b054a4
+2000-02-02 Zack Weinberg <zack@wolery.cumb.org>
+
+ * cpplib.h (cpp_reader): Add new flag, no_directives.
+ * cpphash.c (macarg): Set it.
+ * cpplib.c (handle_directive): If no_directives is on and we
+ find a directive, issue an error and discard the line.
+
Wed Feb 2 13:07:10 2000 Jim Wilson <wilson@cygnus.com>
* config/sparc/sparc.h (PREFERRED_RELOAD_CLASS): Delete 'E' check for
/* Try to parse as much of the argument as exists at this
input stack level. */
pfile->no_macro_expand++;
+ pfile->no_directives++;
CPP_OPTIONS (pfile)->no_line_commands++;
for (;;)
{
CPP_OPTIONS (pfile)->put_out_comments = save_put_out_comments;
CPP_OPTIONS (pfile)->no_line_commands--;
pfile->no_macro_expand--;
+ pfile->no_directives--;
return token;
}
}
CPP_SET_WRITTEN (pfile, old_written);
- (*kt->func) (pfile, kt);
+
+ if (pfile->no_directives)
+ {
+ cpp_error (pfile, "`#%s' may not be used inside a macro argument",
+ kt->name);
+ skip_rest_of_line (pfile);
+ }
+ else
+ (*kt->func) (pfile, kt);
return 1;
}
/* If non-zero, macros are not expanded. */
char no_macro_expand;
+ /* If non-zero, directives cause a hard error. Used when parsing
+ macro arguments. */
+
+ char no_directives;
+
/* Print column number in error messages. */
char show_column;
--- /dev/null
+/* { dg-do preprocess } */
+
+/* 6.9.3.11: ...If there are sequences of preprocessing tokens within
+ the list of arguments that would otherwise act as preprocessing
+ directives, the behavior is undefined.
+
+ I choose to make this a hard error. It definitely should not cause
+ a core dump. */
+
+#define foo(bar) bar
+
+foo( blah
+#undef foo /* { dg-error "may not be used inside" "foo(#undef foo)" } */
+ blah )