summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse
diff options
context:
space:
mode:
authorBill Schmidt <wschmidt@linux.vnet.ibm.com>2013-07-03 20:54:09 +0000
committerBill Schmidt <wschmidt@linux.vnet.ibm.com>2013-07-03 20:54:09 +0000
commit99a084b7ae1479f445ec4d20754ea3ebe720d528 (patch)
treebd5e1ff0603b3661acae028200a9d3498c502d54 /clang/lib/Parse
parentfb7ace71cffc430c1af7a8fb6bfee717738a4378 (diff)
downloadbcm5719-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/Parse')
-rw-r--r--clang/lib/Parse/ParseDecl.cpp12
-rw-r--r--clang/lib/Parse/Parser.cpp1
2 files changed, 13 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;
OpenPOWER on IntegriCloud