]> granicus.if.org Git - clang/commitdiff
[Objective-C patch] Patch to fix a crash in IRGen because
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 6 Apr 2015 16:56:39 +0000 (16:56 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 6 Apr 2015 16:56:39 +0000 (16:56 +0000)
of incorrect AST when a compound literal of Objective-C
property access is used to initialize a vertor of floats.
rdar://20407999

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234176 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprMember.cpp
test/CodeGenObjC/compound-literal-property-access.m [new file with mode: 0644]

index b3efa70b43a132bf1d29f46bd879a4679a711eb8..212c5547151b096c84e4ec285e3f536174e636e7 100644 (file)
@@ -1519,7 +1519,15 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult &R,
   if (BaseType->isExtVectorType()) {
     // FIXME: this expr should store IsArrow.
     IdentifierInfo *Member = MemberName.getAsIdentifierInfo();
-    ExprValueKind VK = (IsArrow ? VK_LValue : BaseExpr.get()->getValueKind());
+    ExprValueKind VK;
+    if (IsArrow)
+      VK = VK_LValue;
+    else {
+      if (PseudoObjectExpr *POE = dyn_cast<PseudoObjectExpr>(BaseExpr.get()))
+        VK = POE->getSyntacticForm()->getValueKind();
+      else
+        VK = BaseExpr.get()->getValueKind();
+    }
     QualType ret = CheckExtVectorComponent(S, BaseType, VK, OpLoc,
                                            Member, MemberLoc);
     if (ret.isNull())
diff --git a/test/CodeGenObjC/compound-literal-property-access.m b/test/CodeGenObjC/compound-literal-property-access.m
new file mode 100644 (file)
index 0000000..bc1bd78
--- /dev/null
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-darwin -o - | FileCheck %s
+// rdar://20407999
+
+typedef __attribute__((__ext_vector_type__(2))) float vector_float2;
+
+@interface GPAgent2D
+@property (nonatomic, assign) vector_float2 position;
+@end
+
+@interface GPGoal @end
+
+@implementation GPGoal
+-(void)getForce {
+    GPAgent2D* targetAgent;
+    (vector_float2){targetAgent.position.x, targetAgent.position.y};
+}
+@end
+
+// CHECK: [[CL:%.*]] = alloca <2 x float>, align 8
+// CHECK: store <2 x float> [[VECINIT:%.*]], <2 x float>* [[CL]]
+// CHECK: [[FOURTEEN:%.*]] = load <2 x float>, <2 x float>* [[CL]]