[PATCH] D101052: [OpenCL] allow pipe as a valid identifier prior to OpenCL 2.0

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 22 05:20:03 PDT 2021


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 at -1 {{type specifier missing, defaults to 'int'}}
+// expected-error at -2 {{access qualifier can only be used for pipe and image type}}
+// expected-error at -3 {{expected ')'}} expected-note at -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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101052.339575.patch
Type: text/x-patch
Size: 1337 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210422/593de6a8/attachment.bin>


More information about the cfe-commits mailing list