summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamie Schmeiser <schmeise@ca.ibm.com>2021-04-21 13:27:44 -0400
committerJamie Schmeiser <schmeise@ca.ibm.com>2021-04-21 14:36:00 -0400
commit3733420a974201b8439f83441aaa8bcf3610fab6 (patch)
tree8fe242ed1e1556066ad32d698073b5c1d1340518
parent35c564dc963d0875a8af750362cacda91eb8e694 (diff)
downloadllvm-Jamie_Phabricator_D100991.tar.gz
When vector is found as a type or non-type id, check if it is really theJamie_Phabricator_D100991
altivec vector token. Call TryAltiVecVectorToken when an identifier is seen in the parser before annotating the token. This checks the next token where necessary to ensure that vector is properly handled as the altivec token.
-rw-r--r--clang/lib/Parse/Parser.cpp10
-rw-r--r--clang/test/Parser/altivec-non-type-vector.c7
-rw-r--r--clang/test/Parser/altivec-template-vector.cpp11
-rw-r--r--clang/test/Parser/altivec-typedef-vector.c7
4 files changed, 35 insertions, 0 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index b178b56e967c..c4f5f5d3c49d 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -1695,6 +1695,11 @@ Parser::TryAnnotateName(CorrectionCandidateCallback *CCC) {
break;
case Sema::NC_Type: {
+ if (TryAltiVecVectorToken())
+ // vector has been found as a type id when altivec is enabled but
+ // this is followed by a declaration specifier so this is really the
+ // altivec vector token. Leave it unannotated.
+ break;
SourceLocation BeginLoc = NameLoc;
if (SS.isNotEmpty())
BeginLoc = SS.getBeginLoc();
@@ -1736,6 +1741,11 @@ Parser::TryAnnotateName(CorrectionCandidateCallback *CCC) {
return ANK_Success;
case Sema::NC_NonType:
+ if (TryAltiVecVectorToken())
+ // vector has been found as a non-type id when altivec is enabled but
+ // this is followed by a declaration specifier so this is really the
+ // altivec vector token. Leave it unannotated.
+ break;
Tok.setKind(tok::annot_non_type);
setNonTypeAnnotation(Tok, Classification.getNonTypeDecl());
Tok.setLocation(NameLoc);
diff --git a/clang/test/Parser/altivec-non-type-vector.c b/clang/test/Parser/altivec-non-type-vector.c
new file mode 100644
index 000000000000..38e170da62a9
--- /dev/null
+++ b/clang/test/Parser/altivec-non-type-vector.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s
+
+int vector();
+
+void test() {
+ vector unsigned int v = {0};
+}
diff --git a/clang/test/Parser/altivec-template-vector.cpp b/clang/test/Parser/altivec-template-vector.cpp
new file mode 100644
index 000000000000..3b349e778e1f
--- /dev/null
+++ b/clang/test/Parser/altivec-template-vector.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -target-feature +altivec %s
+
+template <typename T> class vector {
+public:
+ vector(int) {}
+};
+
+void f() {
+ vector int v = {0};
+ vector<int> vi = {0};
+}
diff --git a/clang/test/Parser/altivec-typedef-vector.c b/clang/test/Parser/altivec-typedef-vector.c
new file mode 100644
index 000000000000..e94d332b5d79
--- /dev/null
+++ b/clang/test/Parser/altivec-typedef-vector.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s
+
+typedef int vector;
+
+void test() {
+ vector unsigned int v = {0};
+}