r205557 - vector [Sema]. Check for proper use of 's' char prefix

Fariborz Jahanian fjahanian at apple.com
Thu Apr 3 12:43:01 PDT 2014


Author: fjahanian
Date: Thu Apr  3 14:43:01 2014
New Revision: 205557

URL: http://llvm.org/viewvc/llvm-project?rev=205557&view=rev
Log:
vector [Sema]. Check for proper use of 's' char prefix
(which indicates vector expression is a string of hex
values) instead of crashing in code gen. // rdar://16492792

Modified:
    cfe/trunk/lib/Sema/SemaExprMember.cpp
    cfe/trunk/test/Sema/types.c

Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=205557&r1=205556&r2=205557&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp Thu Apr  3 14:43:01 2014
@@ -292,7 +292,7 @@ CheckExtVectorComponent(Sema &S, QualTyp
 
   // 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] = {};

Modified: cfe/trunk/test/Sema/types.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/types.c?rev=205557&r1=205556&r2=205557&view=diff
==============================================================================
--- cfe/trunk/test/Sema/types.c (original)
+++ cfe/trunk/test/Sema/types.c Thu Apr  3 14:43:01 2014
@@ -73,3 +73,11 @@ typedef int __attribute__ ((ext_vector_t
 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'}}
+}





More information about the cfe-commits mailing list