diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2014-04-03 19:43:01 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2014-04-03 19:43:01 +0000 |
commit | 275542a40e38a321d2926b44659b926016446501 (patch) | |
tree | 0c3d2fbb9f9e69a861bccd28a352225625c890af | |
parent | 72cebdec2e203949fd57ef1376905e0980d4b370 (diff) | |
download | bcm5719-llvm-275542a40e38a321d2926b44659b926016446501.tar.gz bcm5719-llvm-275542a40e38a321d2926b44659b926016446501.zip |
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
llvm-svn: 205557
-rw-r--r-- | clang/lib/Sema/SemaExprMember.cpp | 2 | ||||
-rw-r--r-- | clang/test/Sema/types.c | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp index 354dfcf3896..675c69fa88f 100644 --- a/clang/lib/Sema/SemaExprMember.cpp +++ b/clang/lib/Sema/SemaExprMember.cpp @@ -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] = {}; diff --git a/clang/test/Sema/types.c b/clang/test/Sema/types.c index 339788eb9df..778a5fe9f7c 100644 --- a/clang/test/Sema/types.c +++ b/clang/test/Sema/types.c @@ -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'}} +} |