From: Argyrios Kyrtzidis Date: Thu, 19 Jun 2014 14:45:16 +0000 (+0000) Subject: Fix assertion hit or bogus compiler error in cases when instantiating ObjC property... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fe7694fab6a94720b814689a70d2aaf2e9f4aa0c;p=clang Fix assertion hit or bogus compiler error in cases when instantiating ObjC property accesses used with overloaded binary operators. rdar://17153478 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211270 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 9330070bf6..a1a564e2f2 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -9911,6 +9911,24 @@ TreeTransform::RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, Expr *Callee = OrigCallee->IgnoreParenCasts(); bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus); + if (First->getObjectKind() == OK_ObjCProperty) { + BinaryOperatorKind Opc = BinaryOperator::getOverloadedOpcode(Op); + if (BinaryOperator::isAssignmentOp(Opc)) + return SemaRef.checkPseudoObjectAssignment(/*Scope=*/nullptr, OpLoc, Opc, + First, Second); + ExprResult Result = SemaRef.CheckPlaceholderExpr(First); + if (Result.isInvalid()) + return ExprError(); + First = Result.get(); + } + + if (Second && Second->getObjectKind() == OK_ObjCProperty) { + ExprResult Result = SemaRef.CheckPlaceholderExpr(Second); + if (Result.isInvalid()) + return ExprError(); + Second = Result.get(); + } + // Determine whether this should be a builtin operation. if (Op == OO_Subscript) { if (!First->getType()->isOverloadableType() && diff --git a/test/SemaObjCXX/instantiate-property-access.mm b/test/SemaObjCXX/instantiate-property-access.mm new file mode 100644 index 0000000000..8d5c201a80 --- /dev/null +++ b/test/SemaObjCXX/instantiate-property-access.mm @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// expected-no-diagnostics + +class C {}; +bool operator == (C c1, C c2); + +bool operator == (C c1, int i); +bool operator == (int i, C c2); + +C operator += (C c1, C c2); + +enum TextureType { TextureType3D }; + +@interface Texture +@property int textureType; +@property C c; +@end + +template class Framebuffer { +public: + Texture **color_attachment; + Framebuffer(); +}; + +template Framebuffer::Framebuffer() { + (void)(color_attachment[0].textureType == TextureType3D); + color_attachment[0].textureType += 1; + (void)(color_attachment[0].c == color_attachment[0].c); + (void)(color_attachment[0].c == 1); + (void)(1 == color_attachment[0].c); +} + +void foo() { + Framebuffer(); +}