-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] IsDerivedFromInclusive expects a compelete type in the presence of attribute add_ir_attributes_global_variable. #15897
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
@@ -776,6 +777,8 @@ static AccessResult HasAccess(Sema &S, | |||
// [B3] and [M3] | |||
} else { | |||
assert(Access == AS_protected); | |||
if (!ECRecord->getDefinition()) |
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.
Should these changes be made in community clang? This doesn't seem SYCL specific
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.
I have tried but I there is no upstream class attribute that accepts an arbitrary expression. Couldn't find a test case that crashes. The closest one I could find is https://godbolt.org/z/qxEjjvf73 , but it doesn't crash. It returns the expected error.
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.
When is ECRecord
not defined here? And why is this restriction only required for protected
access?
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.
When is ECRecord not defined here?
This function is checking if the entity is accessible with the specific AccessSpecifier
. If it's protected
then we need to make sure that the type is complete. A type is incomplete if !getDefinition()
.
When is
ECRecord
not defined here? And why is this restriction only required forprotected
access?
Please see comments at line 858 concerning [M3] and [B3].
IsDerivedFromInclusive
checks whether a class is derived from another class. The question is, should IsDerivedFromInclusive
have a precondition on Derived
being a complete type. I think it should. See https://eel.is/c++draft/class.derived 2.
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.
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.
Thanks for explaining.
ping? |
@@ -301,6 +301,7 @@ static AccessResult IsDerivedFromInclusive(const CXXRecordDecl *Derived, | |||
const CXXRecordDecl *Target) { | |||
assert(Derived->getCanonicalDecl() == Derived); | |||
assert(Target->getCanonicalDecl() == Target); | |||
assert(Derived->getDefinition() && "Expecting a complete type"); |
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.
I guess this is because types need to be complete to determine inheritance hierarchy? @AaronBallman can you confirm this?
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.
That's correct.
@@ -776,6 +777,8 @@ static AccessResult HasAccess(Sema &S, | |||
// [B3] and [M3] | |||
} else { | |||
assert(Access == AS_protected); | |||
if (!ECRecord->getDefinition()) |
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.
When is ECRecord
not defined here? And why is this restriction only required for protected
access?
|
@@ -776,6 +777,8 @@ static AccessResult HasAccess(Sema &S, | |||
// [B3] and [M3] | |||
} else { | |||
assert(Access == AS_protected); | |||
if (!ECRecord->getDefinition()) |
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.
Thanks for explaining.
@intel/llvm-gatekeepers Can this be merged in please? Thanks. |
This test is crashing the compiler.
struct A {
protected:
static constexpr const char *ir_attribute_name = "";
static constexpr auto ir_attribute_value = nullptr;
};
template <typename Ts>
struct [[__sycl_detail__::add_ir_attributes_global_variable(
Ts::ir_attribute_name, Ts::ir_attribute_value)]] B {
};
B<A> v;
When a class attribute accepts an arbitrary expression, the underlying class needs to be a complete type.