From d6af03689afcb6d54e5ce66a399f68753a2aea3e Mon Sep 17 00:00:00 2001 From: neil Date: Wed, 27 Feb 2002 07:24:53 +0000 Subject: * cpplex.c (_cpp_lex_token): Handle directives in macro arguments. * cpplib.c (_cpp_handle_directive): Save and restore state if parsing macro args when entering a directive. * cppmacro.c (collect_args): No need to handle directives in macro arguments. (enter_macro_context, replace_args): Use the original macro definition in case it was redefined whilst collecting arguments. doc: * cpp.texi: Update. testsuite: * gcc.dg/cpp/undef1.c: Remove. * gcc.dg/cpp/directiv.c: Update. * gcc.dg/cpp/mac-dir-1.c, mac-dir-2.c: New tests. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@50091 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/gcc.dg/cpp/mac-dir-1.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/cpp/mac-dir-1.c (limited to 'gcc/testsuite/gcc.dg/cpp/mac-dir-1.c') diff --git a/gcc/testsuite/gcc.dg/cpp/mac-dir-1.c b/gcc/testsuite/gcc.dg/cpp/mac-dir-1.c new file mode 100644 index 00000000000..002c47f5f2b --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/mac-dir-1.c @@ -0,0 +1,34 @@ +/* Copyright (C) 2002 Free Software Foundation, Inc. */ + +/* { dg-do preprocess } */ + +/* Source: Neil Booth, 26 Feb 2002. + + Test that we allow directives in macro arguments. */ + +/* { dg-do run } */ +/* { dg-options "" } */ + +#define f(x) x +extern void abort (void); + +int main () +{ + if (f ( +#if f(1) /* True. */ + 0)) /* False. */ +#else + 1)) +#endif + abort (); + + /* Outer f expands to original definition, f in argument expands + to new definition, so result is: if (1 != 2 - 1). */ + if (1 != f(2 +#undef f +#define f - 1 + f)) + abort (); + + return 0; +} -- cgit v1.2.1