Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Add test for Class Template Argument Deduction
Browse files Browse the repository at this point in the history
CTAD is already used in Rebirth code.  Add a test to reject compilers
which do not support it.  Include in the test a construct known to cause
gcc-11 to reject the code, since that construct already exists in the
game code, and thus gcc-11 cannot compile the game.  This test forces
a build using gcc-11 to fail early, at the configure stage, rather than
only failing when it reaches the header that uses a user defined
deduction guide for an inner class.
  • Loading branch information
vLKp committed Mar 17, 2024
1 parent 65ae3b0 commit b5ca993
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,33 @@ class ConfigureTests(_ConfigureTests):
__python_import_struct = None
_cxx_conformance_cxx20 = 20
__cxx_std_required_features = CxxRequiredFeatures([
# As of this writing, <gcc-12 is already unsupported, but some
# platforms, such as Ubuntu 22.04, still try to use gcc-11 by default.
# Use this test both to verify that Class Template Argument Deduction
# is generally supported, since it is used in the game, and to exclude
# an unsupported compiler that does not accept CTAD in one of the
# contexts the game uses.
Cxx20RequiredFeature('class template argument deduction', '''
struct Outer_%(N)s
{
template <typename byte_type>
struct Inner
{
constexpr Inner(byte_type &)
{
}
};
/* <gcc-12 does not allow declaring a deduction guide in the immediately
* enclosing scope:
```
error: deduction guide 'Outer_test_class_20template_20argument
_20deduction::Inner(byte_type&) -> Outer_test_class_20template_20argument_20deduction::Inner<byte_type>' must be declared at namespace scope
```
*/
template <typename byte_type>
Inner(byte_type &) -> Inner<byte_type>;
};
'''),
Cxx20RequiredFeature('explicitly defaulted operator==', '''
struct A_%(N)s
{
Expand Down

0 comments on commit b5ca993

Please sign in to comment.