-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang] Track function template instantiation from definition #110387
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
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
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
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,101 @@ | ||
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++26 %s | ||
mizvekov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
namespace t1 { | ||
template<int N> struct A { | ||
template<class C> friend auto cica(const A<N-1>&, C) { | ||
return N; | ||
} | ||
}; | ||
|
||
template<> struct A<0> { | ||
template<class C> friend auto cica(const A<0>&, C); | ||
// expected-note@-1 {{declared here}} | ||
}; | ||
|
||
void test() { | ||
cica(A<0>{}, 0); | ||
// expected-error@-1 {{function 'cica<int>' with deduced return type cannot be used before it is defined}} | ||
|
||
(void)A<1>{}; | ||
cica(A<0>{}, 0); | ||
} | ||
} // namespace t1 | ||
namespace t2 { | ||
template<int N> struct A { | ||
template<class C> friend auto cica(const A<N-1>&, C) { | ||
return N; | ||
} | ||
}; | ||
|
||
template<> struct A<0> { | ||
template<class C> friend auto cica(const A<0>&, C); | ||
}; | ||
|
||
template <int N, class = decltype(cica(A<N>{}, nullptr))> | ||
void MakeCica(); | ||
// expected-note@-1 {{candidate function}} | ||
|
||
template <int N> void MakeCica(A<N+1> = {}); | ||
// expected-note@-1 {{candidate function}} | ||
|
||
void test() { | ||
MakeCica<0>(); | ||
|
||
MakeCica<0>(); | ||
// expected-error@-1 {{call to 'MakeCica' is ambiguous}} | ||
} | ||
} // namespace t2 | ||
namespace t3 { | ||
template<int N> struct A { | ||
template<class C> friend auto cica(const A<N-1>&, C) { | ||
return N-1; | ||
} | ||
}; | ||
|
||
template<> struct A<0> { | ||
template<class C> friend auto cica(const A<0>&, C); | ||
}; | ||
|
||
template <int N, class AT, class = decltype(cica(AT{}, nullptr))> | ||
static constexpr bool MakeCica(int); | ||
|
||
template <int N, class AT> | ||
static constexpr bool MakeCica(short, A<N+1> = {}); | ||
|
||
template <int N, class AT = A<N>, class Val = decltype(MakeCica<N, AT>(0))> | ||
static constexpr bool has_cica = Val{}; | ||
|
||
constexpr bool cica2 = has_cica<0> || has_cica<0>; | ||
} // namespace t3 | ||
namespace t4 { | ||
template<int N> struct A { | ||
template<class C> friend auto cica(const A<N-1>&, C); | ||
}; | ||
|
||
template<> struct A<0> { | ||
template<class C> friend auto cica(const A<0>&, C) { | ||
C a; | ||
} | ||
}; | ||
|
||
template struct A<1>; | ||
|
||
void test() { | ||
cica(A<0>{}, 0); | ||
} | ||
} // namespace t4 | ||
namespace regression1 { | ||
template <class> class A; | ||
|
||
template <class T> [[gnu::abi_tag("TAG")]] void foo(A<T>); | ||
|
||
template <class> struct A { | ||
friend void foo <>(A); | ||
}; | ||
|
||
template struct A<int>; | ||
|
||
template <class T> [[gnu::abi_tag("TAG")]] void foo(A<T>) {} | ||
|
||
template void foo<int>(A<int>); | ||
} // namespace regression1 |
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.
Uh oh!
There was an error while loading. Please reload this page.