-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The new testcase from P2308 crashed trying to expand 'this' without an object to refer to, because we stripped the TARGET_EXPR in create_template_parm_object. So let's leave it on for giving an error. gcc/cp/ChangeLog: * pt.cc (create_template_parm_object): Pass TARGET_EXPR to cxx_constant_value. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/nontype-class64.C: New test.
- Loading branch information
Showing
2 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 @@ | ||
// Testcase from P2308R1 | ||
// { dg-do compile { target c++20 } } | ||
|
||
template<auto n> struct B { /* ... */ }; | ||
B<5> b1; // OK, template parameter type is int | ||
B<'a'> b2; // OK, template parameter type is char | ||
B<2.5> b3; // OK, template parameter type is double | ||
B<void(0)> b4; // { dg-error "void" } | ||
|
||
template<int i> struct C { /* ... */ }; | ||
C<{ 42 }> c1; // OK | ||
|
||
struct J1 { | ||
J1 *self=this; | ||
}; | ||
B<J1{}> j1; // { dg-error "not a constant expression" } | ||
|
||
struct J2 { | ||
J2 *self=this; | ||
constexpr J2() {} | ||
constexpr J2(const J2&) {} | ||
}; | ||
B<J2{}> j2; // { dg-error "" } |