Skip to content

Commit 46b55fa

Browse files
author
Anastasia Stulova
committed
[OpenCL] Update comments/diagnostics to refer to C++ for OpenCL
Clang doesn't implement OpenCL C++, change the comments to reflect that. Differential Revision: https://reviews.llvm.org/D64867 llvm-svn: 366421
1 parent 51cdd51 commit 46b55fa

17 files changed

+43
-45
lines changed

clang/include/clang/Basic/DiagnosticCommonKinds.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ def err_nullability_conflicting : Error<
132132

133133
// OpenCL Section 6.8.g
134134
def err_opencl_unknown_type_specifier : Error<
135-
"OpenCL %select{C|C++}0 version %1 does not support the '%2' "
136-
"%select{type qualifier|storage class specifier}3">;
135+
"%select{OpenCL C|C++ for OpenCL}0 version %1 does not support the "
136+
"'%2' %select{type qualifier|storage class specifier}3">;
137137

138138
def warn_unknown_attribute_ignored : Warning<
139139
"unknown attribute %0 ignored">, InGroup<UnknownAttributes>;
@@ -291,9 +291,9 @@ def note_mt_message : Note<"[rewriter] %0">;
291291
def warn_arcmt_nsalloc_realloc : Warning<"[rewriter] call returns pointer to GC managed memory; it will become unmanaged in ARC">;
292292
def err_arcmt_nsinvocation_ownership : Error<"NSInvocation's %0 is not safe to be used with an object with ownership other than __unsafe_unretained">;
293293

294-
// OpenCL C++.
294+
// C++ for OpenCL.
295295
def err_openclcxx_not_supported : Error<
296-
"'%0' is not supported in OpenCL C++">;
296+
"'%0' is not supported in C++ for OpenCL">;
297297

298298
// OpenMP
299299
def err_omp_more_one_clause : Error<

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,9 +1154,9 @@ def err_opencl_taking_function_address_parser : Error<
11541154
def err_opencl_logical_exclusive_or : Error<
11551155
"^^ is a reserved operator in OpenCL">;
11561156

1157-
// OpenCL C++.
1157+
// C++ for OpenCL.
11581158
def err_openclcxx_virtual_function : Error<
1159-
"virtual functions are not supported in OpenCL C++">;
1159+
"virtual functions are not supported in C++ for OpenCL">;
11601160

11611161
// OpenMP support.
11621162
def warn_pragma_omp_ignored : Warning<

clang/include/clang/Basic/LangOptions.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ LANGOPT(ShortEnums , 1, 0, "short enum types")
197197

198198
LANGOPT(OpenCL , 1, 0, "OpenCL")
199199
LANGOPT(OpenCLVersion , 32, 0, "OpenCL C version")
200-
LANGOPT(OpenCLCPlusPlus , 1, 0, "OpenCL C++")
201-
LANGOPT(OpenCLCPlusPlusVersion , 32, 0, "OpenCL C++ version")
200+
LANGOPT(OpenCLCPlusPlus , 1, 0, "C++ for OpenCL")
201+
LANGOPT(OpenCLCPlusPlusVersion , 32, 0, "C++ for OpenCL version")
202202
LANGOPT(NativeHalfType , 1, 0, "Native half type support")
203203
LANGOPT(NativeHalfArgsAndReturns, 1, 0, "Native half args and returns")
204204
LANGOPT(HalfArgsAndReturns, 1, 0, "half args and returns")

clang/include/clang/Basic/TokenKinds.def

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,8 @@ PUNCTUATOR(caretcaret, "^^")
252252
// KEYNOMS18 - This is a keyword that must never be enabled under
253253
// MSVC <= v18.
254254
// KEYOPENCLC - This is a keyword in OpenCL C
255-
// KEYOPENCLCXX - This is a keyword in OpenCL C++
256-
// KEYNOOPENCL - This is a keyword that is not supported in OpenCL C
257-
// nor in OpenCL C++.
255+
// KEYOPENCLCXX - This is a keyword in C++ for OpenCL
256+
// KEYNOOPENCL - This is a keyword that is not supported in OpenCL
258257
// KEYALTIVEC - This is a keyword in AltiVec
259258
// KEYZVECTOR - This is a keyword for the System z vector extensions,
260259
// which are heavily based on AltiVec

