<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Feb 15, 2014 at 10:53 AM, Argyrios Kyrtzidis <span dir="ltr"><<a href="mailto:akyrtzi@gmail.com" target="_blank">akyrtzi@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: akirtzidis<br>
Date: Sat Feb 15 12:53:57 2014<br>
New Revision: 201468<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=201468&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=201468&view=rev</a><br>
Log:<br>
[Sema] Fix assertion hit while trying to do constant evaluation for a dependent expression<br>
inside a GNU statement expression.<br>
<br>
rdar://16064952<br>
<br>
Modified:<br>
cfe/trunk/lib/AST/ExprConstant.cpp<br>
cfe/trunk/test/SemaCXX/constant-expression.cpp<br>
<br>
Modified: cfe/trunk/lib/AST/ExprConstant.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=201468&r1=201467&r2=201468&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=201468&r1=201467&r2=201468&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)<br>
+++ cfe/trunk/lib/AST/ExprConstant.cpp Sat Feb 15 12:53:57 2014<br>
@@ -8028,6 +8028,8 @@ static bool Evaluate(APValue &Result, Ev<br>
/// an object can indirectly refer to subobjects which were initialized earlier.<br>
static bool EvaluateInPlace(APValue &Result, EvalInfo &Info, const LValue &This,<br>
const Expr *E, bool AllowNonLiteralTypes) {<br>
+ if (E->isTypeDependent() || E->isValueDependent())<br>
+ return false;<br></blockquote><div><br></div><div>It's the responsibility of the caller of the evaluator to check that the expression isn't value-dependent, not of the evaluator itself (the answer in such a case isn't that the expression is non-constant, it's that the question isn't meaningful). This should be an assert, and the check should be elsewhere. (Also, checking isValueDependent should be sufficient.)</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
if (!AllowNonLiteralTypes && !CheckLiteralType(Info, E, &This))<br>
return false;<br>
<br>
<br>
Modified: cfe/trunk/test/SemaCXX/constant-expression.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression.cpp?rev=201468&r1=201467&r2=201468&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression.cpp?rev=201468&r1=201467&r2=201468&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/constant-expression.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/constant-expression.cpp Sat Feb 15 12:53:57 2014<br>
@@ -133,3 +133,11 @@ namespace test4 {<br>
// equivalent to "const int x = 42;" as per C++03 8.5/p13.<br>
typedef A<i> Ai; // ok<br>
}<br>
+<br>
+// rdar://16064952<br>
+namespace rdar16064952 {<br>
+ template < typename T > void fn1() {<br>
+ T b;<br>
+ unsigned w = ({int a = b.val[sizeof(0)]; 0; }); // expected-warning {{use of GNU statement expression extension}}<br>
+ }<br>
+}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>