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
This commit is contained in:
parent
7e55f2d868
commit
96e768c3fe
@ -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.
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
21
gcc/testsuite/g++.dg/cpp2a/nontype-class11.C
Normal file
21
gcc/testsuite/g++.dg/cpp2a/nontype-class11.C
Normal file
@ -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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user