X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=libcpp%2Fexpr.c;h=47689189b2b632379e24bf31c7aacb1a79f8b004;hb=31d1d680bb7f175a1accad38f08e13fb90129370;hp=f49bd082858edce6b8e3edc43c2fdc6737ec22a8;hpb=d856c8a6b9ed6ffbbb012ce9f999e9db3a8ee302;p=pf3gnuchains%2Fgcc-fork.git 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);