diff options
author | Tom Tromey <tromey@redhat.com> | 2008-05-30 14:25:09 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2008-05-30 14:25:09 +0000 |
commit | d750887f5f4273e10625e13d1bac1db9aeef849e (patch) | |
tree | 5c6c1e4ce1846b970214259abb76f69f5370d6be /libcpp/expr.c | |
parent | bfab40f8e5c12b8fd32dfd55a7437528def52f3e (diff) | |
download | gcc-d750887f5f4273e10625e13d1bac1db9aeef849e.zip gcc-d750887f5f4273e10625e13d1bac1db9aeef849e.tar.gz gcc-d750887f5f4273e10625e13d1bac1db9aeef849e.tar.bz2 |
re PR preprocessor/36320 (Required diagnosis of syntax error missed)
gcc/testsuite
PR preprocessor/36320:
* gcc.dg/cpp/pr36320.c: New file.
libcpp
PR preprocessor/36320:
* internal.h (_cpp_parse_expr): Update.
* expr.c (_cpp_parse_expr): Add 'is_if' argument. Update error
messages.
* directives.c (do_if): Update.
(do_elif): Require expression if processing group.
From-SVN: r136209
Diffstat (limited to 'libcpp/expr.c')
-rw-r--r-- | libcpp/expr.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libcpp/expr.c b/libcpp/expr.c index 2e52617..c0e3cbd 100644 --- a/libcpp/expr.c +++ b/libcpp/expr.c @@ -852,7 +852,7 @@ static const struct cpp_operator stored in the 'value' field of the stack element of the operator that precedes it. */ bool -_cpp_parse_expr (cpp_reader *pfile) +_cpp_parse_expr (cpp_reader *pfile, bool is_if) { struct op *top = pfile->op_stack; unsigned int lex_count; @@ -927,7 +927,7 @@ _cpp_parse_expr (cpp_reader *pfile) SYNTAX_ERROR ("missing expression between '(' and ')'"); if (op.op == CPP_EOF && top->op == CPP_EOF) - SYNTAX_ERROR ("#if with no expression"); + SYNTAX_ERROR2 ("%s with no expression", is_if ? "#if" : "#elif"); if (top->op != CPP_EOF && top->op != CPP_OPEN_PAREN) SYNTAX_ERROR2 ("operator '%s' has no right operand", @@ -988,7 +988,8 @@ _cpp_parse_expr (cpp_reader *pfile) if (top != pfile->op_stack) { - cpp_error (pfile, CPP_DL_ICE, "unbalanced stack in #if"); + cpp_error (pfile, CPP_DL_ICE, "unbalanced stack in %s", + is_if ? "#if" : "#elif"); syntax_error: return false; /* Return false on syntax error. */ } |