r292497 - [Sema] Fix PR28181 by avoiding calling BuildOverloadedBinOp in C mode
Alex L via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 19 09:34:03 PST 2017
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/SemaE
> xpr.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/PR28
> 181.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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170119/7398076e/attachment-0001.html>
More information about the cfe-commits
mailing list