diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-24 22:35:48 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-24 22:35:48 +0000 |
| commit | 62f65951220a6a14200b94fdd02bec134aab731f (patch) | |
| tree | 09e2acf54185dac8afe6c141becd4b48d1e09d09 | |
| parent | 43edb32f1f032c366ad06faec09832912f538ba6 (diff) | |
| download | bcm5719-llvm-62f65951220a6a14200b94fdd02bec134aab731f.tar.gz bcm5719-llvm-62f65951220a6a14200b94fdd02bec134aab731f.zip | |
Add explanatory comments for ICE checking in C99 mode.
llvm-svn: 142866
| -rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 98fe07f1b68..edcf3c8fa2e 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -2974,6 +2974,9 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { return NoDiag(); case Expr::CallExprClass: case Expr::CXXOperatorCallExprClass: { + // C99 6.6/3 allows function calls within unevaluated subexpressions of + // constant expressions, but they can never be ICEs because an ICE cannot + // contain an operand of (pointer to) function type. const CallExpr *CE = cast<CallExpr>(E); if (CE->isBuiltinCall(Ctx)) return CheckEvalInICE(E, Ctx); @@ -3034,6 +3037,9 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { case UO_PreDec: case UO_AddrOf: case UO_Deref: + // C99 6.6/3 allows increment and decrement within unevaluated + // subexpressions of constant expressions, but they can never be ICEs + // because an ICE cannot contain an lvalue operand. return ICEDiag(2, E->getLocStart()); case UO_Extension: case UO_LNot: @@ -3050,7 +3056,7 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { case Expr::OffsetOfExprClass: { // Note that per C99, offsetof must be an ICE. And AFAIK, using // Evaluate matches the proposed gcc behavior for cases like - // "offsetof(struct s{int x[4];}, x[!.0])". This doesn't affect + // "offsetof(struct s{int x[4];}, x[1.0])". This doesn't affect // compliance: we should warn earlier for offsetof expressions with // array subscripts that aren't ICEs, and if the array subscripts // are ICEs, the value of the offsetof must be an integer constant. @@ -3079,6 +3085,9 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { case BO_AndAssign: case BO_XorAssign: case BO_OrAssign: + // C99 6.6/3 allows assignments within unevaluated subexpressions of + // constant expressions, but they can never be ICEs because an ICE cannot + // contain an lvalue operand. return ICEDiag(2, E->getLocStart()); case BO_Mul: |

