From: Anastasia Stulova Date: Thu, 18 Jul 2019 10:02:35 +0000 (+0000) Subject: [OpenCL] Update comments/diagnostics to refer to C++ for OpenCL X-Git-Tag: llvmorg-10-init~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=46b55fa58dead05222211e327ed90ffab949040b;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td b/clang/include/clang/Basic/DiagnosticCommonKinds.td index 776d16b..ca2faf5 100644 --- a/clang/include/clang/Basic/DiagnosticCommonKinds.td +++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td @@ -132,8 +132,8 @@ def err_nullability_conflicting : Error< // OpenCL Section 6.8.g def err_opencl_unknown_type_specifier : Error< - "OpenCL %select{C|C++}0 version %1 does not support the '%2' " - "%select{type qualifier|storage class specifier}3">; + "%select{OpenCL C|C++ for OpenCL}0 version %1 does not support the " + "'%2' %select{type qualifier|storage class specifier}3">; def warn_unknown_attribute_ignored : Warning< "unknown attribute %0 ignored">, InGroup; @@ -291,9 +291,9 @@ def note_mt_message : Note<"[rewriter] %0">; def warn_arcmt_nsalloc_realloc : Warning<"[rewriter] call returns pointer to GC managed memory; it will become unmanaged in ARC">; def err_arcmt_nsinvocation_ownership : Error<"NSInvocation's %0 is not safe to be used with an object with ownership other than __unsafe_unretained">; -// OpenCL C++. +// C++ for OpenCL. def err_openclcxx_not_supported : Error< - "'%0' is not supported in OpenCL C++">; + "'%0' is not supported in C++ for OpenCL">; // OpenMP def err_omp_more_one_clause : Error< diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index 608337e..8e6ced0 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1154,9 +1154,9 @@ def err_opencl_taking_function_address_parser : Error< def err_opencl_logical_exclusive_or : Error< "^^ is a reserved operator in OpenCL">; -// OpenCL C++. +// C++ for OpenCL. def err_openclcxx_virtual_function : Error< - "virtual functions are not supported in OpenCL C++">; + "virtual functions are not supported in C++ for OpenCL">; // OpenMP support. def warn_pragma_omp_ignored : Warning< diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index bbe3f7b..31aca2b 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -197,8 +197,8 @@ LANGOPT(ShortEnums , 1, 0, "short enum types") LANGOPT(OpenCL , 1, 0, "OpenCL") LANGOPT(OpenCLVersion , 32, 0, "OpenCL C version") -LANGOPT(OpenCLCPlusPlus , 1, 0, "OpenCL C++") -LANGOPT(OpenCLCPlusPlusVersion , 32, 0, "OpenCL C++ version") +LANGOPT(OpenCLCPlusPlus , 1, 0, "C++ for OpenCL") +LANGOPT(OpenCLCPlusPlusVersion , 32, 0, "C++ for OpenCL version") LANGOPT(NativeHalfType , 1, 0, "Native half type support") LANGOPT(NativeHalfArgsAndReturns, 1, 0, "Native half args and returns") LANGOPT(HalfArgsAndReturns, 1, 0, "half args and returns") diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def index 764f586..55e94d3 100644 --- a/clang/include/clang/Basic/TokenKinds.def +++ b/clang/include/clang/Basic/TokenKinds.def @@ -252,9 +252,8 @@ PUNCTUATOR(caretcaret, "^^") // KEYNOMS18 - This is a keyword that must never be enabled under // MSVC <= v18. // KEYOPENCLC - This is a keyword in OpenCL C -// KEYOPENCLCXX - This is a keyword in OpenCL C++ -// KEYNOOPENCL - This is a keyword that is not supported in OpenCL C -// nor in OpenCL C++. +// KEYOPENCLCXX - This is a keyword in C++ for OpenCL +// KEYNOOPENCL - This is a keyword that is not supported in OpenCL // KEYALTIVEC - This is a keyword in AltiVec // KEYZVECTOR - This is a keyword for the System z vector extensions, // which are heavily based on AltiVec diff --git a/clang/include/clang/Frontend/LangStandards.def b/clang/include/clang/Frontend/LangStandards.def index 44a080d..0964e9b 100644 --- a/clang/include/clang/Frontend/LangStandards.def +++ b/clang/include/clang/Frontend/LangStandards.def @@ -166,7 +166,7 @@ LANGSTANDARD(opencl20, "cl2.0", OpenCL, "OpenCL 2.0", LineComment | C99 | Digraphs | HexFloat | OpenCL) LANGSTANDARD(openclcpp, "c++", - OpenCL, "OpenCL C++ 1.0", + OpenCL, "C++ for OpenCL", LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus17 | Digraphs | HexFloat | OpenCL) diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 11ebab9..3906e2a 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -411,7 +411,7 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI, if (LangOpts.OpenCLCPlusPlusVersion == 100) Builder.defineMacro("__OPENCL_CPP_VERSION__", "100"); else - llvm_unreachable("Unsupported OpenCL C++ version"); + llvm_unreachable("Unsupported C++ version for OpenCL"); Builder.defineMacro("__CL_CPP_VERSION_1_0__", "100"); } else { // OpenCL v1.0 and v1.1 do not have a predefined macro to indicate the diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 97fd92b..73b4f50 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -3559,7 +3559,8 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, isInvalid = DS.setFunctionSpecInline(Loc, PrevSpec, DiagID); break; case tok::kw_virtual: - // OpenCL C++ v1.0 s2.9: the virtual function qualifier is not supported. + // C++ for OpenCL does not allow virtual function qualifier, to avoid + // function pointers restricted in OpenCL v2.0 s6.9.a. if (getLangOpts().OpenCLCPlusPlus) { DiagID = diag::err_openclcxx_virtual_function; PrevSpec = Tok.getIdentifierInfo()->getNameStart(); diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index 9433efb..77e5eb0 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -596,7 +596,6 @@ bool DeclSpec::SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, // these storage-class specifiers. // OpenCL v1.2 s6.8 changes this to "The auto and register storage-class // specifiers are not supported." - // OpenCL C++ v1.0 s2.9 restricts register. if (S.getLangOpts().OpenCL && !S.getOpenCLOptions().isEnabled("cl_clang_storage_class_specifiers")) { switch (SC) { diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp index 85d6da7..f184eda 100644 --- a/clang/lib/Sema/SemaCast.cpp +++ b/clang/lib/Sema/SemaCast.cpp @@ -285,7 +285,7 @@ Sema::BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, AngleBrackets)); case tok::kw_dynamic_cast: { - // OpenCL C++ 1.0 s2.9: dynamic_cast is not supported. + // dynamic_cast is not supported in C++ for OpenCL. if (getLangOpts().OpenCLCPlusPlus) { return ExprError(Diag(OpLoc, diag::err_openclcxx_not_supported) << "dynamic_cast"); diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 72b4f6bb..a6c52b7 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -6428,8 +6428,8 @@ NamedDecl *Sema::ActOnVariableDeclarator( } } - // OpenCL C++ 1.0 s2.9: the thread_local storage qualifier is not - // supported. OpenCL C does not support thread_local either, and + // C++ for OpenCL does not allow the thread_local storage qualifier. + // OpenCL C does not support thread_local either, and // also reject all other thread storage class specifiers. DeclSpec::TSCS TSC = D.getDeclSpec().getThreadStorageClassSpec(); if (TSC != TSCS_unspecified) { @@ -7435,9 +7435,8 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) { // OpenCL C v2.0 s6.5.1 - Variables defined at program scope and static // variables inside a function can also be declared in the global // address space. - // OpenCL C++ v1.0 s2.5 inherits rule from OpenCL C v2.0 and allows local - // address space additionally. - // FIXME: Add local AS for OpenCL C++. + // C++ for OpenCL inherits rule from OpenCL C v2.0. + // FIXME: Adding local AS in C++ for OpenCL might make sense. if (NewVD->isFileVarDecl() || NewVD->isStaticLocal() || NewVD->hasExternalStorage()) { if (!T->isSamplerT() && @@ -11590,7 +11589,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) { // do nothing // OpenCL v1.2 s6.5.3: __constant locals must be constant-initialized. - // This is true even in OpenCL C++. + // This is true even in C++ for OpenCL. } else if (VDecl->getType().getAddressSpace() == LangAS::opencl_constant) { CheckForConstantInitializer(Init, DclT); diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index cb6b418..dd77fc5 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -13272,7 +13272,7 @@ CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl, diag::err_operator_new_delete_dependent_result_type) << FnDecl->getDeclName() << ExpectedResultType; - // OpenCL C++: the operator is valid on any address space. + // The operator is valid on any address space for OpenCL. if (SemaRef.getLangOpts().OpenCLCPlusPlus) { if (auto *PtrTy = ResultType->getAs()) { ResultType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy); @@ -13305,7 +13305,7 @@ CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl, // Check that the first parameter type is what we expect. if (SemaRef.getLangOpts().OpenCLCPlusPlus) { - // OpenCL C++: the operator is valid on any address space. + // The operator is valid on any address space for OpenCL. if (auto *PtrTy = FnDecl->getParamDecl(0)->getType()->getAs()) { FirstParamType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy); diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index cdca2e8..705e3b9 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -529,7 +529,7 @@ ExprResult Sema::BuildCXXTypeId(QualType TypeInfoType, ExprResult Sema::ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc, bool isType, void *TyOrExpr, SourceLocation RParenLoc) { - // OpenCL C++ 1.0 s2.9: typeid is not supported. + // typeid is not supported in OpenCL. if (getLangOpts().OpenCLCPlusPlus) { return ExprError(Diag(OpLoc, diag::err_openclcxx_not_supported) << "typeid"); @@ -2656,8 +2656,8 @@ void Sema::DeclareGlobalNewDelete() { if (GlobalNewDeleteDeclared) return; - // OpenCL C++ 1.0 s2.9: the implicitly declared new and delete operators - // are not supported. + // The implicitly declared new and delete operators + // are not supported in OpenCL. if (getLangOpts().OpenCLCPlusPlus) return; diff --git a/clang/test/Driver/unknown-std.cl b/clang/test/Driver/unknown-std.cl index 90ee97b..285582e 100644 --- a/clang/test/Driver/unknown-std.cl +++ b/clang/test/Driver/unknown-std.cl @@ -10,7 +10,7 @@ // CHECK-NEXT: note: use 'cl1.1' for 'OpenCL 1.1' standard // CHECK-NEXT: note: use 'cl1.2' for 'OpenCL 1.2' standard // CHECK-NEXT: note: use 'cl2.0' for 'OpenCL 2.0' standard -// CHECK-NEXT: note: use 'c++' for 'OpenCL C++ 1.0' standard +// CHECK-NEXT: note: use 'c++' for 'C++ for OpenCL' standard // Make sure that no other output is present. // CHECK-NOT: {{^.+$}} diff --git a/clang/test/Parser/opencl-cxx-keywords.cl b/clang/test/Parser/opencl-cxx-keywords.cl index beae6f4..0cafcdf 100644 --- a/clang/test/Parser/opencl-cxx-keywords.cl +++ b/clang/test/Parser/opencl-cxx-keywords.cl @@ -2,7 +2,7 @@ // RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -verify -fsyntax-only -fexceptions -fcxx-exceptions // This test checks that various C++ and OpenCL C keywords are not available -// in OpenCL C++, according to OpenCL C++ 1.0 Specification Section 2.9. +// in OpenCL. // Test that exceptions are disabled despite passing -fcxx-exceptions. kernel void test_exceptions() { diff --git a/clang/test/Parser/opencl-cxx-virtual.cl b/clang/test/Parser/opencl-cxx-virtual.cl index da08bfd..53befbc 100644 --- a/clang/test/Parser/opencl-cxx-virtual.cl +++ b/clang/test/Parser/opencl-cxx-virtual.cl @@ -3,17 +3,17 @@ // Test that virtual functions and abstract classes are rejected. class virtual_functions { virtual void bad1() {} - //expected-error@-1 {{virtual functions are not supported in OpenCL C++}} + //expected-error@-1 {{virtual functions are not supported in C++ for OpenCL}} virtual void bad2() = 0; - //expected-error@-1 {{virtual functions are not supported in OpenCL C++}} + //expected-error@-1 {{virtual functions are not supported in C++ for OpenCL}} //expected-error@-2 {{'bad2' is not virtual and cannot be declared pure}} }; template class X { virtual T f(); - //expected-error@-1 {{virtual functions are not supported in OpenCL C++}} + //expected-error@-1 {{virtual functions are not supported in C++ for OpenCL}} }; // Test that virtual base classes are allowed. diff --git a/clang/test/SemaOpenCLCXX/newdelete.cl b/clang/test/SemaOpenCLCXX/newdelete.cl index 14be455..abc4c0f 100644 --- a/clang/test/SemaOpenCLCXX/newdelete.cl +++ b/clang/test/SemaOpenCLCXX/newdelete.cl @@ -19,8 +19,8 @@ class B { // There are no global user-defined new operators at this point. Test that clang // rejects these gracefully. void test_default_new_delete(void *buffer, A **pa) { - A *a = new A; // expected-error {{'default new' is not supported in OpenCL C++}} - delete a; // expected-error {{'default delete' is not supported in OpenCL C++}} + A *a = new A; // expected-error {{'default new' is not supported in C++ for OpenCL}} + delete a; // expected-error {{'default delete' is not supported in C++ for OpenCL}} *pa = new (buffer) A; // expected-error {{use of placement new requires explicit declaration}} } @@ -36,10 +36,10 @@ void *operator new[](size_t _s, void *ptr) noexcept { void test_new_delete(void *buffer, A **a, B **b) { *a = new A; // expected-error {{no matching function for call to 'operator new'}} - delete a; // expected-error {{'default delete' is not supported in OpenCL C++}} + delete a; // expected-error {{'default delete' is not supported in C++ for OpenCL}} *a = new A[20]; // expected-error {{no matching function for call to 'operator new[]'}} - delete[] *a; // expected-error {{'default delete' is not supported in OpenCL C++}} + delete[] *a; // expected-error {{'default delete' is not supported in C++ for OpenCL}} // User-defined placement new is supported. *a = new (buffer) A; diff --git a/clang/test/SemaOpenCLCXX/restricted.cl b/clang/test/SemaOpenCLCXX/restricted.cl index f4ad27a..2af4ae1 100644 --- a/clang/test/SemaOpenCLCXX/restricted.cl +++ b/clang/test/SemaOpenCLCXX/restricted.cl @@ -1,9 +1,9 @@ // RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify -fsyntax-only // This test checks that various C/C++/OpenCL C constructs are not available in -// OpenCL C++, according to OpenCL C++ 1.0 Specification Section 2.9. +// C++ for OpenCL. -// Test that typeid is not available in OpenCL C++. +// Test that typeid is not available. namespace std { // Provide a dummy std::type_info so that we can use typeid. class type_info { @@ -11,9 +11,9 @@ namespace std { }; } __constant std::type_info int_ti = typeid(int); -// expected-error@-1 {{'typeid' is not supported in OpenCL C++}} +// expected-error@-1 {{'typeid' is not supported in C++ for OpenCL}} -// Test that dynamic_cast is not available in OpenCL C++. +// Test that dynamic_cast is not available in C++ for OpenCL. class A { public: int a; @@ -25,17 +25,17 @@ class B : public A { B *test_dynamic_cast(B *p) { return dynamic_cast(p); - // expected-error@-1 {{'dynamic_cast' is not supported in OpenCL C++}} + // expected-error@-1 {{'dynamic_cast' is not supported in C++ for OpenCL}} } // Test storage class qualifiers. __constant _Thread_local int a = 1; -// expected-error@-1 {{OpenCL C++ version 1.0 does not support the '_Thread_local' storage class specifier}} +// expected-error@-1 {{C++ for OpenCL version 1.0 does not support the '_Thread_local' storage class specifier}} __constant __thread int b = 2; -// expected-error@-1 {{OpenCL C++ version 1.0 does not support the '__thread' storage class specifier}} +// expected-error@-1 {{C++ for OpenCL version 1.0 does not support the '__thread' storage class specifier}} kernel void test_storage_classes() { register int x; - // expected-error@-1 {{OpenCL C++ version 1.0 does not support the 'register' storage class specifier}} + // expected-error@-1 {{C++ for OpenCL version 1.0 does not support the 'register' storage class specifier}} thread_local int y; - // expected-error@-1 {{OpenCL C++ version 1.0 does not support the 'thread_local' storage class specifier}} + // expected-error@-1 {{C++ for OpenCL version 1.0 does not support the 'thread_local' storage class specifier}} }