Skip to content

[SYCL] Ignore vec_type_hint attribute in SYCL 2020 #10619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -4031,6 +4031,7 @@ def VecTypeHint : InheritableAttr {
let Spellings = [GNU<"vec_type_hint">, CXX11<"sycl", "vec_type_hint">];
let Args = [TypeArgument<"TypeHint">];
let Subjects = SubjectList<[Function], ErrorDiag>;
let SupportsNonconformingLambdaSyntax = 1;
let Documentation = [Undocumented];
}

Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -11979,6 +11979,9 @@ def warn_ivdep_attribute_argument : Warning<
def warn_attribute_spelling_deprecated : Warning<
"attribute %0 is deprecated">,
InGroup<DeprecatedAttributes>;
def warn_attribute_deprecated_ignored : Warning<
"attribute %0 is deprecated; attribute ignored">,
InGroup<DeprecatedAttributes>;
def note_spelling_suggestion : Note<
"did you mean to use %0 instead?">;
def warn_attribute_requires_non_negative_integer_argument :
Expand Down
7 changes: 5 additions & 2 deletions clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4550,8 +4550,11 @@ static void handleSYCLIntelLoopFuseAttr(Sema &S, Decl *D, const ParsedAttr &A) {

static void handleVecTypeHint(Sema &S, Decl *D, const ParsedAttr &AL) {
// This attribute is deprecated without replacement in SYCL 2020 mode.
if (S.LangOpts.getSYCLVersion() > LangOptions::SYCL_2017)
S.Diag(AL.getLoc(), diag::warn_attribute_spelling_deprecated) << AL;
// Ignore the attribute in SYCL 2020.
if (S.LangOpts.getSYCLVersion() > LangOptions::SYCL_2017) {
S.Diag(AL.getLoc(), diag::warn_attribute_deprecated_ignored) << AL;
return;
}

// If the attribute is used with the [[sycl::vec_type_hint]] spelling in SYCL
// 2017 mode, we want to warn about using the newer name in the older
Expand Down
26 changes: 26 additions & 0 deletions clang/test/SemaSYCL/vec-type-hint-2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// RUN: %clang_cc1 -fsycl-is-device -sycl-std=2020 -internal-isystem %S/Inputs -fsyntax-only -verify %s

// Test which verifies [[sycl::vec_type_hint()]] is accepted
// with non-conforming lambda syntax.

// NOTE: This attribute is not supported in the SYCL backends.
// To be minimally conformant with SYCL2020, attribute is
// accepted by the Clang FE with a warning. No additional
// semantic handling or IR generation is done for this
// attribute.

#include "sycl.hpp"

struct test {};

using namespace sycl;
queue q;

void bar() {
q.submit([&](handler &h) {
h.single_task<class kernelname>(
// expected-warning@+1 {{attribute 'vec_type_hint' is deprecated; attribute ignored}}
[]() [[sycl::vec_type_hint(test)]] {});
});
}

2 changes: 1 addition & 1 deletion clang/test/SemaSYCL/vec-type-hint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

// __attribute__((vec_type_hint)) is deprecated without replacement in SYCL
// 2020 mode, but is allowed in SYCL 2017 and OpenCL modes.
KERNEL __attribute__((vec_type_hint(int))) void foo() {} // sycl-2020-warning {{attribute 'vec_type_hint' is deprecated}}
KERNEL __attribute__((vec_type_hint(int))) void foo() {} // sycl-2020-warning {{attribute 'vec_type_hint' is deprecated; attribute ignored}}