-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[Clang][Sema] Fix issue on requires expression with templated base class member function #85198
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// RUN: %clang_cc1 -std=c++20 -verify %s | ||
// RUN: %clang_cc1 -std=c++23 -verify %s | ||
// expected-no-diagnostics | ||
|
||
struct B { | ||
template <typename S> | ||
void foo(); | ||
|
||
void bar(); | ||
}; | ||
|
||
template <typename T, typename S> | ||
struct A : T { | ||
auto foo() { | ||
static_assert(requires { T::template foo<S>(); }); | ||
static_assert(requires { T::bar(); }); | ||
} | ||
}; | ||
|
||
int main() { | ||
A<B, double> a; | ||
a.foo(); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 don't really understand the change, can you better explain why this is the solution here?
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.
In require body, name resolving just lookup function name and don't check function parameter without function call(I think).
After add a parameter to
foo
, this code also compiles correctly without calling.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 I don't see how 'implicit object member function' is what we want there? It seems what we really want is 'in the context of a requires clause', right?
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.
Yeah, I think it's like this, just with the same name is enough.
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.
@erichkeane I am still feeling that we have no need to check whether the method has a explicit object parameter in require clause. In type requirement, checking nested member is enough(name resolution and parameter checking has already completed) and we don't need object argument since it isn't a function call.
It is only doing a function call that object parameter is required.
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 still dont think 'implictObjectMemberFunction' is the right thing here. Why does the fact that it is not a 'Explit Object Member Function' matter?
like:
??
Or static member functions? This solution just doesn't seem right to me, and your responses dont' make it more clear.
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.
Do you mean that checking whether
Method
is an implicit object function is redundant? After I removedllvm-project/clang/lib/Sema/SemaExpr.cpp
Lines 7723 to 7726 in 844b532
These testcases failed
llvm-project/clang/test/CXX/drs/dr3xx.cpp
Lines 1084 to 1095 in 844b532
llvm-project/clang/test/SemaTemplate/instantiate-using-decl.cpp
Lines 150 to 168 in 844b532
without diagnose. Or the checking shouldn't be placed at current position?
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.
And if only checking whether
Method
is a static method, we failed on:llvm-project/clang/test/CXX/drs/dr26xx.cpp
Lines 225 to 240 in ef9446b
Why does the fact that it is not a 'Explit Object Member Function' matter?
Because 'Explit Object Member Function' can be invoked with member pointer with an object as the parameter (like
S::h
). While object is required when invoked an 'implictObjectMemberFunction'.