From 43988f664374c71b278ec99c6fd0aa73bfba9efc Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Thu, 3 Apr 2014 19:43:01 +0000 Subject: [PATCH] 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205557 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExprMember.cpp | 2 +- test/Sema/types.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaExprMember.cpp b/lib/Sema/SemaExprMember.cpp index 354dfcf389..675c69fa88 100644 --- a/lib/Sema/SemaExprMember.cpp +++ b/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/test/Sema/types.c b/test/Sema/types.c index 339788eb9d..778a5fe9f7 100644 --- a/test/Sema/types.c +++ b/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'}} +} -- 2.40.0