r292497 - [Sema] Fix PR28181 by avoiding calling BuildOverloadedBinOp in C mode

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 23 10:11:45 PST 2017


On Thu, Jan 19, 2017 at 6:25 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> On 19 January 2017 at 15:52, Hans Wennborg <hans at chromium.org> wrote:
>>
>> Richard, what do you think?
>
>
> Yes, let's merge this.

r292808.

Cheers,
Hans

>> On Thu, Jan 19, 2017 at 9:34 AM, Alex L <arphaman at gmail.com> wrote:
>> > Hi Hans,
>> >
>> > Would it be possible to merge this for 4.0?
>> >
>> > Cheers,
>> > Alex
>> >
>> > On 19 January 2017 at 17:17, Alex Lorenz via cfe-commits
>> > <cfe-commits at lists.llvm.org> wrote:
>> >>
>> >> Author: arphaman
>> >> Date: Thu Jan 19 11:17:57 2017
>> >> New Revision: 292497
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=292497&view=rev
>> >> Log:
>> >> [Sema] Fix PR28181 by avoiding calling BuildOverloadedBinOp in C mode
>> >>
>> >> rdar://28532840
>> >>
>> >> Differential Revision: https://reviews.llvm.org/D25213
>> >>
>> >> Added:
>> >>     cfe/trunk/test/Sema/PR28181.c
>> >> Modified:
>> >>     cfe/trunk/lib/Sema/SemaExpr.cpp
>> >>
>> >> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
>> >> URL:
>> >>
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=292497&r1=292496&r2=292497&view=diff
>> >>
>> >>
>> >> ==============================================================================
>> >> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
>> >> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Jan 19 11:17:57 2017
>> >> @@ -11505,7 +11505,7 @@ ExprResult Sema::BuildBinOp(Scope *S, So
>> >>        return checkPseudoObjectAssignment(S, OpLoc, Opc, LHSExpr,
>> >> RHSExpr);
>> >>
>> >>      // Don't resolve overloads if the other type is overloadable.
>> >> -    if (pty->getKind() == BuiltinType::Overload) {
>> >> +    if (getLangOpts().CPlusPlus && pty->getKind() ==
>> >> BuiltinType::Overload) {
>> >>        // We can't actually test that if we still have a placeholder,
>> >>        // though.  Fortunately, none of the exceptions we see in that
>> >>        // code below are valid when the LHS is an overload set.  Note
>> >> @@ -11530,17 +11530,16 @@ ExprResult Sema::BuildBinOp(Scope *S, So
>> >>      // An overload in the RHS can potentially be resolved by the type
>> >>      // being assigned to.
>> >>      if (Opc == BO_Assign && pty->getKind() == BuiltinType::Overload) {
>> >> -      if (LHSExpr->isTypeDependent() || RHSExpr->isTypeDependent())
>> >> -        return BuildOverloadedBinOp(*this, S, OpLoc, Opc, LHSExpr,
>> >> RHSExpr);
>> >> -
>> >> -      if (LHSExpr->getType()->isOverloadableType())
>> >> +      if (getLangOpts().CPlusPlus &&
>> >> +          (LHSExpr->isTypeDependent() || RHSExpr->isTypeDependent() ||
>> >> +           LHSExpr->getType()->isOverloadableType()))
>> >>          return BuildOverloadedBinOp(*this, S, OpLoc, Opc, LHSExpr,
>> >> RHSExpr);
>> >>
>> >>        return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
>> >>      }
>> >>
>> >>      // Don't resolve overloads if the other type is overloadable.
>> >> -    if (pty->getKind() == BuiltinType::Overload &&
>> >> +    if (getLangOpts().CPlusPlus && pty->getKind() ==
>> >> BuiltinType::Overload &&
>> >>          LHSExpr->getType()->isOverloadableType())
>> >>        return BuildOverloadedBinOp(*this, S, OpLoc, Opc, LHSExpr,
>> >> RHSExpr);
>> >>
>> >>
>> >> Added: cfe/trunk/test/Sema/PR28181.c
>> >> URL:
>> >>
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/PR28181.c?rev=292497&view=auto
>> >>
>> >>
>> >> ==============================================================================
>> >> --- cfe/trunk/test/Sema/PR28181.c (added)
>> >> +++ cfe/trunk/test/Sema/PR28181.c Thu Jan 19 11:17:57 2017
>> >> @@ -0,0 +1,13 @@
>> >> +// RUN: %clang_cc1 -fsyntax-only -verify %s
>> >> +
>> >> +struct spinlock_t {
>> >> +  int lock;
>> >> +} audit_skb_queue;
>> >> +
>> >> +void fn1() {
>> >> +  audit_skb_queue = (lock); // expected-error {{use of undeclared
>> >> identifier 'lock'; did you mean 'long'?}}
>> >> +}                           // expected-error at -1 {{assigning to
>> >> 'struct
>> >> spinlock_t' from incompatible type '<overloaded function type>'}}
>> >> +
>> >> +void fn2() {
>> >> +  audit_skb_queue + (lock); // expected-error {{use of undeclared
>> >> identifier 'lock'; did you mean 'long'?}}
>> >> +}                           // expected-error at -1 {{reference to
>> >> overloaded function could not be resolved; did you mean to call it?}}
>> >>
>> >>
>> >> _______________________________________________
>> >> cfe-commits mailing list
>> >> cfe-commits at lists.llvm.org
>> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>> >
>> >
>
>


More information about the cfe-commits mailing list