r211270 - Fix assertion hit or bogus compiler error in cases when instantiating ObjC property accesses used with overloaded binary operators.
Argyrios Kyrtzidis
akyrtzi at gmail.com
Thu Jun 19 07:45:17 PDT 2014
Author: akirtzidis
Date: Thu Jun 19 09:45:16 2014
New Revision: 211270
URL: http://llvm.org/viewvc/llvm-project?rev=211270&view=rev
Log:
Fix assertion hit or bogus compiler error in cases when instantiating ObjC property accesses used with overloaded binary operators.
rdar://17153478
Added:
cfe/trunk/test/SemaObjCXX/instantiate-property-access.mm
Modified:
cfe/trunk/lib/Sema/TreeTransform.h
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=211270&r1=211269&r2=211270&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Thu Jun 19 09:45:16 2014
@@ -9911,6 +9911,24 @@ TreeTransform<Derived>::RebuildCXXOperat
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() &&
Added: cfe/trunk/test/SemaObjCXX/instantiate-property-access.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/instantiate-property-access.mm?rev=211270&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjCXX/instantiate-property-access.mm (added)
+++ cfe/trunk/test/SemaObjCXX/instantiate-property-access.mm Thu Jun 19 09:45:16 2014
@@ -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 };
+
+ at interface Texture
+ at property int textureType;
+ at property C c;
+ at end
+
+template <typename> class Framebuffer {
+public:
+ Texture **color_attachment;
+ Framebuffer();
+};
+
+template <typename T> Framebuffer<T>::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<int>();
+}
More information about the cfe-commits
mailing list