Skip to content

Commit

Permalink
Rename and reword the diagnostic; added a test for a warning
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Savonichev <andrew.savonichev@intel.com>
  • Loading branch information
Andrew Savonichev committed Dec 4, 2019
1 parent 72c9470 commit 746b5e0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
6 changes: 3 additions & 3 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -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<SyclStrict>, DefaultError;
def err_ivdep_duplicate_arg : Error<
"duplicate argument to 'ivdep'. attribute requires one or both of a safelen "
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */;
}

Expand Down
17 changes: 12 additions & 5 deletions clang/test/SemaSYCL/sycl-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit 746b5e0

Please sign in to comment.