Skip to content

Conversation

uditagarwal97
Copy link
Contributor

No description provided.

@uditagarwal97 uditagarwal97 marked this pull request as ready for review August 22, 2025 17:49
@uditagarwal97 uditagarwal97 requested a review from a team as a code owner August 22, 2025 17:49
Comment on lines +25 to +41
// MSVC ignores [[deprecated]] attribute on namespace unless compiled with
// /W3 or above.
#ifdef _MSC_VER
#define __SYCLCOMPAT_STRINGIFY(x) #x
#define __SYCLCOMPAT_TOSTRING(x) __SYCLCOMPAT_STRINGIFY(x)

#define __SYCLCOMPAT_WARNING(msg) \
__pragma(message(__FILE__ \
"(" __SYCLCOMPAT_TOSTRING(__LINE__) "): warning: " msg))

__SYCLCOMPAT_WARNING("syclcompat is deprecated and the deprecation warnings "
"are ignored unless compiled with /W3 or above.")

#undef __SYCLCOMPAT_WARNING
#undef __SYCLCOMPAT_TOSTRING
#undef __SYCLCOMPAT_STRINGIFY
#endif
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized that this isn't of much help as SYCL headers are treated as system headers and warnings are suppressed from them. Another option is to use #warning instead of pragma but not all MSVC versions support #warning, as it's a C++23 feature.
@aelovikov-intel suggestions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how that's an issue: https://godbolt.org/z/YG75Kx5rE

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this Godbolt accurately describes our compilation toolchain. I was debugging the failure in the new test I added (sycl/test/syclcompat/warnings_deprecated_msvc.cpp) and that when I found that no warning is being thrown for MSVC. Instead of including the header via -fsycl, if I explicitly include the header -I, then the warning is thrown properly (so the problem isn't with macros).
I also saw that we faced the same problem in #6808 as well.
In clang driver, do you know if we explicitly suppress warnings from system headers somewhere?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What warning? On the namespace syclcompat? pragma message isn't a warning, just a message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline. The problem was with clang-cl's imitation of MSVC's option. See https://godbolt.org/z/96aG1K1G8 - clang-cl's interpretation of /external:W0 is different from that of MSVC and the clang-cl also disables pragma messages with /external:W0.
Also, clang-cl, unlike MSVC, do not ignore [[deprecated]] attribute and so, I've modified warnings_deprecated.cpp test to also run on windows.

Copy link
Contributor

@stdale-intel stdale-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, all is as expected

@uditagarwal97 uditagarwal97 merged commit c0f8a08 into sycl Aug 27, 2025
27 of 28 checks passed
@uditagarwal97 uditagarwal97 deleted the private/udit/syclcompat branch August 27, 2025 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants