<div dir="ltr">Hi Hans,<div><div style="font-size:12.800000190734863px"><br></div><div style="font-size:12.800000190734863px">Would it be possible to merge this for 4.0?</div></div><div style="font-size:12.800000190734863px"><br></div><div style="font-size:12.800000190734863px">Cheers,</div><div style="font-size:12.800000190734863px">Alex</div><div class="gmail_extra"><br><div class="gmail_quote">On 19 January 2017 at 17:17, Alex Lorenz via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: arphaman<br>
Date: Thu Jan 19 11:17:57 2017<br>
New Revision: 292497<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=292497&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=292497&view=rev</a><br>
Log:<br>
[Sema] Fix PR28181 by avoiding calling BuildOverloadedBinOp in C mode<br>
<br>
rdar://28532840<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D25213" rel="noreferrer" target="_blank">https://reviews.llvm.org/D2521<wbr>3</a><br>
<br>
Added:<br>
    cfe/trunk/test/Sema/PR28181.c<br>
Modified:<br>
    cfe/trunk/lib/Sema/SemaExpr.cp<wbr>p<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaExpr.cp<wbr>p<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=292497&r1=292496&r2=292497&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Sema/SemaE<wbr>xpr.cpp?rev=292497&r1=292496&<wbr>r2=292497&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Sema/SemaExpr.cp<wbr>p (original)<br>
+++ cfe/trunk/lib/Sema/SemaExpr.cp<wbr>p Thu Jan 19 11:17:57 2017<br>
@@ -11505,7 +11505,7 @@ ExprResult Sema::BuildBinOp(Scope *S, So<br>
       return checkPseudoObjectAssignment(S, OpLoc, Opc, LHSExpr, RHSExpr);<br>
<br>
     // Don't resolve overloads if the other type is overloadable.<br>
-    if (pty->getKind() == BuiltinType::Overload) {<br>
+    if (getLangOpts().CPlusPlus && pty->getKind() == BuiltinType::Overload) {<br>
       // We can't actually test that if we still have a placeholder,<br>
       // though.  Fortunately, none of the exceptions we see in that<br>
       // code below are valid when the LHS is an overload set.  Note<br>
@@ -11530,17 +11530,16 @@ ExprResult Sema::BuildBinOp(Scope *S, So<br>
     // An overload in the RHS can potentially be resolved by the type<br>
     // being assigned to.<br>
     if (Opc == BO_Assign && pty->getKind() == BuiltinType::Overload) {<br>
-      if (LHSExpr->isTypeDependent() || RHSExpr->isTypeDependent())<br>
-        return BuildOverloadedBinOp(*this, S, OpLoc, Opc, LHSExpr, RHSExpr);<br>
-<br>
-      if (LHSExpr->getType()->isOverloa<wbr>dableType())<br>
+      if (getLangOpts().CPlusPlus &&<br>
+          (LHSExpr->isTypeDependent() || RHSExpr->isTypeDependent() ||<br>
+           LHSExpr->getType()->isOverloa<wbr>dableType()))<br>
         return BuildOverloadedBinOp(*this, S, OpLoc, Opc, LHSExpr, RHSExpr);<br>
<br>
       return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);<br>
     }<br>
<br>
     // Don't resolve overloads if the other type is overloadable.<br>
-    if (pty->getKind() == BuiltinType::Overload &&<br>
+    if (getLangOpts().CPlusPlus && pty->getKind() == BuiltinType::Overload &&<br>
         LHSExpr->getType()->isOverloa<wbr>dableType())<br>
       return BuildOverloadedBinOp(*this, S, OpLoc, Opc, LHSExpr, RHSExpr);<br>
<br>
<br>
Added: cfe/trunk/test/Sema/PR28181.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/PR28181.c?rev=292497&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/Sema/PR28<wbr>181.c?rev=292497&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/Sema/PR28181.c (added)<br>
+++ cfe/trunk/test/Sema/PR28181.c Thu Jan 19 11:17:57 2017<br>
@@ -0,0 +1,13 @@<br>
+// RUN: %clang_cc1 -fsyntax-only -verify %s<br>
+<br>
+struct spinlock_t {<br>
+  int lock;<br>
+} audit_skb_queue;<br>
+<br>
+void fn1() {<br>
+  audit_skb_queue = (lock); // expected-error {{use of undeclared identifier 'lock'; did you mean 'long'?}}<br>
+}                           // expected-error@-1 {{assigning to 'struct spinlock_t' from incompatible type '<overloaded function type>'}}<br>
+<br>
+void fn2() {<br>
+  audit_skb_queue + (lock); // expected-error {{use of undeclared identifier 'lock'; did you mean 'long'?}}<br>
+}                           // expected-error@-1 {{reference to overloaded function could not be resolved; did you mean to call it?}}<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>