diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-07-04 12:57:50 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-07-04 12:57:50 +0000 |
commit | d80efa726fcb355ff6a45acc49b4142c87fe41b9 (patch) | |
tree | 7aa5c20469e6c104827c6efe34863e1cdbc76042 /libcpp | |
parent | 9a5b4d700058c15a5e10de62e857195b01f90084 (diff) | |
download | gcc-d80efa726fcb355ff6a45acc49b4142c87fe41b9.tar.gz |
* doc/cpp.texi: Don't document what we do for ill-formed expressions.
* doc/cppopts.texi: Clarify processing of command-line defines.
libcpp:
PR preprocessor/16192
PR preprocessor/15913
PR preprocessor/15572
* expr.c (_cpp_parse_expr): Handle remaining cases where an
expression is missing.
* init.c (post_options): Traditional cpp doesn't do // comments.
testsuite:
* gcc.dg/cpp/if-mop.c: Two new testcases.
* gcc.dg/cpp/trad/comment-3.c: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84080 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 9 | ||||
-rw-r--r-- | libcpp/expr.c | 28 | ||||
-rw-r--r-- | libcpp/init.c | 2 |
3 files changed, 27 insertions, 12 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index 01cb5653f92..2cdd78445b8 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,12 @@ +2004-07-04 Neil Booth <neil@duron.akihabara.co.uk> + + PR preprocessor/16192 + PR preprocessor/15913 + PR preprocessor/15572 + * expr.c (_cpp_parse_expr): Handle remaining cases where an + expression is missing. + * init.c (post_options): Traditional cpp doesn't do // comments. + 2004-06-30 Per Bothner <per@bothner.com> * include/line-map.h (fileline): Remove old typedef. diff --git a/libcpp/expr.c b/libcpp/expr.c index f49bd082858..47689189b2b 100644 --- a/libcpp/expr.c +++ b/libcpp/expr.c @@ -747,18 +747,22 @@ _cpp_parse_expr (cpp_reader *pfile) } else if (want_value) { - /* Ordering here is subtle and intended to favor the - missing parenthesis diagnostics over alternatives. */ - if (op.op == CPP_CLOSE_PAREN) - { - if (top->op == CPP_OPEN_PAREN) - SYNTAX_ERROR ("void expression between '(' and ')'"); - } - else if (top->op == CPP_EOF) - SYNTAX_ERROR ("#if with no expression"); - if (top->op != CPP_EOF && top->op != CPP_OPEN_PAREN) - SYNTAX_ERROR2 ("operator '%s' has no right operand", - cpp_token_as_text (pfile, top->token)); + /* We want a number (or expression) and haven't got one. + Try to emit a specific diagnostic. */ + if (op.op == CPP_CLOSE_PAREN && top->op == CPP_OPEN_PAREN) + SYNTAX_ERROR ("missing expression between '(' and ')'"); + + if (op.op == CPP_EOF && top->op == CPP_EOF) + SYNTAX_ERROR ("#if with no expression"); + + if (top->op != CPP_EOF && top->op != CPP_OPEN_PAREN) + SYNTAX_ERROR2 ("operator '%s' has no right operand", + cpp_token_as_text (pfile, top->token)); + else if (op.op == CPP_CLOSE_PAREN || op.op == CPP_EOF) + /* Complain about missing paren during reduction. */; + else + SYNTAX_ERROR2 ("operator '%s' has no left operand", + cpp_token_as_text (pfile, op.token)); } top = reduce (pfile, top, op.op); diff --git a/libcpp/init.c b/libcpp/init.c index 65cca9b2bab..d1cc1e65d0f 100644 --- a/libcpp/init.c +++ b/libcpp/init.c @@ -611,6 +611,8 @@ post_options (cpp_reader *pfile) if (CPP_OPTION (pfile, traditional)) { + CPP_OPTION (pfile, cplusplus_comments) = 0; + /* Traditional CPP does not accurately track column information. */ CPP_OPTION (pfile, show_column) = 0; CPP_OPTION (pfile, trigraphs) = 0; |