]> granicus.if.org Git - clang/commitdiff
vector [Sema]. Check for proper use of 's' char prefix
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 3 Apr 2014 19:43:01 +0000 (19:43 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 3 Apr 2014 19:43:01 +0000 (19:43 +0000)
(which indicates vector expression is a string of hex
values) instead of crashing in code gen. // rdar://16492792

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

lib/Sema/SemaExprMember.cpp
test/Sema/types.c

index 354dfcf389622ac49ab5ec47b45663c9e3afbb5d..675c69fa88f5678fc220e5e095684d07e42c4c7a 100644 (file)
@@ -292,7 +292,7 @@ CheckExtVectorComponent(Sema &S, QualType baseType, ExprValueKind &VK,
 
   // 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' || *compStr == 'S';
+  bool HexSwizzle = (*compStr == 's' || *compStr == 'S') && compStr[1];
 
   bool HasRepeated = false;
   bool HasIndex[16] = {};
index 339788eb9dfc5695c72dd8d392cc97b7c4a844f3..778a5fe9f7ca02b2ee241be63a1e50391282bffb 100644 (file)
@@ -73,3 +73,11 @@ typedef int __attribute__ ((ext_vector_type(8192))) x2; // expected-error {{vect
 enum { e_2 } x3 __attribute__((vector_size(64))); // expected-error {{invalid vector element type}}
 
 int x4 __attribute__((ext_vector_type(64)));  // expected-error {{'ext_vector_type' attribute only applies to types}}
+
+// rdar://16492792
+typedef __attribute__ ((ext_vector_type(32),__aligned__(32))) unsigned char uchar32;
+
+void convert() {
+    uchar32 r = 0;
+    r.s[ 1234 ] = 1; // expected-error {{illegal vector component name 's'}}
+}