]> granicus.if.org Git - clang/commitdiff
[Sema] Fix assertion hit while trying to do constant evaluation for a dependent expre...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 15 Feb 2014 18:53:57 +0000 (18:53 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 15 Feb 2014 18:53:57 +0000 (18:53 +0000)
inside a GNU statement expression.

rdar://16064952

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201468 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ExprConstant.cpp
test/SemaCXX/constant-expression.cpp

index 9f79064fd77df0f1bd9e571f38386fbdff40c77a..b11e9e8a272567837057cd327b1afd5de8fc2f65 100644 (file)
@@ -8028,6 +8028,8 @@ static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E) {
 /// 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;
 
index 2b39de68906e3dda8ffffc62acff4ecec9bda674..e01acdd46f935a79b9df456445a530137e848c30 100644 (file)
@@ -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}}
+  }
+}