From: Anastasia Stulova Date: Tue, 12 Mar 2019 12:46:56 +0000 (+0000) Subject: [PR41007][OpenCL] Allow printf in C++ mode. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=de668a55adaa1394e0aa9480617e452b30eeaaf6;p=clang [PR41007][OpenCL] Allow printf in C++ mode. As for OpenCL C, we need to allow using printf and toolchain variadic functions (prefixed by "__") in C++ mode. Differential Revision: https://reviews.llvm.org/D59219 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355915 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 3591add23d..62d9e3dc7f 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -4585,7 +4585,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, if (FTI.isVariadic && !(D.getIdentifier() && ((D.getIdentifier()->getName() == "printf" && - LangOpts.OpenCLVersion >= 120) || + (LangOpts.OpenCLCPlusPlus || LangOpts.OpenCLVersion >= 120)) || D.getIdentifier()->getName().startswith("__")))) { S.Diag(D.getIdentifierLoc(), diag::err_opencl_variadic_function); D.setInvalidType(true); diff --git a/test/SemaOpenCL/extensions.cl b/test/SemaOpenCL/extensions.cl index e9dba69ecd..3a0bb5f2e0 100644 --- a/test/SemaOpenCL/extensions.cl +++ b/test/SemaOpenCL/extensions.cl @@ -28,7 +28,7 @@ // enabled by default with -cl-std=CL2.0). // // RUN: %clang_cc1 %s -triple amdgcn-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL2.0 -finclude-default-header -// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=c++ +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=c++ -finclude-default-header #ifdef _OPENCL_H_ // expected-no-diagnostics