Fix assertion hit or bogus compiler error in cases when instantiating ObjC property...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 19 Jun 2014 14:45:16 +0000 (14:45 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 19 Jun 2014 14:45:16 +0000 (14:45 +0000)
rdar://17153478

llvm-svn: 211270

clang/lib/Sema/TreeTransform.h
clang/test/SemaObjCXX/instantiate-property-access.mm [new file with mode: 0644]

index 9330070..a1a564e 100644 (file)
@@ -9911,6 +9911,24 @@ TreeTransform<Derived>::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 (file)
index 0000000..8d5c201
--- /dev/null
@@ -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 <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>();
+}