diff options
author | Chris Lattner <sabre@nondot.org> | 2008-05-04 18:36:18 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-05-04 18:36:18 +0000 |
commit | d89e458ce00319f332775b4765bd99f9031e2cb5 (patch) | |
tree | 79ebec69e85b974ca7f372b293649d094ba9bf83 /clang/lib/Lex/PPExpressions.cpp | |
parent | a08f869c22910bd7f692a21560d8d1f534393158 (diff) | |
download | bcm5719-llvm-d89e458ce00319f332775b4765bd99f9031e2cb5.tar.gz bcm5719-llvm-d89e458ce00319f332775b4765bd99f9031e2cb5.zip |
Fix the rest of PR2279:
a) correct rejection of ',' in pp expressions.
b) the precedence of ',' was wrong w.r.t. ?:.
Thanks again to Neil for finding these and providing testcases.
llvm-svn: 50625
Diffstat (limited to 'clang/lib/Lex/PPExpressions.cpp')
-rw-r--r-- | clang/lib/Lex/PPExpressions.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp index 6343a3c0983..3c0bf5c59c8 100644 --- a/clang/lib/Lex/PPExpressions.cpp +++ b/clang/lib/Lex/PPExpressions.cpp @@ -328,9 +328,9 @@ static unsigned getPrecedence(tok::TokenKind Kind) { case tok::pipe: return 7; case tok::ampamp: return 6; case tok::pipepipe: return 5; - case tok::question: return 4; - case tok::colon: return 3; - case tok::comma: return 2; + case tok::comma: return 4; + case tok::question: return 3; + case tok::colon: return 2; case tok::r_paren: return 0; // Lowest priority, end of expr. case tok::eom: return 0; // Lowest priority, end of macro. } @@ -543,7 +543,10 @@ static bool EvaluateDirectiveSubExpr(llvm::APSInt &LHS, unsigned MinPrec, Res.setIsUnsigned(false); // C99 6.5.14p3, result is always int (signed) break; case tok::comma: - PP.Diag(OpToken, diag::ext_pp_comma_expr); + // Comma is invalid in pp expressions in c89/c++ mode, but is valid in C99 + // if not being evaluated. + if (!PP.getLangOptions().C99 || ValueLive) + PP.Diag(OpToken, diag::ext_pp_comma_expr); Res = RHS; // LHS = LHS,RHS -> RHS. break; case tok::question: { |