[PATCH] D100991: Fix parsing of vector keyword in presence of conflicting uses.

2021-05-20 Thread Jamie Schmeiser via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG136ced498ba8: When vector is found as a type or non-type id, 
check if it is really theā€¦ (authored by jamieschmeiser).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100991/new/

https://reviews.llvm.org/D100991

Files:
  clang/lib/Parse/Parser.cpp
  clang/test/Parser/altivec-non-type-vector.c
  clang/test/Parser/altivec-template-vector.cpp
  clang/test/Parser/altivec-typedef-vector.c


Index: clang/test/Parser/altivec-typedef-vector.c
===
--- /dev/null
+++ clang/test/Parser/altivec-typedef-vector.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64le-ibm-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc-linux-gnu
+
+typedef int vector;
+
+void test() {
+  vector unsigned int v = {0};
+}
Index: clang/test/Parser/altivec-template-vector.cpp
===
--- /dev/null
+++ clang/test/Parser/altivec-template-vector.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64le-ibm-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc-linux-gnu
+
+template  class vector {
+public:
+  vector(int) {}
+};
+
+void f() {
+  vector int v = {0};
+  vector vi = {0};
+}
Index: clang/test/Parser/altivec-non-type-vector.c
===
--- /dev/null
+++ clang/test/Parser/altivec-non-type-vector.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64le-ibm-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc-linux-gnu
+
+int vector();
+
+void test() {
+  vector unsigned int v = {0};
+}
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1695,6 +1695,11 @@
 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 @@
 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);


Index: clang/test/Parser/altivec-typedef-vector.c
===
--- /dev/null
+++ clang/test/Parser/altivec-typedef-vector.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-ibm-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-linux-gnu
+
+typedef int vector;
+
+void test() {
+  vector unsigned int v = {0};
+}
Index: clang/test/Parser/altivec-template-vector.cpp
===
--- /dev/null
+++ clang/test/Parser/altivec-template-vector.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-ibm-linux-gnu
+// RUN: %clang_cc1 -target-feature 

[PATCH] D100991: Fix parsing of vector keyword in presence of conflicting uses.

2021-05-20 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA accepted this revision.
ZarkoCA added a comment.
This revision is now accepted and ready to land.

LGTM, thanks.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100991/new/

https://reviews.llvm.org/D100991

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100991: Fix parsing of vector keyword in presence of conflicting uses.

2021-05-20 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser updated this revision to Diff 346722.
jamieschmeiser added a comment.

Remove unnecessary tests.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100991/new/

https://reviews.llvm.org/D100991

Files:
  clang/lib/Parse/Parser.cpp
  clang/test/Parser/altivec-non-type-vector.c
  clang/test/Parser/altivec-template-vector.cpp
  clang/test/Parser/altivec-typedef-vector.c


Index: clang/test/Parser/altivec-typedef-vector.c
===
--- /dev/null
+++ clang/test/Parser/altivec-typedef-vector.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64le-ibm-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc-linux-gnu
+
+typedef int vector;
+
+void test() {
+  vector unsigned int v = {0};
+}
Index: clang/test/Parser/altivec-template-vector.cpp
===
--- /dev/null
+++ clang/test/Parser/altivec-template-vector.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64le-ibm-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc-linux-gnu
+
+template  class vector {
+public:
+  vector(int) {}
+};
+
+void f() {
+  vector int v = {0};
+  vector vi = {0};
+}
Index: clang/test/Parser/altivec-non-type-vector.c
===
--- /dev/null
+++ clang/test/Parser/altivec-non-type-vector.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64le-ibm-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc-linux-gnu
+
+int vector();
+
+void test() {
+  vector unsigned int v = {0};
+}
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1695,6 +1695,11 @@
 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 @@
 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);


Index: clang/test/Parser/altivec-typedef-vector.c
===
--- /dev/null
+++ clang/test/Parser/altivec-typedef-vector.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-ibm-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-linux-gnu
+
+typedef int vector;
+
+void test() {
+  vector unsigned int v = {0};
+}
Index: clang/test/Parser/altivec-template-vector.cpp
===
--- /dev/null
+++ clang/test/Parser/altivec-template-vector.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-ibm-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 

[PATCH] D100991: Fix parsing of vector keyword in presence of conflicting uses.

2021-05-20 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA added inline comments.



Comment at: clang/test/Parser/altivec-non-type-vector.c:1-24
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64-ibm-aix
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64le-ibm-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64le-linux-unknown
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64le-unknown-linux
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64le-unknown-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple 
powerpc64le-unknown-unknown

Sorry, didn't mean to imply you needed all of these.  These should suffice. 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100991/new/

https://reviews.llvm.org/D100991

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100991: Fix parsing of vector keyword in presence of conflicting uses.

2021-05-19 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser updated this revision to Diff 346548.
jamieschmeiser added a comment.

Expand testing.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100991/new/

https://reviews.llvm.org/D100991

Files:
  clang/lib/Parse/Parser.cpp
  clang/test/Parser/altivec-non-type-vector.c
  clang/test/Parser/altivec-template-vector.cpp
  clang/test/Parser/altivec-typedef-vector.c

