From 37dbf7aa9c7ecd0d04c5caf229023d9e4d911129 Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Tue, 30 May 2000 02:40:48 +0000 Subject: [PATCH] cpplib.c (do_if): Don't save and restore only_seen_white here. * cpplib.c (do_if): Don't save and restore only_seen_white here. * cppexp.c (_cpp_parse_expr): Save and restore only_seen_white and skipping here. From-SVN: r34260 --- gcc/ChangeLog | 18 ++++++++++++------ gcc/cppexp.c | 8 ++++++++ gcc/cpplib.c | 4 ---- gcc/testsuite/gcc.dg/20000529-1.c | 14 ++++++++++++++ 4 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/20000529-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3fc27462251..525c8b0f1bf 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2000-05-29 Zack Weinberg + + * cpplib.c (do_if): Don't save and restore only_seen_white here. + * cppexp.c (_cpp_parse_expr): Save and restore only_seen_white + and skipping here. + 2000-05-29 Richard Earnshaw (rearnsha@arm.com) * flow.c (mark_used_reg): If a register is unconditionally live, @@ -249,14 +255,14 @@ Sun May 28 23:26:59 2000 Philippe De Muyter 2000-05-28 Neil Booth - * cpplex.c (_cpp_init_toklist): No comment space to initialise. + * cpplex.c (_cpp_init_toklist): No comment space to initialise. (_cpp_free_toklist): No comment space to free. (expand_comment_space): Remove. - (save_comment_space): Place the comment in the current token and - not in a separate comment space. - (_cpp_lex_line): Save comments during plain code and #define - directives only. - * cpplib.h (struct _cpp_toklist): Remove comment space. + (save_comment_space): Place the comment in the current token and + not in a separate comment space. + (_cpp_lex_line): Save comments during plain code and #define + directives only. + * cpplib.h (struct _cpp_toklist): Remove comment space. 2000-05-28 Neil Booth diff --git a/gcc/cppexp.c b/gcc/cppexp.c index b50acd8bb3c..58430c331e2 100644 --- a/gcc/cppexp.c +++ b/gcc/cppexp.c @@ -843,6 +843,12 @@ _cpp_parse_expr (pfile) int result; char buff[5]; + /* Save parser state and set it to something sane. */ + int save_only_seen_white = pfile->only_seen_white; + int save_skipping = pfile->skipping; + pfile->only_seen_white = 0; + pfile->skipping = 0; + /* We've finished when we try to reduce this. */ top->op = FINISHED; /* Nifty way to catch missing '('. */ @@ -1162,5 +1168,7 @@ _cpp_parse_expr (pfile) if (stack != init_stack) free (stack); CPP_SET_WRITTEN (pfile, old_written); + pfile->only_seen_white = save_only_seen_white; + pfile->skipping = save_skipping; return result; } diff --git a/gcc/cpplib.c b/gcc/cpplib.c index 3bc882562e7..e339c1eaab3 100644 --- a/gcc/cpplib.c +++ b/gcc/cpplib.c @@ -1186,15 +1186,11 @@ do_if (pfile) { const cpp_hashnode *cmacro = 0; int value = 0; - int save_only_seen_white = pfile->only_seen_white; if (! pfile->skipping) { cmacro = detect_if_not_defined (pfile); - - pfile->only_seen_white = 0; value = _cpp_parse_expr (pfile); - pfile->only_seen_white = save_only_seen_white; } push_conditional (pfile, value == 0, T_IF, cmacro); return 0; diff --git a/gcc/testsuite/gcc.dg/20000529-1.c b/gcc/testsuite/gcc.dg/20000529-1.c new file mode 100644 index 00000000000..6343a81feb7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20000529-1.c @@ -0,0 +1,14 @@ +/* Regression test for bug with macro expansion on #if lines - + exposed by glibc. */ +/* { dg-do compile } */ + +# define SHLIB_COMPAT(lib, introduced, obsoleted) \ + (!(ABI_##lib##_##obsoleted - 0) \ + || ((ABI_##lib##_##introduced - 0) < (ABI_##lib##_##obsoleted - 0))) + +#if 0 +bad +#elif SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) +int +#endif +x;