diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-31 20:57:44 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-31 20:57:44 +0000 |
| commit | dd78544d4474154fa8ee097aed3d6c5b2dff72f5 (patch) | |
| tree | 348f84a4812c8babf47713f85a3fccafc7d5e15e | |
| parent | 4f8e86979a7ffe0e02c2c9afacdc75c83f52ee88 (diff) | |
| download | bcm5719-llvm-dd78544d4474154fa8ee097aed3d6c5b2dff72f5.tar.gz bcm5719-llvm-dd78544d4474154fa8ee097aed3d6c5b2dff72f5.zip | |
Refactoring and test for r143360. Support for array rvalue to pointer decay is
needed for C++11, and will follow later.
llvm-svn: 143363
| -rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 9 | ||||
| -rw-r--r-- | clang/test/Sema/const-eval.c | 3 |
2 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index a12beb51792..b34b59d9079 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -1222,10 +1222,13 @@ bool PointerExprEvaluator::VisitCastExpr(const CastExpr* E) { } } case CK_ArrayToPointerDecay: + // FIXME: Support array-to-pointer decay on array rvalues. + if (!SubExpr->isGLValue()) + return Error(E); + return EvaluateLValue(SubExpr, Result, Info); + case CK_FunctionToPointerDecay: - if (SubExpr->isGLValue() || SubExpr->getType()->isFunctionType()) - return EvaluateLValue(SubExpr, Result, Info); - return Error(E); + return EvaluateLValue(SubExpr, Result, Info); } return ExprEvaluatorBaseTy::VisitCastExpr(E); diff --git a/clang/test/Sema/const-eval.c b/clang/test/Sema/const-eval.c index 8cfa7ea6f87..df56b06e48c 100644 --- a/clang/test/Sema/const-eval.c +++ b/clang/test/Sema/const-eval.c @@ -92,3 +92,6 @@ double d2 = ++d; // expected-error {{not a compile-time constant}} int n = 2; int intLvalue[*(int*)((long)&n ?: 1)] = { 1, 2 }; // expected-error {{variable length array}} + +union u { int a; char b[4]; }; +char c = ((union u)(123456)).b[0]; // expected-error {{not a compile-time constant}} |

