aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2008-10-31 22:33:47 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2008-10-31 22:33:47 +0100
commit4f48b9c1a5fa185bf85768d4748de3077d503a53 (patch)
tree2c499200514eac0068bd5944e2a21587fe24c3ff /gcc/cp/decl.c
parent0a3098bba15a5f03c017683cad6aa81427865d00 (diff)
downloadgcc-4f48b9c1a5fa185bf85768d4748de3077d503a53.zip
gcc-4f48b9c1a5fa185bf85768d4748de3077d503a53.tar.gz
gcc-4f48b9c1a5fa185bf85768d4748de3077d503a53.tar.bz2
re PR c++/37967 (ICE with function returning auto)
PR c++/37967 * decl.c (grokdeclarator): Diagnose auto function decl without late return type and late return type function decl where type is not auto. * g++.dg/cpp0x/auto8.C: New test. From-SVN: r141502
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 091edd5..754f433 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -8237,16 +8237,40 @@ grokdeclarator (const cp_declarator *declarator,
/* Pick up the exception specifications. */
raises = declarator->u.function.exception_specification;
+ /* Say it's a definition only for the CALL_EXPR
+ closest to the identifier. */
+ funcdecl_p = inner_declarator && inner_declarator->kind == cdk_id;
+
/* Handle a late-specified return type. */
+ if (funcdecl_p)
+ {
+ if (type_uses_auto (type))
+ {
+ if (!declarator->u.function.late_return_type)
+ {
+ error ("%qs function uses auto type specifier without"
+ " late return type", name);
+ return error_mark_node;
+ }
+ else if (!is_auto (type))
+ {
+ error ("%qs function with late return type not using"
+ " auto type specifier as its type", name);
+ return error_mark_node;
+ }
+ }
+ else if (declarator->u.function.late_return_type)
+ {
+ error ("%qs function with late return type not declared"
+ " with auto type specifier", name);
+ return error_mark_node;
+ }
+ }
type = splice_late_return_type
(type, declarator->u.function.late_return_type);
if (type == error_mark_node)
return error_mark_node;
- /* Say it's a definition only for the CALL_EXPR
- closest to the identifier. */
- funcdecl_p = inner_declarator && inner_declarator->kind == cdk_id;
-
if (ctype == NULL_TREE
&& decl_context == FIELD
&& funcdecl_p