<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jun 24, 2014 at 3:13 PM, Richard Trieu <span dir="ltr"><<a href="mailto:rtrieu@google.com" target="_blank">rtrieu@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">When a bit cast expression has pointer type, don't assume that the subexpression also has pointer type. It is possible that the subexpression is a value type instead. This patch checks the type of the subexpression and calls the proper function. Prevents the assertion failure reported in PR20110.<br>
<br>
<a href="http://llvm.org/bugs/show_bug.cgi?id=20110" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=20110</a><br>
<br>
<a href="http://reviews.llvm.org/D4280" target="_blank">http://reviews.llvm.org/D4280</a><br>
<br>
Files:<br>
lib/Sema/SemaChecking.cpp<br>
test/SemaCXX/PR20110.cpp<br>
<br>
Index: test/SemaCXX/PR20110.cpp<br>
===================================================================<br>
--- test/SemaCXX/PR20110.cpp<br>
+++ test/SemaCXX/PR20110.cpp<br>
@@ -0,0 +1,13 @@<br>
+// RUN: %clang_cc1 -fsyntax-only -verify %s<br>
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s<br>
+// expected-no-diagnostics<br>
+<br>
+template <char const *p><br>
+class A {<br>
+ char const *get_p() { return *p; }<br>
+};<br>
+template <int p><br>
+class B {<br>
+ char const *get_p() { return p; }<br>
+};<br></blockquote><div><br></div><div>In C++11 onwards, we should reject both of these in the template definition.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
Index: lib/Sema/SemaChecking.cpp<br>
===================================================================<br>
--- lib/Sema/SemaChecking.cpp<br>
+++ lib/Sema/SemaChecking.cpp<br>
@@ -4592,7 +4592,6 @@<br>
case Stmt::CXXReinterpretCastExprClass: {<br>
Expr* SubExpr = cast<CastExpr>(E)->getSubExpr();<br>
switch (cast<CastExpr>(E)->getCastKind()) {<br>
- case CK_BitCast:<br>
case CK_LValueToRValue:<br>
case CK_NoOp:<br>
case CK_BaseToDerived:<br>
@@ -4607,6 +4606,14 @@<br>
case CK_ArrayToPointerDecay:<br>
return EvalVal(SubExpr, refVars, ParentDecl);<br>
<br>
+ case CK_BitCast:<br>
+ if (SubExpr->getType()->isAnyPointerType() ||<br>
+ SubExpr->getType()->isBlockPointerType() ||<br>
+ SubExpr->getType()->isObjCQualifiedIdType())<br>
+ return EvalAddr(SubExpr, refVars, ParentDecl);<br>
+ else<br>
+ return EvalVal(SubExpr, refVars, ParentDecl);<br></blockquote><div><br></div><div>Should Eval* really be walking into value-dependent expressions?</div><div><br></div><div>I think the right thing to do here is to fail if you don't have a pointer (return nullptr), not to call EvalVal.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
default:<br>
return nullptr;<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>
<br></blockquote></div><br></div></div>