aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2019-09-10 02:29:13 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2019-09-10 02:29:13 +0000
commit77df40e8127ec4f62c01c15f2d6f76d995424863 (patch)
tree822ee69b10dda22574ed61f738c3de26535abdc0 /gcc/cp/decl.c
parentfa412b7c52a8e023a16f853cc7f7efc7265b81ef (diff)
downloadgcc-77df40e8127ec4f62c01c15f2d6f76d995424863.zip
gcc-77df40e8127ec4f62c01c15f2d6f76d995424863.tar.gz
gcc-77df40e8127ec4f62c01c15f2d6f76d995424863.tar.bz2
PR c++/84374 - diagnose invalid uses of decltype(auto).
* decl.c (grokdeclarator): Diagnose wrong usage of decltype(auto) in a function declaration. * g++.dg/cpp1y/auto-fn57.C: New test. From-SVN: r275557
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c10
1 files changed, 10 insertions, 0 deletions
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