[clang] 64911ee - [OpenCL] Allow pipe as a valid identifier prior to OpenCL 2.0.

Anastasia Stulova via cfe-commits cfe-commits at lists.llvm.org
Tue May 4 06:31:19 PDT 2021


Author: Anastasia Stulova
Date: 2021-05-04T14:30:42+01:00
New Revision: 64911eec75bb0c54e40665a2c3f744f046c66a59

URL: https://github.com/llvm/llvm-project/commit/64911eec75bb0c54e40665a2c3f744f046c66a59
DIFF: https://github.com/llvm/llvm-project/commit/64911eec75bb0c54e40665a2c3f744f046c66a59.diff

LOG: [OpenCL] Allow pipe as a valid identifier prior to OpenCL 2.0.

Pipe has not been a reserved keyword in the earlier OpenCL
standards. However we failed to allow its use as an identifier
in the original commit. This issues is fixed now and testing
is improved accordingly.

Differential Revision: https://reviews.llvm.org/D101052

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index eb567f528a1cd..b56f3934fcedf 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -3930,6 +3930,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
         // 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);

diff  --git a/clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl b/clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
index 441a24cf85227..557c191f64076 100644
--- a/clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
+++ b/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;


        


More information about the cfe-commits mailing list