From 0f99537ecac400c5c6db0eafdc60ef871859d5f6 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Thu, 19 Jun 2014 14:45:16 +0000 Subject: [PATCH] Fix assertion hit or bogus compiler error in cases when instantiating ObjC property accesses used with overloaded binary operators. rdar://17153478 llvm-svn: 211270 --- clang/lib/Sema/TreeTransform.h | 18 +++++++++++ .../test/SemaObjCXX/instantiate-property-access.mm | 35 ++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 clang/test/SemaObjCXX/instantiate-property-access.mm diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 9330070..a1a564e 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/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/clang/test/SemaObjCXX/instantiate-property-access.mm b/clang/test/SemaObjCXX/instantiate-property-access.mm new file mode 100644 index 0000000..8d5c201 --- /dev/null +++ b/clang/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(); +} -- 2.7.4