[cfe-commits] r143363 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/Sema/const-eval.c
Richard Smith
richard-llvm at metafoo.co.uk
Mon Oct 31 13:57:44 PDT 2011
Author: rsmith
Date: Mon Oct 31 15:57:44 2011
New Revision: 143363
URL: http://llvm.org/viewvc/llvm-project?rev=143363&view=rev
Log:
Refactoring and test for r143360. Support for array rvalue to pointer decay is
needed for C++11, and will follow later.
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/Sema/const-eval.c
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=143363&r1=143362&r2=143363&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Oct 31 15:57:44 2011
@@ -1222,10 +1222,13 @@
}
}
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);
Modified: cfe/trunk/test/Sema/const-eval.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/const-eval.c?rev=143363&r1=143362&r2=143363&view=diff
==============================================================================
--- cfe/trunk/test/Sema/const-eval.c (original)
+++ cfe/trunk/test/Sema/const-eval.c Mon Oct 31 15:57:44 2011
@@ -92,3 +92,6 @@
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}}
More information about the cfe-commits
mailing list