<div dir="ltr"><div>+    const QualType SubExprType = ThrowExpr->getSubExpr()->getType();</div><div><br></div><div>This is the wrong type; we want the type of the surrounding conditional operator here, not the type of the exception.</div>
<div><br></div><div>I've committed a fix based on your patch in r<span style="color:rgb(0,0,0)">211388. Thanks!</span></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jun 16, 2014 at 9:37 AM, Marius Wachtler <span dir="ltr"><<a href="mailto:undingen@gmail.com" target="_blank">undingen@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">Gentle</span><span style="font-family:arial,sans-serif;font-size:13px"> </span><span style="font-family:arial,sans-serif;font-size:13px">ping..</span><div>

<span style="font-family:arial,sans-serif;font-size:13px">I updated the patch to target latest the svn revision and added an regexpr to check that "val" is really returned.</span><div>Thank you</div><div><br></div>

</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jun 11, 2014 at 11:18 PM, Marius Wachtler <span dir="ltr"><<a href="mailto:undingen@gmail.com" target="_blank">undingen@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Sorry for all the spam...<div>I attached the wrong patch file.</div><div> </div></div><div>
<div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jun 11, 2014 at 11:16 PM, Marius Wachtler <span dir="ltr"><<a href="mailto:undingen@gmail.com" target="_blank">undingen@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks for your expertise.<div>Attached you can find an updated patch where I removed the const and made the FileCheck a little bit more specific.</div>


<div><div><br></div></div></div><div><div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Wed, Jun 11, 2014 at 10:55 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>On Wed, Jun 11, 2014 at 1:25 PM, Marius Wachtler <span dir="ltr"><<a href="mailto:undingen@gmail.com" target="_blank">undingen@gmail.com</a>></span> wrote:<br>




</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi<div><br></div><div><div>
I added a testcase for the function you mention but I also added const to the return type because otherwise gcc won't compile it ("error: invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘int’") - clang compiles both.</div>




</div></div></blockquote><div><br></div><div>GCC doesn't implement one of the relevant DRs; you don't need to make the testcase work with it.</div><div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">




<div dir="ltr"><div>The generated code from clang for the function looks correct and works as I would expect it.</div><div>Compiling it with g++ 4.8.2 and -O2 will instead produce and object which will return an address to a temporary in the function and not a reference to the global val.</div>





<div><br></div><div>I'm not sure if clangs behavior is correct or if it should also only accept a const reference? If the error is somewhere else I would appreciate some guidance to where to look around and what the expected behavior is.</div>




</div></blockquote><div><br></div></div><div>See <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1550" target="_blank">http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1550</a>; Clang's behavior is right, this is just a bug with IR generation.</div>



<div><div>
<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">
<div>The C++11 non final standard I have says (5.16-2):</div><div>"If either the second or the third operand has type (possibly cv-qualified) void, then the lvalue-to-rvalue (4.1), array-to-pointer (4.2), and function-to-pointer (4.3) standard conversions are performed on the second and third operands, and one of the following shall hold:<div>





— The second or the third operand (but not both) is a throw-expression (15.1); the result is of the type</div><div>of the other and is a prvalue.</div><div>— Both the second and the third operands have type void; the result is of type void and is a prvalue. [ Note: This includes the case where both operands are throw-expressions. — end note ]</div>





"</div><div>So this means gcc is correct?</div><div><br></div><div>Thank you very much</div><span><font color="#888888"><div>- Marius</div><div><br></div><div> </div><div><br></div></font></span></div><div>
<div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Wed, Jun 11, 2014 at 1:05 AM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">





<div dir="ltr"><div class="gmail_extra">Please also include a test that the produced lvalue actually has the right value. Something like:</div><div class="gmail_extra"><br></div><div class="gmail_extra">int &test7(bool cond) {</div>






<div class="gmail_extra">  return cond ? throw 1 : val;</div><div class="gmail_extra">}</div><div class="gmail_extra"><br></div><div class="gmail_extra">... and check that the value returned is @_Z3val</div><div><div>
<div class="gmail_extra">
<br><div class="gmail_quote">On Tue, Jun 10, 2014 at 3:01 PM, Marius Wachtler <span dir="ltr"><<a href="mailto:undingen@gmail.com" target="_blank">undingen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">






<div dir="ltr">Hi<div>Attached you can find an updates patch.</div><div><br></div><div><br></div></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jun 10, 2014 at 11:50 PM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br>







<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">







+<br>+  case Expr::CXXThrowExprClass: {<br>+    const auto* throwExpr = cast<CXXThrowExpr>(E);<br>

</blockquote><div><br></div><div>Please stick the star on the RHS. Also, it is customary in LLVM and clang to spell it like "ThrowExpr"</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">








+    EmitCXXThrowExpr(throwExpr);<br>
+    const QualType subExprType = throwExpr->getSubExpr()->getType();<br></blockquote><div><br></div><div>Likewise for "subExprType"</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">








+    llvm::Type *Ty = llvm::PointerType::getUnqual(ConvertType(subExprType));<br>+    return MakeAddrLValue(llvm::UndefValue::get(Ty), subExprType);<br>
   }</blockquote></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div>On Tue, Jun 10, 2014 at 5:19 PM, Marius Wachtler <span dir="ltr"><<a href="mailto:undingen@gmail.com" target="_blank">undingen@gmail.com</a>></span> wrote:<br>








</div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><div dir="ltr">Hello<div><br></div>




<div>Attached you can find my first clang patch which should implement </div>


<div>"cond ? throw 1 : val".</div>
<div><br></div><div>Without this patch I get: "cannot compile this l-value expression yet"</div>
<div><br></div><div>As this is my first time looking under the hood of clang I'm not sure if this is the right approach. I'm Looking forward to your feedback.</div><span><font color="#888888"><div>
<br></div><div>- Marius Wachtler</div></font></span></div>
<br></div></div>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">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>
</blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">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></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>