From e41dad060b771814572d1481459c0b6912dafa67 Mon Sep 17 00:00:00 2001 From: "srividya.sundaram" Date: Mon, 2 Nov 2020 19:46:47 -0800 Subject: [PATCH 1/3] [SYCL]Remove warning about SYCL_EXTERNAL with pointers --- clang/include/clang/Basic/DiagnosticSemaKinds.td | 5 ----- clang/lib/Sema/SemaDeclAttr.cpp | 9 --------- clang/test/SemaSYCL/restrict-recursion3.cpp | 1 - clang/test/SemaSYCL/restrict-recursion4.cpp | 1 - clang/test/SemaSYCL/sycl-device.cpp | 12 ++++-------- 5 files changed, 4 insertions(+), 24 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 2de36ff88607d..4604a71d2f0a5 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -11131,11 +11131,6 @@ def warn_sycl_pass_by_value_deprecated def warn_sycl_pass_by_reference_future : Warning<"Passing of kernel functions by reference is a SYCL 2020 extension">, InGroup, ShowInSystemHeader; -def warn_sycl_attibute_function_raw_ptr - : Warning<"SYCL 1.2.1 specification does not allow %0 attribute applied " - "to a function with a raw pointer " - "%select{return type|parameter type}1">, - InGroup, DefaultError; def warn_sycl_implicit_decl : Warning<"SYCL 1.2.1 specification requires an explicit forward " "declaration for a kernel type name; your program may not " diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 4a979613abdf6..d37c7be676177 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -4539,15 +4539,6 @@ static void handleSYCLDeviceAttr(Sema &S, Decl *D, const ParsedAttr &AL) { S.Diag(AL.getLoc(), diag::err_sycl_attibute_cannot_be_applied_here) << AL; return; } - if (FD->getReturnType()->isPointerType()) { - 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_function_raw_ptr) - << AL << 1 /* function with a raw pointer parameter type */; - } handleSimpleAttribute(S, D, AL); } diff --git a/clang/test/SemaSYCL/restrict-recursion3.cpp b/clang/test/SemaSYCL/restrict-recursion3.cpp index f5289b3142e2b..49bd39e90ae28 100644 --- a/clang/test/SemaSYCL/restrict-recursion3.cpp +++ b/clang/test/SemaSYCL/restrict-recursion3.cpp @@ -16,7 +16,6 @@ using myFuncDef = int(int, int); typedef __typeof__(sizeof(int)) size_t; -// expected-warning@+1 {{SYCL 1.2.1 specification does not allow 'sycl_device' attribute applied to a function with a raw pointer return type}} SYCL_EXTERNAL void *operator new(size_t); diff --git a/clang/test/SemaSYCL/restrict-recursion4.cpp b/clang/test/SemaSYCL/restrict-recursion4.cpp index dde093792cf26..3d4d73e47a5bb 100644 --- a/clang/test/SemaSYCL/restrict-recursion4.cpp +++ b/clang/test/SemaSYCL/restrict-recursion4.cpp @@ -18,7 +18,6 @@ using myFuncDef = int(int, int); typedef __typeof__(sizeof(int)) size_t; -// expected-warning@+1 {{SYCL 1.2.1 specification does not allow 'sycl_device' attribute applied to a function with a raw pointer return type}} SYCL_EXTERNAL void *operator new(size_t); diff --git a/clang/test/SemaSYCL/sycl-device.cpp b/clang/test/SemaSYCL/sycl-device.cpp index 131b038b220a6..61e5e313d1fc0 100644 --- a/clang/test/SemaSYCL/sycl-device.cpp +++ b/clang/test/SemaSYCL/sycl-device.cpp @@ -41,17 +41,13 @@ int* func3() { return nullptr; } __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)) 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 *) {} +__attribute__((sycl_device)) void func3(int *) {} #else -__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)) 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}} -void func3(int *) {} +__attribute__((sycl_device)) void func3(int *) {} #endif #else // NO_SYCL From e0d9bdaa97d130531008e87a9673d2a19d4d9f1b Mon Sep 17 00:00:00 2001 From: "srividya.sundaram" Date: Tue, 3 Nov 2020 09:18:46 -0800 Subject: [PATCH 2/3] Remove unwanted defines and run commands --- clang/test/SemaSYCL/sycl-device.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/clang/test/SemaSYCL/sycl-device.cpp b/clang/test/SemaSYCL/sycl-device.cpp index 61e5e313d1fc0..09f743f1bd604 100644 --- a/clang/test/SemaSYCL/sycl-device.cpp +++ b/clang/test/SemaSYCL/sycl-device.cpp @@ -1,9 +1,6 @@ // RUN: %clang_cc1 -fsycl -fsycl-is-device -fsyntax-only -verify %s // RUN: %clang_cc1 -verify -DNO_SYCL %s -// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsyntax-only -verify -DNOT_STRICT -Wno-error=sycl-strict -Wno-sycl-strict %s -// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsyntax-only -verify -DWARN_STRICT -Wno-error=sycl-strict %s - #ifndef NO_SYCL __attribute__((sycl_device)) // expected-warning {{'sycl_device' attribute only applies to functions}} @@ -34,21 +31,17 @@ class B { __attribute__((sycl_device)) virtual void bar() = 0; }; -#if defined(NOT_STRICT) -__attribute__((sycl_device)) -int* func3() { return nullptr; } +__attribute__((sycl_device)) int *func0() { return nullptr; } -__attribute__((sycl_device)) -void func3(int *) {} -#elif defined(WARN_STRICT) -__attribute__((sycl_device)) int *func3() { return nullptr; } +__attribute__((sycl_device)) void func2(int *) {} -__attribute__((sycl_device)) void func3(int *) {} -#else __attribute__((sycl_device)) int *func3() { return nullptr; } -__attribute__((sycl_device)) void func3(int *) {} -#endif +__attribute__((sycl_device)) void func4(int *) {} + +__attribute__((sycl_device)) int *func5() { return nullptr; } + +__attribute__((sycl_device)) void func6(int *) {} #else // NO_SYCL __attribute__((sycl_device)) // expected-warning {{'sycl_device' attribute ignored}} From c4324818656e725b3f4b538a0ba7d06e9f985917 Mon Sep 17 00:00:00 2001 From: "srividya.sundaram" Date: Tue, 3 Nov 2020 10:26:51 -0800 Subject: [PATCH 3/3] Remove duplicate test cases --- clang/test/SemaSYCL/sycl-device.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/clang/test/SemaSYCL/sycl-device.cpp b/clang/test/SemaSYCL/sycl-device.cpp index 09f743f1bd604..48681606ebb75 100644 --- a/clang/test/SemaSYCL/sycl-device.cpp +++ b/clang/test/SemaSYCL/sycl-device.cpp @@ -35,14 +35,6 @@ __attribute__((sycl_device)) int *func0() { return nullptr; } __attribute__((sycl_device)) void func2(int *) {} -__attribute__((sycl_device)) int *func3() { return nullptr; } - -__attribute__((sycl_device)) void func4(int *) {} - -__attribute__((sycl_device)) int *func5() { return nullptr; } - -__attribute__((sycl_device)) void func6(int *) {} - #else // NO_SYCL __attribute__((sycl_device)) // expected-warning {{'sycl_device' attribute ignored}} void baz() {}