CXXBindTemporaryExpr *CXXBindTemporaryExpr::Create(ASTContext &C,
CXXTemporary *Temp,
Expr* SubExpr) {
- assert(SubExpr->getType()->isRecordType() &&
- "Expression bound to a temporary must have record type!");
+ assert((SubExpr->getType()->isRecordType() ||
+ SubExpr->getType()->isArrayType()) &&
+ "Expression bound to a temporary must have record or array type!");
return new (C) CXXBindTemporaryExpr(Temp, SubExpr);
}
if (!getLangOptions().CPlusPlus)
return Owned(E);
- const RecordType *RT = E->getType()->getAs<RecordType>();
+ QualType ET = Context.getBaseElementType(E->getType());
+ const RecordType *RT = ET->getAs<RecordType>();
if (!RT)
return Owned(E);
b ? A(2) : A(3);
}
}
+
+namespace PR11365 {
+ struct A { A(); ~A(); };
+
+ // CHECK: define void @_ZN7PR113653fooEv(
+ void foo() {
+ // CHECK: [[BEGIN:%.*]] = getelementptr inbounds [3 x [[A:%.*]]]* {{.*}}, i32 0, i32 0
+ // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds [[A]]* [[BEGIN]], i64 3
+ // CHECK-NEXT: br label
+
+ // CHECK: [[PHI:%.*]] = phi
+ // CHECK-NEXT: [[ELEM:%.*]] = getelementptr inbounds [[A]]* [[PHI]], i64 -1
+ // CHECK-NEXT: call void @_ZN7PR113651AD1Ev([[A]]* [[ELEM]])
+ // CHECK-NEXT: icmp eq [[A]]* [[ELEM]], [[BEGIN]]
+ // CHECK-NEXT: br i1
+ (void) (A [3]) {};
+ }
+}