diff options
| author | Bill Schmidt <wschmidt@linux.vnet.ibm.com> | 2013-07-03 20:54:09 +0000 |
|---|---|---|
| committer | Bill Schmidt <wschmidt@linux.vnet.ibm.com> | 2013-07-03 20:54:09 +0000 |
| commit | 99a084b7ae1479f445ec4d20754ea3ebe720d528 (patch) | |
| tree | bd5e1ff0603b3661acae028200a9d3498c502d54 /clang/lib | |
| parent | fb7ace71cffc430c1af7a8fb6bfee717738a4378 (diff) | |
| download | bcm5719-llvm-99a084b7ae1479f445ec4d20754ea3ebe720d528.tar.gz bcm5719-llvm-99a084b7ae1479f445ec4d20754ea3ebe720d528.zip | |
"bool" should be a context-sensitive keyword in Altivec mode.
PR16456 reported that Clang implements a hybrid between AltiVec's
"Keyword and Predefine Method" and its "Context Sensitive Keyword
Method," where "bool" is always a keyword, but "vector" and "pixel"
are context-sensitive keywords. This isn't permitted by the AltiVec
spec. For consistency with gcc, this patch implements the Context
Sensitive Keyword Method for bool, and stops treating true and false
as keywords in Altivec mode.
The patch removes KEYALTIVEC as a trigger for defining these keywords
in include/clang/Basic/TokenKinds.def, and adds logic for "vector
bool" that mirrors the existing logic for "vector pixel." The test
case is taken from the bug report.
llvm-svn: 185580
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 12 | ||||
| -rw-r--r-- | clang/lib/Parse/Parser.cpp | 1 | ||||
| -rw-r--r-- | clang/lib/Sema/DeclSpec.cpp | 14 |
3 files changed, 27 insertions, 0 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 451bf957219..b3e2a85965c 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -5587,6 +5587,10 @@ bool Parser::TryAltiVecVectorTokenOutOfLine() { Tok.setKind(tok::kw___vector); return true; } + if (Next.getIdentifierInfo() == Ident_bool) { + Tok.setKind(tok::kw___vector); + return true; + } return false; } } @@ -5615,6 +5619,10 @@ bool Parser::TryAltiVecTokenOutOfLine(DeclSpec &DS, SourceLocation Loc, isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID); return true; } + if (Next.getIdentifierInfo() == Ident_bool) { + isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID); + return true; + } break; default: break; @@ -5623,6 +5631,10 @@ bool Parser::TryAltiVecTokenOutOfLine(DeclSpec &DS, SourceLocation Loc, DS.isTypeAltiVecVector()) { isInvalid = DS.SetTypeAltiVecPixel(true, Loc, PrevSpec, DiagID); return true; + } else if ((Tok.getIdentifierInfo() == Ident_bool) && + DS.isTypeAltiVecVector()) { + isInvalid = DS.SetTypeAltiVecBool(true, Loc, PrevSpec, DiagID); + return true; } return false; } diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index f19d24299aa..2c6d6b329dd 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -488,6 +488,7 @@ void Parser::Initialize() { if (getLangOpts().AltiVec) { Ident_vector = &PP.getIdentifierTable().get("vector"); Ident_pixel = &PP.getIdentifierTable().get("pixel"); + Ident_bool = &PP.getIdentifierTable().get("bool"); } Ident_introduced = 0; diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index dfce324b702..e75dc7b1bc9 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -707,6 +707,20 @@ bool DeclSpec::SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc, return false; } +bool DeclSpec::SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc, + const char *&PrevSpec, unsigned &DiagID) { + if (!TypeAltiVecVector || TypeAltiVecBool || + (TypeSpecType != TST_unspecified)) { + PrevSpec = DeclSpec::getSpecifierName((TST) TypeSpecType); + DiagID = diag::err_invalid_vector_bool_decl_spec; + return true; + } + TypeAltiVecBool = isAltiVecBool; + TSTLoc = Loc; + TSTNameLoc = Loc; + return false; +} + bool DeclSpec::SetTypeSpecError() { TypeSpecType = TST_error; TypeSpecOwned = false; |