clang/include/clang/Frontend/LangStandards.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ LANGSTANDARD(opencl20, "cl2.0",
166166
OpenCL, "OpenCL 2.0",
167167
LineComment | C99 | Digraphs | HexFloat | OpenCL)
168168
LANGSTANDARD(openclcpp, "c++",
169-
OpenCL, "OpenCL C++ 1.0",
169+
OpenCL, "C++ for OpenCL",
170170
LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus17 |
171171
Digraphs | HexFloat | OpenCL)
172172

clang/lib/Frontend/InitPreprocessor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
411411
if (LangOpts.OpenCLCPlusPlusVersion == 100)
412412
Builder.defineMacro("__OPENCL_CPP_VERSION__", "100");
413413
else
414-
llvm_unreachable("Unsupported OpenCL C++ version");
414+
llvm_unreachable("Unsupported C++ version for OpenCL");
415415
Builder.defineMacro("__CL_CPP_VERSION_1_0__", "100");
416416
} else {
417417
// OpenCL v1.0 and v1.1 do not have a predefined macro to indicate the

clang/lib/Parse/ParseDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3559,7 +3559,8 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
35593559
isInvalid = DS.setFunctionSpecInline(Loc, PrevSpec, DiagID);
35603560
break;
35613561
case tok::kw_virtual:
3562-
// OpenCL C++ v1.0 s2.9: the virtual function qualifier is not supported.
3562+
// C++ for OpenCL does not allow virtual function qualifier, to avoid
3563+
// function pointers restricted in OpenCL v2.0 s6.9.a.
35633564
if (getLangOpts().OpenCLCPlusPlus) {
35643565
DiagID = diag::err_openclcxx_virtual_function;
35653566
PrevSpec = Tok.getIdentifierInfo()->getNameStart();

clang/lib/Sema/DeclSpec.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,6 @@ bool DeclSpec::SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc,
596596
// these storage-class specifiers.
597597
// OpenCL v1.2 s6.8 changes this to "The auto and register storage-class
598598
// specifiers are not supported."
599-
// OpenCL C++ v1.0 s2.9 restricts register.
600599
if (S.getLangOpts().OpenCL &&
601600
!S.getOpenCLOptions().isEnabled("cl_clang_storage_class_specifiers")) {
602601
switch (SC) {

clang/lib/Sema/SemaCast.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ Sema::BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind,
285285
AngleBrackets));
286286

287287
case tok::kw_dynamic_cast: {
288-
// OpenCL C++ 1.0 s2.9: dynamic_cast is not supported.
288+
// dynamic_cast is not supported in C++ for OpenCL.
289289
if (getLangOpts().OpenCLCPlusPlus) {
290290
return ExprError(Diag(OpLoc, diag::err_openclcxx_not_supported)
291291
<< "dynamic_cast");

clang/lib/Sema/SemaDecl.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6428,8 +6428,8 @@ NamedDecl *Sema::ActOnVariableDeclarator(
64286428
}
64296429
}
64306430

6431-
// OpenCL C++ 1.0 s2.9: the thread_local storage qualifier is not
6432-
// supported. OpenCL C does not support thread_local either, and
6431+
// C++ for OpenCL does not allow the thread_local storage qualifier.
6432+
// OpenCL C does not support thread_local either, and
64336433
// also reject all other thread storage class specifiers.
64346434
DeclSpec::TSCS TSC = D.getDeclSpec().getThreadStorageClassSpec();
64356435
if (TSC != TSCS_unspecified) {
@@ -7435,9 +7435,8 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) {
74357435
// OpenCL C v2.0 s6.5.1 - Variables defined at program scope and static
74367436
// variables inside a function can also be declared in the global
74377437
// address space.
7438-
// OpenCL C++ v1.0 s2.5 inherits rule from OpenCL C v2.0 and allows local
7439-
// address space additionally.
7440-
// FIXME: Add local AS for OpenCL C++.
7438+
// C++ for OpenCL inherits rule from OpenCL C v2.0.
7439+
// FIXME: Adding local AS in C++ for OpenCL might make sense.
74417440
if (NewVD->isFileVarDecl() || NewVD->isStaticLocal() ||
74427441
NewVD->hasExternalStorage()) {
74437442
if (!T->isSamplerT() &&
@@ -11590,7 +11589,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
1159011589
// do nothing
1159111590

1159211591
// OpenCL v1.2 s6.5.3: __constant locals must be constant-initialized.
11593-
// This is true even in OpenCL C++.
11592+
// This is true even in C++ for OpenCL.
1159411593
} else if (VDecl->getType().getAddressSpace() == LangAS::opencl_constant) {
1159511594
CheckForConstantInitializer(Init, DclT);
1159611595

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13272,7 +13272,7 @@ CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl,
1327213272
diag::err_operator_new_delete_dependent_result_type)
1327313273
<< FnDecl->getDeclName() << ExpectedResultType;
1327413274

13275-
// OpenCL C++: the operator is valid on any address space.
13275+
// The operator is valid on any address space for OpenCL.
1327613276
if (SemaRef.getLangOpts().OpenCLCPlusPlus) {
1327713277
if (auto *PtrTy = ResultType->getAs<PointerType>()) {
1327813278
ResultType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy);
@@ -13305,7 +13305,7 @@ CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl,
1330513305

1330613306
// Check that the first parameter type is what we expect.
1330713307
if (SemaRef.getLangOpts().OpenCLCPlusPlus) {
13308-
// OpenCL C++: the operator is valid on any address space.
13308+
// The operator is valid on any address space for OpenCL.
1330913309
if (auto *PtrTy =
1331013310
FnDecl->getParamDecl(0)->getType()->getAs<PointerType>()) {
1331113311
FirstParamType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy);

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ ExprResult Sema::BuildCXXTypeId(QualType TypeInfoType,
529529
ExprResult
530530
Sema::ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc,
531531
bool isType, void *TyOrExpr, SourceLocation RParenLoc) {
532-
// OpenCL C++ 1.0 s2.9: typeid is not supported.
532+
// typeid is not supported in OpenCL.
533533
if (getLangOpts().OpenCLCPlusPlus) {
534534
return ExprError(Diag(OpLoc, diag::err_openclcxx_not_supported)
535535
<< "typeid");
@@ -2656,8 +2656,8 @@ void Sema::DeclareGlobalNewDelete() {
26562656
if (GlobalNewDeleteDeclared)
26572657
return;
26582658

2659-
// OpenCL C++ 1.0 s2.9: the implicitly declared new and delete operators
2660-
// are not supported.
2659+
// The implicitly declared new and delete operators
2660+
// are not supported in OpenCL.
26612661
if (getLangOpts().OpenCLCPlusPlus)
26622662
return;
26632663

clang/test/Driver/unknown-std.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// CHECK-NEXT: note: use 'cl1.1' for 'OpenCL 1.1' standard
1111
// CHECK-NEXT: note: use 'cl1.2' for 'OpenCL 1.2' standard
1212
// CHECK-NEXT: note: use 'cl2.0' for 'OpenCL 2.0' standard
13-
// CHECK-NEXT: note: use 'c++' for 'OpenCL C++ 1.0' standard
13+
// CHECK-NEXT: note: use 'c++' for 'C++ for OpenCL' standard
1414

1515
// Make sure that no other output is present.
1616
// CHECK-NOT: {{^.+$}}

clang/test/Parser/opencl-cxx-keywords.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -verify -fsyntax-only -fexceptions -fcxx-exceptions
33

44
// This test checks that various C++ and OpenCL C keywords are not available
5-
// in OpenCL C++, according to OpenCL C++ 1.0 Specification Section 2.9.
5+
// in OpenCL.
66

77
// Test that exceptions are disabled despite passing -fcxx-exceptions.
88
kernel void test_exceptions() {

clang/test/Parser/opencl-cxx-virtual.cl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
// Test that virtual functions and abstract classes are rejected.
44
class virtual_functions {
55
virtual void bad1() {}
6-
//expected-error@-1 {{virtual functions are not supported in OpenCL C++}}
6+
//expected-error@-1 {{virtual functions are not supported in C++ for OpenCL}}
77

88
virtual void bad2() = 0;
9-
//expected-error@-1 {{virtual functions are not supported in OpenCL C++}}
9+
//expected-error@-1 {{virtual functions are not supported in C++ for OpenCL}}
1010
//expected-error@-2 {{'bad2' is not virtual and cannot be declared pure}}
1111
};
1212

1313
template <typename T>
1414
class X {
1515
virtual T f();
16-
//expected-error@-1 {{virtual functions are not supported in OpenCL C++}}
16+
//expected-error@-1 {{virtual functions are not supported in C++ for OpenCL}}
1717
};
1818

1919
// Test that virtual base classes are allowed.

clang/test/SemaOpenCLCXX/newdelete.cl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class B {
1919
// There are no global user-defined new operators at this point. Test that clang
2020
// rejects these gracefully.
2121
void test_default_new_delete(void *buffer, A **pa) {
22-
A *a = new A; // expected-error {{'default new' is not supported in OpenCL C++}}
23-
delete a; // expected-error {{'default delete' is not supported in OpenCL C++}}
22+
A *a = new A; // expected-error {{'default new' is not supported in C++ for OpenCL}}
23+
delete a; // expected-error {{'default delete' is not supported in C++ for OpenCL}}
2424
*pa = new (buffer) A; // expected-error {{use of placement new requires explicit declaration}}
2525
}
2626

@@ -36,10 +36,10 @@ void *operator new[](size_t _s, void *ptr) noexcept {
3636

3737
void test_new_delete(void *buffer, A **a, B **b) {
3838
*a = new A; // expected-error {{no matching function for call to 'operator new'}}
39-
delete a; // expected-error {{'default delete' is not supported in OpenCL C++}}
39+
delete a; // expected-error {{'default delete' is not supported in C++ for OpenCL}}
4040

4141
*a = new A[20]; // expected-error {{no matching function for call to 'operator new[]'}}
42-
delete[] *a; // expected-error {{'default delete' is not supported in OpenCL C++}}
42+
delete[] *a; // expected-error {{'default delete' is not supported in C++ for OpenCL}}
4343

4444
// User-defined placement new is supported.
4545
*a = new (buffer) A;
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify -fsyntax-only
22

33
// This test checks that various C/C++/OpenCL C constructs are not available in
4-
// OpenCL C++, according to OpenCL C++ 1.0 Specification Section 2.9.
4+
// C++ for OpenCL.
55

6-
// Test that typeid is not available in OpenCL C++.
6+
// Test that typeid is not available.
77
namespace std {
88
// Provide a dummy std::type_info so that we can use typeid.
99
class type_info {
1010
int a;
1111
};
1212
}
1313
__constant std::type_info int_ti = typeid(int);
14-
// expected-error@-1 {{'typeid' is not supported in OpenCL C++}}
14+
// expected-error@-1 {{'typeid' is not supported in C++ for OpenCL}}
1515

16-
// Test that dynamic_cast is not available in OpenCL C++.
16+
// Test that dynamic_cast is not available in C++ for OpenCL.
1717
class A {
1818
public:
1919
int a;
@@ -25,17 +25,17 @@ class B : public A {
2525

2626
B *test_dynamic_cast(B *p) {
2727
return dynamic_cast<B *>(p);
28-
// expected-error@-1 {{'dynamic_cast' is not supported in OpenCL C++}}
28+
// expected-error@-1 {{'dynamic_cast' is not supported in C++ for OpenCL}}
2929
}
3030

3131
// Test storage class qualifiers.
3232
__constant _Thread_local int a = 1;
33-
// expected-error@-1 {{OpenCL C++ version 1.0 does not support the '_Thread_local' storage class specifier}}
33+
// expected-error@-1 {{C++ for OpenCL version 1.0 does not support the '_Thread_local' storage class specifier}}
3434
__constant __thread int b = 2;
35-
// expected-error@-1 {{OpenCL C++ version 1.0 does not support the '__thread' storage class specifier}}
35+
// expected-error@-1 {{C++ for OpenCL version 1.0 does not support the '__thread' storage class specifier}}
3636
kernel void test_storage_classes() {
3737
register int x;
38-
// expected-error@-1 {{OpenCL C++ version 1.0 does not support the 'register' storage class specifier}}
38+
// expected-error@-1 {{C++ for OpenCL version 1.0 does not support the 'register' storage class specifier}}
3939
thread_local int y;
40-
// expected-error@-1 {{OpenCL C++ version 1.0 does not support the 'thread_local' storage class specifier}}
40+
// expected-error@-1 {{C++ for OpenCL version 1.0 does not support the 'thread_local' storage class specifier}}
4141
}

0 commit comments

Comments
 (0)