Index: clang/test/Parser/altivec-typedef-vector.c
===
--- /dev/null
+++ clang/test/Parser/altivec-typedef-vector.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-ibm-aix
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-ibm-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-linux-unknown
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-unknown-linux
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-unknown-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-unknown-unknown
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-linux
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-linux-musl
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-montavista-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-none-none
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-unknown-aix
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-unknown-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-unknown-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-unknown-unknown
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-ibm-aix
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-unknown-aix
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-unknown-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-unknown-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-unknown-openbsd
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-unknown-unknown
+
+typedef int vector;
+
+void test() {
+  vector unsigned int v = {0};
+}
Index: clang/test/Parser/altivec-template-vector.cpp
===
--- /dev/null
+++ clang/test/Parser/altivec-template-vector.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-ibm-aix
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-ibm-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-linux-unknown
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-unknown-linux
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-unknown-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-unknown-unknown
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-linux
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-linux-musl
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-montavista-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-none-none
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-unknown-aix
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-unknown-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-unknown-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-unknown-unknown
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-ibm-aix
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-unknown-aix
+// RUN: %clang_cc1 

[PATCH] D100991: Fix parsing of vector keyword in presence of conflicting uses.

2021-05-13 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA added inline comments.



Comment at: clang/test/Parser/altivec-non-type-vector.c:1
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix-xcoff -target-feature 
+altivec -fsyntax-only %s
+

Can you add tests for 64bit BE/LE linux and 32bit AIX/BE linux in this the 
subsequent test cases? 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100991/new/

https://reviews.llvm.org/D100991

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100991: Fix parsing of vector keyword in presence of conflicting uses.

2021-05-11 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser added a comment.

ping


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100991/new/

https://reviews.llvm.org/D100991

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100991: Fix parsing of vector keyword in presence of conflicting uses.

2021-05-03 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser updated this revision to Diff 342540.
jamieschmeiser added a comment.

Limit tests to platform that supports altivec.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100991/new/

https://reviews.llvm.org/D100991

Files:
  clang/lib/Parse/Parser.cpp
  clang/test/Parser/altivec-non-type-vector.c
  clang/test/Parser/altivec-template-vector.cpp
  clang/test/Parser/altivec-typedef-vector.c


Index: clang/test/Parser/altivec-typedef-vector.c
===
--- /dev/null
+++ clang/test/Parser/altivec-typedef-vector.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix-xcoff -target-feature 
+altivec -fsyntax-only %s
+
+typedef int vector;
+
+void test() {
+  vector unsigned int v = {0};
+}
Index: clang/test/Parser/altivec-template-vector.cpp
===
--- /dev/null
+++ clang/test/Parser/altivec-template-vector.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix-xcoff -target-feature 
+altivec -fsyntax-only %s
+
+template  class vector {
+public:
+  vector(int) {}
+};
+
+void f() {
+  vector int v = {0};
+  vector vi = {0};
+}
Index: clang/test/Parser/altivec-non-type-vector.c
===
--- /dev/null
+++ clang/test/Parser/altivec-non-type-vector.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix-xcoff -target-feature 
+altivec -fsyntax-only %s
+
+int vector();
+
+void test() {
+  vector unsigned int v = {0};
+}
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1695,6 +1695,11 @@
 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 @@
 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);


Index: clang/test/Parser/altivec-typedef-vector.c
===
--- /dev/null
+++ clang/test/Parser/altivec-typedef-vector.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix-xcoff -target-feature +altivec -fsyntax-only %s
+
+typedef int vector;
+
+void test() {
+  vector unsigned int v = {0};
+}
Index: clang/test/Parser/altivec-template-vector.cpp
===
--- /dev/null
+++ clang/test/Parser/altivec-template-vector.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix-xcoff -target-feature +altivec -fsyntax-only %s
+
+template  class vector {
+public:
+  vector(int) {}
+};
+
+void f() {
+  vector int v = {0};
+  vector vi = {0};
+}
Index: clang/test/Parser/altivec-non-type-vector.c
===
--- /dev/null
+++ clang/test/Parser/altivec-non-type-vector.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix-xcoff -target-feature +altivec -fsyntax-only %s
+
+int vector();
+
+void test() {
+  vector unsigned int v = {0};
+}
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1695,6 +1695,11 @@
 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 @@
 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);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100991: Fix parsing of vector keyword in presence of conflicting uses.

2021-04-21 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser created this revision.
jamieschmeiser added reviewers: rsmith, saar.raz.
jamieschmeiser requested review of this revision.
Herald added a project: clang.

When vector is found as a type or non-type id, check if it is really the 
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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100991

Files:
  clang/lib/Parse/Parser.cpp
  clang/test/Parser/altivec-non-type-vector.c
  clang/test/Parser/altivec-template-vector.cpp
  clang/test/Parser/altivec-typedef-vector.c


Index: clang/test/Parser/altivec-typedef-vector.c
===
--- /dev/null
+++ 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};
+}
Index: clang/test/Parser/altivec-template-vector.cpp
===
--- /dev/null
+++ clang/test/Parser/altivec-template-vector.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -target-feature +altivec %s
+
+template  class vector {
+public:
+  vector(int) {}
+};
+
+void f() {
+  vector int v = {0};
+  vector vi = {0};
+}
Index: clang/test/Parser/altivec-non-type-vector.c
===
--- /dev/null
+++ 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};
+}
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1695,6 +1695,11 @@
 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 @@
 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);


Index: clang/test/Parser/altivec-typedef-vector.c
===
--- /dev/null
+++ 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};
+}
Index: clang/test/Parser/altivec-template-vector.cpp
===
--- /dev/null
+++ clang/test/Parser/altivec-template-vector.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -target-feature +altivec %s
+
+template  class vector {
+public:
+  vector(int) {}
+};
+
+void f() {
+  vector int v = {0};
+  vector vi = {0};
+}
Index: clang/test/Parser/altivec-non-type-vector.c
===
--- /dev/null
+++ 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};
+}
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1695,6 +1695,11 @@
 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 @@
 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);
___
cfe-commits mailing list