From 746b5e04ca934746700395d224467752cda1566b Mon Sep 17 00:00:00 2001 From: Andrew Savonichev Date: Wed, 4 Dec 2019 18:02:45 +0300 Subject: [PATCH] Rename and reword the diagnostic; added a test for a warning Signed-off-by: Andrew Savonichev --- .../include/clang/Basic/DiagnosticSemaKinds.td | 6 +++--- clang/lib/Sema/SemaDeclAttr.cpp | 4 ++-- clang/test/SemaSYCL/sycl-device.cpp | 17 ++++++++++++----- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index fc7be566f3f7c..21e355f6a1489 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -10121,10 +10121,10 @@ def err_sycl_attibute_cannot_be_applied_here : Error<"%0 attribute cannot be applied to a " "%select{static function or function in an anonymous namespace" "|class member function}1">; -def warn_sycl_attibute_address_space_ext +def warn_sycl_attibute_function_raw_ptr : Warning<"SYCL 1.2.1 specification does not allow %0 attribute applied " - "to a %select{function with a raw pointer return type" - "|function with a raw pointer parameter type}1">, + "to a function with a raw " + "%select{pointer return type|pointer parameter type}1">, InGroup, DefaultError; def err_ivdep_duplicate_arg : Error< "duplicate argument to 'ivdep'. attribute requires one or both of a safelen " diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 1d8c29963c62f..d2ae66fda42f1 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -4329,12 +4329,12 @@ static void handleSYCLDeviceAttr(Sema &S, Decl *D, const ParsedAttr &AL) { return; } if (FD->getReturnType()->isPointerType()) { - S.Diag(AL.getLoc(), diag::warn_sycl_attibute_address_space_ext) + S.Diag(AL.getLoc(), diag::warn_sycl_attibute_function_raw_ptr) << AL << 0 /* function with a raw pointer return type */; } for (const ParmVarDecl *Param : FD->parameters()) if (Param->getType()->isPointerType()) { - S.Diag(AL.getLoc(), diag::warn_sycl_attibute_address_space_ext) + S.Diag(AL.getLoc(), diag::warn_sycl_attibute_function_raw_ptr) << AL << 1 /* function with a raw pointer parameter type */; } diff --git a/clang/test/SemaSYCL/sycl-device.cpp b/clang/test/SemaSYCL/sycl-device.cpp index ca41ad4fbe9f8..f889cb7447ede 100644 --- a/clang/test/SemaSYCL/sycl-device.cpp +++ b/clang/test/SemaSYCL/sycl-device.cpp @@ -2,6 +2,7 @@ // RUN: %clang_cc1 -verify -DNO_SYCL %s // RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify -DNOT_STRICT -Wno-error=sycl-strict -Wno-sycl-strict %s +// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify -DWARN_STRICT -Wno-error=sycl-strict %s #ifndef NO_SYCL @@ -27,17 +28,23 @@ class A { int func3() {} }; -#ifndef NOT_STRICT -__attribute__((sycl_device)) // expected-error {{SYCL 1.2.1 specification does not allow 'sycl_device' attribute applied to a function with a raw pointer return type}} +#if defined(NOT_STRICT) +__attribute__((sycl_device)) int* func3() { return nullptr; } -__attribute__((sycl_device)) // expected-error {{SYCL 1.2.1 specification does not allow 'sycl_device' attribute applied to a function with a raw pointer parameter type}} +__attribute__((sycl_device)) +void func3(int *) {} +#elif defined(WARN_STRICT) +__attribute__((sycl_device)) // expected-warning {{SYCL 1.2.1 specification does not allow 'sycl_device' attribute applied to a function with a raw pointer return type}} +int* func3() { return nullptr; } + +__attribute__((sycl_device)) // expected-warning {{SYCL 1.2.1 specification does not allow 'sycl_device' attribute applied to a function with a raw pointer parameter type}} void func3(int *) {} #else -__attribute__((sycl_device)) +__attribute__((sycl_device)) // expected-error {{SYCL 1.2.1 specification does not allow 'sycl_device' attribute applied to a function with a raw pointer return type}} int* func3() { return nullptr; } -__attribute__((sycl_device)) +__attribute__((sycl_device)) // expected-error {{SYCL 1.2.1 specification does not allow 'sycl_device' attribute applied to a function with a raw pointer parameter type}} void func3(int *) {} #endif