diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-05-09 18:56:43 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-05-09 18:56:43 +0000 |
commit | f63eee78a3ed50a974d0963623a06888ecd4ef6b (patch) | |
tree | 61309dec24d0e814d21427a55936821fbe0bf85a | |
parent | 49033207b75216a956f3dbf7d018fb3343a54ec1 (diff) |
Stop AltiVec parsing from going down the 'implicit int' codepath as part of its
normal parse for token sequences like 'vector pixel foo'. This incidentally also
fixes a couple of wrong-parse issues.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156503 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 7 | ||||
-rw-r--r-- | test/Parser/altivec.c | 10 | ||||
-rw-r--r-- | test/SemaCXX/altivec.cpp | 7 |
3 files changed, 22 insertions, 2 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 7cb6474678..e57db6ff9b 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -1921,7 +1921,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, continue; case tok::annot_cxxscope: { - if (DS.hasTypeSpecifier()) + if (DS.hasTypeSpecifier() || DS.isTypeAltiVecVector()) goto DoneWithDeclSpec; CXXScopeSpec SS; @@ -2119,6 +2119,11 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, if (TryAltiVecToken(DS, Loc, PrevSpec, DiagID, isInvalid)) break; + // [AltiVec] 2.2: [If the 'vector' specifier is used] The syntax does not + // allow the use of a typedef name as a type specifier. + if (DS.isTypeAltiVecVector()) + goto DoneWithDeclSpec; + ParsedType TypeRep = Actions.getTypeName(*Tok.getIdentifierInfo(), Tok.getLocation(), getCurScope()); diff --git a/test/Parser/altivec.c b/test/Parser/altivec.c index d1e6552137..0bdc3dcffe 100644 --- a/test/Parser/altivec.c +++ b/test/Parser/altivec.c @@ -76,6 +76,16 @@ vector bool unsigned int v_bsc2; // expected-error {{cannot use 'unsigned' w vector bool long v_bl; // expected-error {{cannot use 'long' with '__vector bool'}} vector bool long long v_bll; // expected-error {{cannot use 'long long' with '__vector bool'}} +typedef char i8; +typedef short i16; +typedef int i32; +struct S { + // i8, i16, i32 here are field names, not type names. + vector bool i8; // expected-error {{requires a specifier or qualifier}} + vector pixel i16; + vector long i32; // expected-warning {{deprecated}} +}; + void f() { __vector unsigned int v = {0,0,0,0}; __vector int v__cast = (__vector int)v; diff --git a/test/SemaCXX/altivec.cpp b/test/SemaCXX/altivec.cpp index 39421b7c40..9de1f04b69 100644 --- a/test/SemaCXX/altivec.cpp +++ b/test/SemaCXX/altivec.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -faltivec -fno-lax-vector-conversions -triple powerpc-unknown-unknown -verify %s +// RUN: %clang_cc1 -faltivec -fno-lax-vector-conversions -triple powerpc-unknown-unknown -fcxx-exceptions -verify %s typedef int V4i __attribute__((vector_size(16))); @@ -76,3 +76,8 @@ namespace LValueToRValueConversions { vector float initFloat = (vector float)(Struct().f); // expected-error {{did you mean to call it}} vector int initInt = (vector int)(Struct().n); // expected-error {{did you mean to call it}} } + +void f() { + try {} + catch (vector pixel px) {} +}; |