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

0 commit comments

Comments
 (0)