} else if (const VectorType *VTy = LHSTy->getAsVectorType()) {
BaseExpr = LHSExp; // vectors: V[123]
IndexExpr = RHSExp;
+
+ // Component access limited to variables (reject vec4.rg[1]).
+ if (!isa<DeclRefExpr>(BaseExpr))
+ return Diag(LLoc, diag::err_ocuvector_component_access,
+ SourceRange(LLoc, RLoc));
// FIXME: need to deal with const...
ResultType = VTy->getElementType();
} else {
SourceRange(MemberLoc));
return new MemberExpr(BaseExpr, OpKind==tok::arrow, MemberDecl, MemberLoc);
} else if (BaseType->isOCUVectorType() && OpKind == tok::period) {
+ // Component access limited to variables (reject vec4.rg.g).
+ if (!isa<DeclRefExpr>(BaseExpr))
+ return Diag(OpLoc, diag::err_ocuvector_component_access,
+ SourceRange(MemberLoc));
QualType ret = CheckOCUVectorComponent(BaseType, OpLoc, Member, MemberLoc);
if (ret.isNull())
return true;
"vector component access exceeds type '%0'")
DIAG(err_ocuvector_component_name_illegal, ERROR,
"illegal vector component name '%0'")
+DIAG(err_ocuvector_component_access, ERROR,
+ "vector component access limited to variables")
// Function Parameter Semantic Analysis.
DIAG(err_param_with_void_type, ERROR,
vec2.xx = vec2_2.xy; // expected-error {{vector is not assignable (contains duplicate components)}}
vec2.yx = vec2_2.xy;
vec4 = (float4){ 1,2,3,4 };
+ vec4.rg.g; // expected-error {{vector component access limited to variables}}
+ vec4.rg[1]; // expected-error {{vector component access limited to variables}}
}