-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop] Don't crash when importing invalid decl. #35962
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
Conversation
@swift-ci please smoke test. |
@@ -0,0 +1,6 @@ | |||
template <class T> | |||
struct IsSubtypeSame { | |||
static constexpr const bool value = __is_same(typename T::type, int); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if the test could avoid using a built-in directly. Instead you can do something like (for example):
struct S {};
template <class T>
struct IsSubtypeSame {
static constexpr const S value = T();
};
using Invalid = IsSubtypeSame<int>;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, you got it to crash in a different way!
Anyway, I take your point. I'll try to re-write this test without using the builtin (and I'll submit another patch to fix the issue you exposed).
439d9df
to
32a875c
Compare
@swift-ci please smoke test. |
@swift-ci please smoke test macOS. |
Same error, but it doesn't seem related 😕 I'll give it one more try. @swift-ci please smoke test macOS. |
@swift-ci please smoke test macOS. |
1 similar comment
@swift-ci please smoke test macOS. |
32a875c
to
f89a6e5
Compare
@swift-ci please smoke test macOS. |
@swift-ci please test. |
Build failed |
Build failed |
@swift-ci please test. |
Build failed |
Build failed |
@swift-ci please test. |
1 similar comment
@swift-ci please test. |
Build failed |
@swift-ci please test macOS. |
test/Interop/Cxx/static/constexpr-static-member-var-errors.swift
Outdated
Show resolved
Hide resolved
It appears that Clang does not mark templates as invalid on Windows: https://godbolt.org/z/Mv5osj This means that we still crash on Windows because the compiler doesn't reject invalid decls. I added a special-case in |
f89a6e5
to
52fd808
Compare
|
||
// Clang does not properly mark decls as invalid on Windows, so we won't get an | ||
// error here. | ||
// XFAIL: OS=windows-msvc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I added a special-case so that we no longer crash on Windows, I still can't enable this test, because Clang won't generate an error on Windows. @varungandhi-apple do you think it would be a good idea for me to add an additional test that just ensures we don't crash when importing ConstexprStaticMemberVarErrors
(that would run on Windows)?
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@swift-ci please test macOS. |
Here's a link to the bug: https://llvm.org/PR49618 |
@swift-ci please test Windows. |
And here's the patch to fix this on Windows: https://reviews.llvm.org/D98904 |
52fd808
to
d675dab
Compare
@swift-ci please test. |
Build failed |
@swift-ci please test macOS. |
Build failed |
@swift-ci please test macOS. |
@swift-ci please test Windows. |
If we see an invalid decl, rather than potentially crashing, simply bail.
d675dab
to
794c0ea
Compare
@swift-ci please test Windows. |
@swift-ci please test macOS. |
@swift-ci please test Linux. |
If we see an invalid decl, rather than potentially crashing, simply bail.