Repository navigation
Reject non-template members named by a template-id [GH #598] #597
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
Open
mbaluda
wants to merge
2
commits into
edgcpp:main
Choose a base branch
from
mbaluda:fix/dependent-member-template-address
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+86
−0
Open
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| [GH #598] | ||
| Dependent template-ids naming non-template members | ||
|
|
||
| Previously, when a dependent template-id named a non-template class member | ||
| or enumerator after substitution, the front end did not treat it as a | ||
| substitution failure. As a result, an overload that should have been | ||
| discarded could be selected, leading to a spurious error. For example, | ||
| with --c++11: | ||
|
|
||
| struct S { int f(); }; | ||
| template<typename T> int g(decltype(&T::template f<>)); | ||
| template<typename T> char g(...); | ||
| int x = sizeof(g<S>(0)); // Previously a spurious error, now okay. | ||
1 change: 1 addition & 0 deletions
1
tests/tests/regressions/.gh-598-dependent-member-template.rto/default.1.1.txt
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 @@ | ||
| fe_only -DTEST_NUMBER=1 --c++11 Test_name.c |
1 change: 1 addition & 0 deletions
1
tests/tests/regressions/.gh-598-dependent-member-template.rto/default.2.1.txt
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 @@ | ||
| fe_only -DTEST_NUMBER=2 --c++14 Test_name.c |
1 change: 1 addition & 0 deletions
1
tests/tests/regressions/.gh-598-dependent-member-template.rto/default.3.1.txt
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 @@ | ||
| fe_only -DTEST_NUMBER=3 --c++20 Test_name.c |
1 change: 1 addition & 0 deletions
1
tests/tests/regressions/.gh-598-dependent-member-template.rto/default.4.1.txt
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 @@ | ||
| fe_only -DTEST_NUMBER=4 --c++20 --gnu_version 150300 Test_name.c |
1 change: 1 addition & 0 deletions
1
tests/tests/regressions/.gh-598-dependent-member-template.rto/default.5.1.txt
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 @@ | ||
| fe_only -DTEST_NUMBER=5 --c++20 --clang_version 190100 Test_name.c |
1 change: 1 addition & 0 deletions
1
tests/tests/regressions/.gh-598-dependent-member-template.rto/default.6.1.txt
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 @@ | ||
| fe_only -DTEST_NUMBER=6 --ms_c++20 --microsoft_version 1950 Test_name.c |
57 changes: 57 additions & 0 deletions
57
tests/tests/regressions/gh-598-dependent-member-template.sft.cpp
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,57 @@ | ||
| //type:fp | ||
| //options:--c++11:--c++14:--c++20:--c++20 --gnu_version 150300:--c++20 --clang_version 190100:--ms_c++20 --microsoft_version 1950 | ||
|
|
||
| template<class...> using void_t = void; | ||
| template<class T, class = void> struct has_f { | ||
| static const bool value = false; | ||
| }; | ||
| template<class T> struct has_f<T, void_t<decltype(&T::template f<>)>> { | ||
| static const bool value = true; | ||
| }; | ||
|
|
||
| template<class T, class = void> struct has_call_f { | ||
| static const bool value = false; | ||
| }; | ||
| template<class T> struct has_call_f<T, void_t<decltype(T::template f<>(0))>> { | ||
| static const bool value = true; | ||
| }; | ||
|
|
||
| struct Plain { int f() const; }; | ||
| struct Generic { template<class = void> int f() const; }; | ||
| struct Overloaded { static int f(int); static int f(double); }; | ||
| struct OverloadedGeneric { | ||
| static int f(double); | ||
| template<class = void> static int f(int); | ||
| }; | ||
| struct Data { int f; }; | ||
| struct StaticData { static int f; }; | ||
|
|
||
| static_assert(!has_f<Plain>::value, ""); | ||
| static_assert(!has_f<Overloaded>::value, ""); | ||
| static_assert(!has_f<Data>::value, ""); | ||
| static_assert(!has_f<StaticData>::value, ""); | ||
| static_assert(has_f<Generic>::value, ""); | ||
| static_assert(has_f<OverloadedGeneric>::value, ""); | ||
| static_assert(!has_call_f<Overloaded>::value, ""); | ||
| static_assert(has_call_f<OverloadedGeneric>::value, ""); | ||
|
|
||
| #if __cpp_variable_templates >= 201304L | ||
| struct StaticGeneric { template<class = void> static int f; }; | ||
| static_assert(has_f<StaticGeneric>::value, ""); | ||
| #endif | ||
|
|
||
| #if __cpp_concepts >= 201907L | ||
| namespace N { | ||
| struct S {}; | ||
| template<typename = void> int f(S); | ||
| } | ||
| int f(); | ||
| template<typename T> auto g(T t) -> decltype(f<>(t)); | ||
| static_assert(sizeof(g(N::S{})) == sizeof(int)); | ||
|
|
||
| struct S { enum { E }; }; | ||
| enum class ScopedEnum { E }; | ||
| template<typename T> concept C = requires { T::template E<>; }; | ||
| static_assert(!C<S>); | ||
| static_assert(!C<ScopedEnum>); | ||
| #endif |
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.