return expr;
}
-/* Parse a `decltype' type. Returns the type.
+/* Parse a `decltype' type. Returns the type.
- simple-type-specifier:
+ decltype-specifier:
decltype ( expression )
- C++14 proposal:
+ C++14:
decltype ( auto ) */
static tree
tree expr = NULL_TREE;
- if (cxx_dialect >= cxx14
- && cp_lexer_next_token_is_keyword (parser->lexer, RID_AUTO))
- /* decltype (auto) */
- cp_lexer_consume_token (parser->lexer);
+ if (cp_lexer_next_token_is_keyword (parser->lexer, RID_AUTO)
+ && cp_lexer_nth_token_is (parser->lexer, 2, CPP_CLOSE_PAREN))
+ {
+ /* decltype (auto) */
+ cp_lexer_consume_token (parser->lexer);
+ if (cxx_dialect < cxx14)
+ {
+ error_at (start_token->location,
+ "%<decltype(auto)%> type specifier only available with "
+ "%<-std=c++14%> or %<-std=gnu++14%>");
+ expr = error_mark_node;
+ }
+ }
else
{
/* decltype (expression) */
--- /dev/null
+// PR c++/96103
+// { dg-do compile { target c++11_only } }
+
+decltype(auto) foo () { return 4; } // { dg-error ".decltype\\(auto\\). type specifier only available" }
+
+void
+bar ()
+{
+ decltype(auto) i = 0; // { dg-error ".decltype\\(auto\\). type specifier only available" }
+}