Anastasia created this revision. Anastasia added a reviewer: yaxunl. Due to missing handling of address space tokens in parsing code of C++ we were unable to parse declarations that start from an address space keyword. For example we would get an error:
test.cl:2:1: error: expected expression __global int * arg_glob; No idea if there are some more cases missing but this patch at least fixes basic variable and function argument declaration parsing. I enable address space test but part of it still can't run correctly in C++ mode. https://reviews.llvm.org/D48419 Files: lib/Parse/ParseTentative.cpp test/SemaOpenCL/address-spaces.cl Index: test/SemaOpenCL/address-spaces.cl =================================================================== --- test/SemaOpenCL/address-spaces.cl +++ test/SemaOpenCL/address-spaces.cl @@ -1,5 +1,6 @@ // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only +// RUN: %clang_cc1 %s -cl-std=c++ -verify -pedantic -fsyntax-only __constant int ci = 1; @@ -8,6 +9,8 @@ __local int lj = 2; // expected-error {{'__local' variable cannot have an initializer}} int *ip; +// FIXME: Temporarily disable part of the test that doesn't work for C++ yet. +#if !__OPENCL_CPP_VERSION__ #if __OPENCL_C_VERSION__ < 200 ip = gip; // expected-error {{assigning '__global int *' to 'int *' changes address space of pointer}} ip = &li; // expected-error {{assigning '__local int *' to 'int *' changes address space of pointer}} @@ -62,4 +65,5 @@ __local __private int *var2; // expected-error {{multiple address spaces specified for type}} __local private_int_t var3; // expected-error {{multiple address spaces specified for type}} __local private_int_t *var4; // expected-error {{multiple address spaces specified for type}} +#endif // !__OPENCL_CXX_VERSION__ Index: lib/Parse/ParseTentative.cpp =================================================================== --- lib/Parse/ParseTentative.cpp +++ lib/Parse/ParseTentative.cpp @@ -1357,6 +1357,11 @@ // cv-qualifier case tok::kw_const: case tok::kw_volatile: + case tok::kw___private: + case tok::kw___local: + case tok::kw___global: + case tok::kw___constant: + case tok::kw___generic: // GNU case tok::kw_restrict:
Index: test/SemaOpenCL/address-spaces.cl =================================================================== --- test/SemaOpenCL/address-spaces.cl +++ test/SemaOpenCL/address-spaces.cl @@ -1,5 +1,6 @@ // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only +// RUN: %clang_cc1 %s -cl-std=c++ -verify -pedantic -fsyntax-only __constant int ci = 1; @@ -8,6 +9,8 @@ __local int lj = 2; // expected-error {{'__local' variable cannot have an initializer}} int *ip; +// FIXME: Temporarily disable part of the test that doesn't work for C++ yet. +#if !__OPENCL_CPP_VERSION__ #if __OPENCL_C_VERSION__ < 200 ip = gip; // expected-error {{assigning '__global int *' to 'int *' changes address space of pointer}} ip = &li; // expected-error {{assigning '__local int *' to 'int *' changes address space of pointer}} @@ -62,4 +65,5 @@ __local __private int *var2; // expected-error {{multiple address spaces specified for type}} __local private_int_t var3; // expected-error {{multiple address spaces specified for type}} __local private_int_t *var4; // expected-error {{multiple address spaces specified for type}} +#endif // !__OPENCL_CXX_VERSION__ Index: lib/Parse/ParseTentative.cpp =================================================================== --- lib/Parse/ParseTentative.cpp +++ lib/Parse/ParseTentative.cpp @@ -1357,6 +1357,11 @@ // cv-qualifier case tok::kw_const: case tok::kw_volatile: + case tok::kw___private: + case tok::kw___local: + case tok::kw___global: + case tok::kw___constant: + case tok::kw___generic: // GNU case tok::kw_restrict:
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits