diff options
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 10 |
2 files changed, 16 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 48582ce..2b98a06 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-09-09 Marek Polacek <polacek@redhat.com> + + PR c++/84374 - diagnose invalid uses of decltype(auto). + * decl.c (grokdeclarator): Diagnose wrong usage of decltype(auto) in + a function declaration. + 2019-09-06 Nathan Sidwell <nathan@acm.org> PR c++/91125 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 88e2c3b..dfcd7b1 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -11681,6 +11681,16 @@ grokdeclarator (const cp_declarator *declarator, "allowed"); return error_mark_node; } + /* Only plain decltype(auto) is allowed. */ + if (tree a = type_uses_auto (type)) + { + if (AUTO_IS_DECLTYPE (a) && a != type) + { + error_at (typespec_loc, "%qT as type rather than " + "plain %<decltype(auto)%>", type); + return error_mark_node; + } + } if (ctype == NULL_TREE && decl_context == FIELD |