Anastasia created this revision.
Anastasia added reviewers: svenvh, azabaznov.
Herald added subscribers: ebevhan, yaxunl.
Anastasia requested review of this revision.

pipe has not been a reserved keyword in the earlier OpenCL standards
https://www.khronos.org/registry/OpenCL/specs/opencl-1.2.pdf
 however we failed to allow its use as an identifier in the original 
implememntation.

This patch fixes the issue and improves testing.

Btw I feel we have a spec issue in the unified spec 
https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_C.html#keywords
 because it doesn't say that the pipe is reserved only from OpenCL 2.0?


https://reviews.llvm.org/D101052

Files:
  clang/lib/Parse/ParseDecl.cpp
  clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl


Index: clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
===================================================================
--- clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
+++ clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
@@ -1,3 +1,9 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
 
-void foo(read_only pipe int p); // expected-error {{expected parameter 
declarator}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+void foo(read_only pipe int p);
+// expected-warning@-1 {{type specifier missing, defaults to 'int'}}
+// expected-error@-2 {{access qualifier can only be used for pipe and image 
type}}
+// expected-error@-3 {{expected ')'}} expected-note@-3 {{to match this '('}}
+
+// 'pipe' should be accepted as an identifier.
+typedef int pipe;
Index: clang/lib/Parse/ParseDecl.cpp
===================================================================
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -3943,6 +3943,7 @@
         // OpenCL 2.0 and later define this keyword. OpenCL 1.2 and earlier
         // should support the "pipe" word as identifier.
         Tok.getIdentifierInfo()->revertTokenIDToIdentifier();
+        Tok.setKind(tok::identifier);
         goto DoneWithDeclSpec;
       }
       isInvalid = DS.SetTypePipe(true, Loc, PrevSpec, DiagID, Policy);


Index: clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
===================================================================
--- clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
+++ clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
@@ -1,3 +1,9 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
 
-void foo(read_only pipe int p); // expected-error {{expected parameter declarator}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+void foo(read_only pipe int p);
+// expected-warning@-1 {{type specifier missing, defaults to 'int'}}
+// expected-error@-2 {{access qualifier can only be used for pipe and image type}}
+// expected-error@-3 {{expected ')'}} expected-note@-3 {{to match this '('}}
+
+// 'pipe' should be accepted as an identifier.
+typedef int pipe;
Index: clang/lib/Parse/ParseDecl.cpp
===================================================================
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -3943,6 +3943,7 @@
         // OpenCL 2.0 and later define this keyword. OpenCL 1.2 and earlier
         // should support the "pipe" word as identifier.
         Tok.getIdentifierInfo()->revertTokenIDToIdentifier();
+        Tok.setKind(tok::identifier);
         goto DoneWithDeclSpec;
       }
       isInvalid = DS.SetTypePipe(true, Loc, PrevSpec, DiagID, Policy);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D101052: [OpenC... Anastasia Stulova via Phabricator via cfe-commits

Reply via email to