From: Neil Booth Date: Sat, 16 Sep 2000 07:18:06 +0000 (+0000) Subject: cpplex.c (push_macro_context): Set an argument's level after calling parse_args. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=08ebc1c594f6ed0aaa4a55e865823c4cee885d4c;p=gcc.git cpplex.c (push_macro_context): Set an argument's level after calling parse_args. * cpplex.c (push_macro_context): Set an argument's level after calling parse_args. We could loop infinitely otherwise. * gcc.dg/cpp/macro2.c: New testcase. From-SVN: r36452 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 88195b58f8b..f218aa13f29 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +Sat 16-Sep-2000 08:13:45 BST Neil Booth + + * cpplex.c (push_macro_context): Set an argument's level after + calling parse_args. We could loop infinitely otherwise. + 2000-09-15 Tom Tromey * configure, config.in: Rebuilt. diff --git a/gcc/cpplex.c b/gcc/cpplex.c index 56b8543f995..970b35ff716 100644 --- a/gcc/cpplex.c +++ b/gcc/cpplex.c @@ -2972,7 +2972,6 @@ push_macro_context (pfile, token) args->tokens = 0; args->capacity = 0; args->used = 0; - args->level = pfile->cur_context; prev_nme = prevent_macro_expansion (pfile); pfile->args = args; @@ -2984,6 +2983,8 @@ push_macro_context (pfile, token) free_macro_args (args); return 1; } + /* Set the level after the call to parse_args. */ + args->level = pfile->cur_context; } /* Now push its context. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 54d0fa9297b..510c0333be1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +Sat 16-Sep-2000 08:14:58 BST Neil Booth + + * gcc.dg/cpp/macro2.c: Testcase for multi-context arguments + in nested macro bug. + Fri 15-Sep-2000 06:50:11 BST Neil Booth * gcc.dg/cpp/paste10.c: Testcase for PASTE_LEFT buglet. diff --git a/gcc/testsuite/gcc.dg/cpp/macro2.c b/gcc/testsuite/gcc.dg/cpp/macro2.c new file mode 100644 index 00000000000..2265a2b4cb0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/macro2.c @@ -0,0 +1,14 @@ +/* Copyright (C) 2000 Free Software Foundation, Inc. */ + +/* { dg-do preprocess } */ + +/* Tests the argument context get set at the lower level if we drop + contexts whilst parsing arguments. This would enter an infinite + loop in is_macro_disabled previously. */ + +#define A Something +#define B C +#define C K( +#define K(S) S +#define T B A ) +T /* Expands to . */