From a0cc3f6d49c7b301a486e0fa43d5458ba8e9013e Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Sat, 15 Feb 2014 18:53:57 +0000 Subject: [PATCH] [Sema] Fix assertion hit while trying to do constant evaluation for a dependent expression 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 | 2 ++ test/SemaCXX/constant-expression.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 9f79064fd7..b11e9e8a27 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -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; diff --git a/test/SemaCXX/constant-expression.cpp b/test/SemaCXX/constant-expression.cpp index 2b39de6890..e01acdd46f 100644 --- a/test/SemaCXX/constant-expression.cpp +++ b/test/SemaCXX/constant-expression.cpp @@ -133,3 +133,11 @@ namespace test4 { // equivalent to "const int x = 42;" as per C++03 8.5/p13. typedef A 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}} + } +} -- 2.40.0