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@-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;


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

Reply via email to