r201468 - [Sema] Fix assertion hit while trying to do constant evaluation for a dependent expression
Argyrios Kyrtzidis
akyrtzi at gmail.com
Sat Feb 15 10:53:57 PST 2014
Author: akirtzidis
Date: Sat Feb 15 12:53:57 2014
New Revision: 201468
URL: http://llvm.org/viewvc/llvm-project?rev=201468&view=rev
Log:
[Sema] Fix assertion hit while trying to do constant evaluation for a dependent expression
inside a GNU statement expression.
rdar://16064952
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/constant-expression.cpp
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=201468&r1=201467&r2=201468&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Sat Feb 15 12:53:57 2014
@@ -8028,6 +8028,8 @@ static bool Evaluate(APValue &Result, Ev
/// an object can indirectly refer to subobjects which were initialized earlier.
static bool EvaluateInPlace(APValue &Result, EvalInfo &Info, const LValue &This,
const Expr *E, bool AllowNonLiteralTypes) {
+ if (E->isTypeDependent() || E->isValueDependent())
+ return false;
if (!AllowNonLiteralTypes && !CheckLiteralType(Info, E, &This))
return false;
Modified: cfe/trunk/test/SemaCXX/constant-expression.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression.cpp?rev=201468&r1=201467&r2=201468&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/constant-expression.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression.cpp Sat Feb 15 12:53:57 2014
@@ -133,3 +133,11 @@ namespace test4 {
// equivalent to "const int x = 42;" as per C++03 8.5/p13.
typedef A<i> Ai; // ok
}
+
+// rdar://16064952
+namespace rdar16064952 {
+ template < typename T > void fn1() {
+ T b;
+ unsigned w = ({int a = b.val[sizeof(0)]; 0; }); // expected-warning {{use of GNU statement expression extension}}
+ }
+}
More information about the cfe-commits
mailing list