case CompoundLiteralExprClass:
if (Loc) *Loc = getLocStart();
// Allow "(int []){2,4}", since the array will be converted to a pointer.
- return TR->isArrayType();
+ // Allow "(vector type){2,4}" since the elements are all constant.
+ return TR->isArrayType() || TR->isVectorType();
case UnaryOperatorClass: {
const UnaryOperator *Exp = cast<UnaryOperator>(this);
return 0;
}
- assert((ILE->getType()->isArrayType() || ILE->getType()->isStructureType()) &&
+ assert((ILE->getType()->isArrayType() || ILE->getType()->isStructureType() ||
+ ILE->getType()->isVectorType()) &&
"Bad type for init list!");
CodeGenTypes& Types = CGM.getTypes();
if (ILE->getType()->isStructureType())
return llvm::ConstantStruct::get(cast<llvm::StructType>(CType), Elts);
+ if (ILE->getType()->isVectorType())
+ return llvm::ConstantVector::get(cast<llvm::VectorType>(CType), Elts);
+
// Make sure we have an array at this point
assert(AType);
return llvm::ConstantArray::get(Str, false);
}
+ // Generate initializer for the CompoundLiteral
+ case Stmt::CompoundLiteralExprClass: {
+ const CompoundLiteralExpr *CLE = cast<CompoundLiteralExpr>(Expression);
+ return GenerateConstantExpr(CLE->getInitializer(), CGM);
+ }
+
// Elide parenthesis.
case Stmt::ParenExprClass:
return GenerateConstantExpr(cast<ParenExpr>(Expression)->getSubExpr(), CGM);
typedef __attribute__(( ocu_vector_type(4) )) float float4;
typedef __attribute__(( ocu_vector_type(2) )) float float2;
+float4 foo = (float4){ 1.0, 2.0, 3.0, 4.0 };
float4 test1(float4 V) {
return V.wzyx+V;
--- /dev/null
+// RUN: clang %s -verify -fsyntax-only
+
+typedef __attribute__(( ocu_vector_type(4) )) float float4;
+
+float4 foo = (float4){ 1.0, 2.0, 3.0, 4.0 };