diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fbbd5c550569..225a42382187 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -1103,11 +1103,17 @@ public: case '7': return 7; case '8': return 8; case '9': return 9; + case 'A': case 'a': return 10; + case 'B': case 'b': return 11; + case 'C': case 'c': return 12; + case 'D': case 'd': return 13; + case 'E': case 'e': return 14; + case 'F': case 'f': return 15; } } diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 4a3ad2641ef4..fce88cc0da28 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -1496,7 +1496,7 @@ bool ExtVectorElementExpr::containsDuplicateElements() const { return false; // Advance past s-char prefix on hex swizzles. - if (*compStr == 's') { + if (*compStr == 's' || *compStr == 'S') { compStr++; length--; } @@ -1514,7 +1514,7 @@ bool ExtVectorElementExpr::containsDuplicateElements() const { void ExtVectorElementExpr::getEncodedElementAccess( llvm::SmallVectorImpl &Elts) const { const char *compStr = Accessor->getName(); - if (*compStr == 's') + if (*compStr == 's' || *compStr == 'S') compStr++; bool isHi = !strcmp(compStr, "hi"); diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 19fc090e3789..5b650680bedd 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1905,7 +1905,7 @@ CheckExtVectorComponent(QualType baseType, SourceLocation OpLoc, // This flag determines whether or not CompName has an 's' char prefix, // indicating that it is a string of hex values to be used as vector indices. - bool HexSwizzle = *compStr == 's'; + bool HexSwizzle = *compStr == 's' || *compStr == 'S'; // Check that we've found one of the special components, or that the component // names must come from the same set. diff --git a/clang/test/Sema/ext_vector_components.c b/clang/test/Sema/ext_vector_components.c index 422a9e6f2287..a5d270074ad0 100644 --- a/clang/test/Sema/ext_vector_components.c +++ b/clang/test/Sema/ext_vector_components.c @@ -3,11 +3,13 @@ typedef __attribute__(( ext_vector_type(2) )) float float2; typedef __attribute__(( ext_vector_type(3) )) float float3; typedef __attribute__(( ext_vector_type(4) )) float float4; +typedef __attribute__(( ext_vector_type(16) )) float float16; static void test() { float2 vec2, vec2_2; float3 vec3; float4 vec4, vec4_2, *vec4p; + float16 vec16; float f; vec2.z; // expected-error {{vector component access exceeds type 'float2'}} @@ -16,6 +18,7 @@ static void test() { vec4.xyzc; // expected-error {{illegal vector component name 'c'}} vec4.s01z; // expected-error {{illegal vector component name 'z'}} vec2 = vec4.s01; // legal, shorten + vec2 = vec4.S01; // legal, shorten vec3 = vec4.xyz; // legal, shorten f = vec2.x; // legal, shorten @@ -32,6 +35,8 @@ static void test() { vec4 = (float4){ 1,2,3,4 }; vec4.xy.w; // expected-error {{vector component access exceeds type 'float2'}} vec4.s06; // expected-error {{vector component access exceeds type 'float4'}} + vec4.x = vec16.sf; + vec4.x = vec16.sF; vec4p->yz = vec4p->xy; }