aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2020-06-24 17:39:21 -0400
committerMarek Polacek <polacek@redhat.com>2020-07-14 09:35:53 -0400
commit9eb370f19c1198e62d47eae74531e54d0b098bf1 (patch)
treeaaf53785b7e57c6bb431eb9deefeedf24e4d30e7 /gcc/expr.c
parentbf567bb3b3cb43e299e947bbdfa00da416de0890 (diff)
downloadgcc-9eb370f19c1198e62d47eae74531e54d0b098bf1.zip
gcc-9eb370f19c1198e62d47eae74531e54d0b098bf1.tar.gz
gcc-9eb370f19c1198e62d47eae74531e54d0b098bf1.tar.bz2
c++: Improve checking of decls with trailing return type [PR95820]
This is an ICE-on-invalid but I've been seeing it when reducing various testcases, so it's more important for me than usually. splice_late_return_type now checks that if we've seen a late return type, the function return type was auto. That's a fair assumption but grokdeclarator/cdk_function wasn't giving errors for function pointers and similar. So we want to perform various checks not only when funcdecl_p || inner_declarator == NULL. But only give the !late_return_type errors when funcdecl_p, to accept e.g. auto (*fp)() = f; in C++11. Here's a diff -w to ease the review: --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -12102,14 +12102,9 @@ grokdeclarator (const cp_declarator *declarator, /* Handle a late-specified return type. */ tree late_return_type = declarator->u.function.late_return_type; - if (funcdecl_p - /* This is the case e.g. for - using T = auto () -> int. */ - || inner_declarator == NULL) - { if (tree auto_node = type_uses_auto (type)) { - if (!late_return_type) + if (!late_return_type && funcdecl_p) { if (current_class_type && LAMBDA_TYPE_P (current_class_type)) @@ -12201,7 +12196,6 @@ grokdeclarator (const cp_declarator *declarator, "type specifier", name); return error_mark_node; } - } type = splice_late_return_type (type, late_return_type); if (type == error_mark_node) return error_mark_node; gcc/cp/ChangeLog: PR c++/95820 * decl.c (grokdeclarator) <case cdk_function>: Check also pointers/references/... to functions. gcc/testsuite/ChangeLog: PR c++/95820 * g++.dg/cpp1y/auto-fn58.C: New test.
Diffstat (limited to 'gcc/expr.c')
0 files changed, 0 insertions, 0 deletions