diff options
author | Marek Polacek <polacek@redhat.com> | 2019-01-08 22:33:04 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2019-01-08 22:33:04 +0000 |
commit | 96e768c3fecf0f65af3f289293145d5740971e2a (patch) | |
tree | e33dfc612400316353e66c17b2cb536c3aa20a93 /gcc | |
parent | 7e55f2d86830d45cbad7cf19d58e4c675fd20579 (diff) | |
download | gcc-96e768c3fecf0f65af3f289293145d5740971e2a.zip gcc-96e768c3fecf0f65af3f289293145d5740971e2a.tar.gz gcc-96e768c3fecf0f65af3f289293145d5740971e2a.tar.bz2 |
PR c++/88538 - braced-init-list in template-argument-list.
* parser.c (cp_parser_template_argument): Handle braced-init-list when
in C++20.
* g++.dg/cpp2a/nontype-class11.C: New test.
From-SVN: r267741
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/parser.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp2a/nontype-class11.C | 21 |
4 files changed, 38 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f3b5dbe..91465da 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2019-01-08 Marek Polacek <polacek@redhat.com> + PR c++/88538 - braced-init-list in template-argument-list. + * parser.c (cp_parser_template_argument): Handle braced-init-list when + in C++20. + PR c++/88548 - this accepted in static member functions. * parser.c (cp_debug_parser): Adjust printing of local_variables_forbidden_p. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index ca75c01..f441943 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -17026,6 +17026,14 @@ cp_parser_template_argument (cp_parser* parser) argument = cp_parser_constant_expression (parser); else { + /* In C++20, we can encounter a braced-init-list. */ + if (cxx_dialect >= cxx2a + && cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) + { + bool expr_non_constant_p; + return cp_parser_braced_list (parser, &expr_non_constant_p); + } + /* With C++17 generalized non-type template arguments we need to handle lvalue constant expressions, too. */ argument = cp_parser_assignment_expression (parser); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 634111b..f7b37d9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-08 Marek Polacek <polacek@redhat.com> + + PR c++/88538 - braced-init-list in template-argument-list. + * g++.dg/cpp2a/nontype-class11.C: New test. + 2019-01-08 Jakub Jelinek <jakub@redhat.com> PR target/88457 diff --git a/gcc/testsuite/g++.dg/cpp2a/nontype-class11.C b/gcc/testsuite/g++.dg/cpp2a/nontype-class11.C new file mode 100644 index 0000000..8a06d23 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/nontype-class11.C @@ -0,0 +1,21 @@ +// PR c++/88538 +// { dg-do compile { target c++2a } } + +struct S { + unsigned a; + unsigned b; + constexpr S(unsigned _a, unsigned _b) noexcept: a{_a}, b{_b} { } +}; + +template <S p> +void fnc() +{ +} + +template<S s> struct X { }; + +void f() +{ + fnc<{10,20}>(); + X<{1, 2}> x; +} |