Commit eedaaaf7 by Jason Merrill Committed by Jason Merrill

PR c++/71569 - decltype of template.

	* parser.c (cp_parser_decltype_expr): Handle missing template args.

From-SVN: r258110
parent 90abdde0
2018-03-01 Jason Merrill <jason@redhat.com>
PR c++/71569 - decltype of template.
* parser.c (cp_parser_decltype_expr): Handle missing template args.
2018-03-01 Marek Polacek <polacek@redhat.com>
PR c++/84596
......
......@@ -13983,6 +13983,10 @@ cp_parser_decltype_expr (cp_parser *parser,
expr = cp_parser_lookup_name_simple (parser, expr,
id_expr_start_token->location);
if (expr && TREE_CODE (expr) == TEMPLATE_DECL)
/* A template without args is not a complete id-expression. */
expr = error_mark_node;
if (expr
&& expr != error_mark_node
&& TREE_CODE (expr) != TYPE_DECL
......@@ -14048,6 +14052,9 @@ cp_parser_decltype_expr (cp_parser *parser,
expression. */
cp_parser_abort_tentative_parse (parser);
/* Commit to the tentative_firewall so we get syntax errors. */
cp_parser_commit_to_tentative_parse (parser);
/* Parse a full expression. */
expr = cp_parser_expression (parser, /*pidk=*/NULL, /*cast_p=*/false,
/*decltype_p=*/true);
......@@ -2,6 +2,6 @@
// PR c++/33837
void foo()
{
__decltype (A::foo()); // { dg-error "was not declared|expected" }
__decltype (B); // { dg-error "was not declared" }
__decltype (A::foo()); // { dg-error "A" }
__decltype (B); // { dg-error "B" }
}
......@@ -22,6 +22,6 @@ struct B
int main()
{
int x = B<decltype(A<int>::a(1))>::b(A<int>::a(1));
int y = B<decltype(A ::a(2))>::b(A<int>::a(2)); // { dg-error "template argument" }
int y = B<decltype(A ::a(2))>::b(A<int>::a(2)); // { dg-error "template" }
return x + y;
}
// PR c++/71569
// { dg-do compile { target c++14 } }
template <class T>
struct A {
template <class U>
static U u;
};
int main()
{
decltype(A<int>::u) a; // { dg-error "missing template arguments" }
return a;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment