Index: clang/include/clang/Basic/DiagnosticCommonKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticCommonKinds.td +++ clang/include/clang/Basic/DiagnosticCommonKinds.td @@ -149,8 +149,8 @@ // OpenCL Section 6.8.g def err_opencl_unknown_type_specifier : Error< - "%select{OpenCL C|C++ for OpenCL}0 version %1 does not support the " - "'%2' %select{type qualifier|storage class specifier}3">; + "%0 does not support the '%1' " + "%select{type qualifier|storage class specifier}2">; def warn_unknown_attribute_ignored : Warning< "unknown attribute %0 ignored">, InGroup; Index: clang/include/clang/Basic/DiagnosticFrontendKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticFrontendKinds.td +++ clang/include/clang/Basic/DiagnosticFrontendKinds.td @@ -245,7 +245,7 @@ "invalid virtual filesystem overlay file '%0'">, DefaultFatal; def warn_option_invalid_ocl_version : Warning< - "OpenCL version %0 does not support the option '%1'">, InGroup; + "%0 does not support the option '%1'">, InGroup; def err_builtin_needs_feature : Error<"%0 needs target feature %1">; def err_function_needs_feature : Error< Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2953,7 +2953,7 @@ "%0 attribute requires a %select{positive|non-negative}1 " "integral compile time constant expression">; def err_attribute_requires_opencl_version : Error< - "%0 attribute requires OpenCL version %1%select{| or above}2">; + "attribute %0 is supported in the OpenCL version %1%select{| onwards}2">; def err_invalid_branch_protection_spec : Error< "invalid or misplaced branch protection specification '%0'">; def warn_unsupported_target_attribute @@ -10080,8 +10080,7 @@ def err_opencl_type_not_found : Error< "%0 type %1 not found; include the base header with -finclude-default-header">; def warn_opencl_attr_deprecated_ignored : Warning < - "%0 attribute is deprecated and ignored in OpenCL version %1">, - InGroup; + "%0 attribute is deprecated and ignored in %1">, InGroup; def err_opencl_variadic_function : Error< "invalid prototype, variadic arguments are not allowed in OpenCL">; def err_opencl_requires_extension : Error< @@ -10148,7 +10147,7 @@ // OpenCL v3.0 s6.3.7 - Vector Components def ext_opencl_ext_vector_type_rgba_selector: ExtWarn< - "vector component name '%0' is an OpenCL C version 3.0 feature">, + "vector component name '%0' is a feature from OpenCL version 3.0 onwards">, InGroup; def err_openclcxx_placement_new : Error< Index: clang/include/clang/Basic/LangOptions.h =================================================================== --- clang/include/clang/Basic/LangOptions.h +++ clang/include/clang/Basic/LangOptions.h @@ -428,6 +428,10 @@ /// Return the OpenCL C or C++ version as a VersionTuple. VersionTuple getOpenCLVersionTuple() const; + /// Return the OpenCL C or C++ for OpenCL language name and version + /// as a string. + std::string getOpenCLVersionString() const; + /// Check if return address signing is enabled. bool hasSignReturnAddress() const { return getSignReturnAddressScope() != SignReturnAddressScopeKind::None; Index: clang/lib/Basic/LangOptions.cpp =================================================================== --- clang/lib/Basic/LangOptions.cpp +++ clang/lib/Basic/LangOptions.cpp @@ -48,6 +48,16 @@ return VersionTuple(Ver / 100, (Ver % 100) / 10); } +std::string LangOptions::getOpenCLVersionString() const { + std::string Result; + { + llvm::raw_string_ostream Out(Result); + Out << (OpenCLCPlusPlus ? "C++ for OpenCL" : "OpenCL C") << " version " + << getOpenCLVersionTuple().getAsString(); + } + return Result; +} + FPOptions FPOptions::defaultWithoutTrailingStorage(const LangOptions &LO) { FPOptions result(LO); return result; Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -503,9 +503,10 @@ // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0. // This option should be deprecated for CL > 1.0 because // this option was added for compatibility with OpenCL 1.0. - if (Args.getLastArg(OPT_cl_strict_aliasing) && LangOpts.OpenCLVersion > 100) + if (Args.getLastArg(OPT_cl_strict_aliasing) && + (LangOpts.OpenCLCPlusPlus || LangOpts.OpenCLVersion > 100)) Diags.Report(diag::warn_option_invalid_ocl_version) - << LangOpts.getOpenCLVersionTuple().getAsString() + << LangOpts.getOpenCLVersionString() << Args.getLastArg(OPT_cl_strict_aliasing)->getAsString(Args); if (Arg *A = Args.getLastArg(OPT_fdefault_calling_conv_EQ)) { Index: clang/lib/Parse/ParseDecl.cpp =================================================================== --- clang/lib/Parse/ParseDecl.cpp +++ clang/lib/Parse/ParseDecl.cpp @@ -4138,9 +4138,8 @@ << FixItHint::CreateRemoval( SourceRange(Loc, DS.getEndLoc())); else if (DiagID == diag::err_opencl_unknown_type_specifier) { - Diag(Loc, DiagID) << getLangOpts().OpenCLCPlusPlus - << getLangOpts().getOpenCLVersionTuple().getAsString() - << PrevSpec << isStorageClass; + Diag(Loc, DiagID) << getLangOpts().getOpenCLVersionString() << PrevSpec + << isStorageClass; } else Diag(Loc, DiagID) << PrevSpec; } Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -7327,10 +7327,9 @@ DeclSpec::TSCS TSC = D.getDeclSpec().getThreadStorageClassSpec(); if (TSC != TSCS_unspecified) { - bool IsCXX = getLangOpts().OpenCLCPlusPlus; Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(), diag::err_opencl_unknown_type_specifier) - << IsCXX << getLangOpts().getOpenCLVersionTuple().getAsString() + << getLangOpts().getOpenCLVersionString() << DeclSpec::getSpecifierName(TSC) << 1; NewVD->setInvalidDecl(); } Index: clang/lib/Sema/SemaDeclAttr.cpp =================================================================== --- clang/lib/Sema/SemaDeclAttr.cpp +++ clang/lib/Sema/SemaDeclAttr.cpp @@ -7369,12 +7369,12 @@ } static void handleOpenCLNoSVMAttr(Sema &S, Decl *D, const ParsedAttr &AL) { - if (S.LangOpts.OpenCLVersion != 200) + if (S.LangOpts.OpenCLVersion < 200 && !S.LangOpts.OpenCLCPlusPlusVersion) S.Diag(AL.getLoc(), diag::err_attribute_requires_opencl_version) - << AL << "2.0" << 0; + << AL << "2.0" << 1; else - S.Diag(AL.getLoc(), diag::warn_opencl_attr_deprecated_ignored) << AL - << "2.0"; + S.Diag(AL.getLoc(), diag::warn_opencl_attr_deprecated_ignored) + << AL << S.LangOpts.getOpenCLVersionString(); } static void handleOpenCLAccessAttr(Sema &S, Decl *D, const ParsedAttr &AL) { Index: clang/test/Frontend/opencl.cl =================================================================== --- clang/test/Frontend/opencl.cl +++ clang/test/Frontend/opencl.cl @@ -2,7 +2,7 @@ // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -DSYNTAX // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -DSYNTAX // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.0 -DSYNTAX -// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=clc++ -DSYNTAX +// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=clc++1.0 -DSYNTAX // RUN: %clang_cc1 %s -verify -fsyntax-only -fblocks -DBLOCKS -DSYNTAX // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -fblocks -DBLOCKS -DSYNTAX // RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -fblocks -DBLOCKS -DSYNTAX @@ -10,6 +10,7 @@ // RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s // RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s // RUN: %clang_cc1 -cl-std=CL2.0 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION20 %s +// RUN: %clang_cc1 -cl-std=clc++1.0 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCLCPP-VERSION10 %s #ifdef SYNTAX class test{ @@ -30,6 +31,7 @@ // expected-error@-6{{blocks support disabled - compile with -fblocks or pick a deployment target that supports them}} #endif -// CHECK-INVALID-OPENCL-VERSION11: warning: OpenCL version 1.1 does not support the option '-cl-strict-aliasing' -// CHECK-INVALID-OPENCL-VERSION12: warning: OpenCL version 1.2 does not support the option '-cl-strict-aliasing' -// CHECK-INVALID-OPENCL-VERSION20: warning: OpenCL version 2.0 does not support the option '-cl-strict-aliasing' +// CHECK-INVALID-OPENCL-VERSION11: warning: OpenCL C version 1.1 does not support the option '-cl-strict-aliasing' +// CHECK-INVALID-OPENCL-VERSION12: warning: OpenCL C version 1.2 does not support the option '-cl-strict-aliasing' +// CHECK-INVALID-OPENCL-VERSION20: warning: OpenCL C version 2.0 does not support the option '-cl-strict-aliasing' +// CHECK-INVALID-OPENCLCPP-VERSION10: warning: C++ for OpenCL version 1.0 does not support the option '-cl-strict-aliasing' Index: clang/test/SemaOpenCL/ext_vectors.cl =================================================================== --- clang/test/SemaOpenCL/ext_vectors.cl +++ clang/test/SemaOpenCL/ext_vectors.cl @@ -1,6 +1,7 @@ // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0 typedef float float4 __attribute__((ext_vector_type(4))); @@ -9,12 +10,12 @@ V = V.abgr; #if (__OPENCL_C_VERSION__ < 300) - // expected-warning@-2 {{vector component name 'a' is an OpenCL C version 3.0 feature}} + // expected-warning@-2 {{vector component name 'a' is a feature from OpenCL version 3.0 onwards}} #endif V = V.xyzr; // expected-error@-1 {{illegal vector component name 'r'}} #if (__OPENCL_C_VERSION__ < 300) - // expected-warning@-3 {{vector component name 'r' is an OpenCL C version 3.0 feature}} + // expected-warning@-3 {{vector component name 'r' is a feature from OpenCL version 3.0 onwards}} #endif } Index: clang/test/SemaOpenCL/nosvm.cl =================================================================== --- clang/test/SemaOpenCL/nosvm.cl +++ clang/test/SemaOpenCL/nosvm.cl @@ -1,13 +1,16 @@ // RUN: %clang_cc1 -verify %s // RUN: %clang_cc1 -verify -cl-std=CL2.0 -D CL20 %s +// RUN: %clang_cc1 -verify -cl-std=clc++1.0 -D CLCPP10 %s // RUN: %clang_cc1 -verify -x c -D NOCL %s #ifndef NOCL kernel void f(__attribute__((nosvm)) global int* a); -#ifndef CL20 -// expected-error@-2 {{'nosvm' attribute requires OpenCL version 2.0}} +#if defined(CL20) +// expected-warning@-2 {{'nosvm' attribute is deprecated and ignored in OpenCL C version 2.0}} +#elif defined(CLCPP10) +// expected-warning@-4 {{'nosvm' attribute is deprecated and ignored in C++ for OpenCL version 1.0}} #else -// expected-warning@-4 {{'nosvm' attribute is deprecated and ignored in OpenCL version 2.0}} +// expected-error@-6 {{attribute 'nosvm' is supported in the OpenCL version 2.0 onwards}} #endif __attribute__((nosvm)) void g(); // expected-warning {{'nosvm' attribute only applies to variables}}