diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-10-27 20:34:22 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-10-27 20:34:22 +0000 |
commit | 5c75236a413ce94285a6d9470fda79a296b07e43 (patch) | |
tree | f056865d00ba272407bfaeb1a03725970a995574 | |
parent | dfefe43019aae091d1ad862e78c04d777520b90a (diff) | |
download | gcc-5c75236a413ce94285a6d9470fda79a296b07e43.tar.gz |
Backported from mainline
2017-10-04 Jakub Jelinek <jakub@redhat.com>
PR c++/82373
* error.c (dump_function_decl): If show_return, call dump_type_suffix
on the same return type dump_type_prefix has been called on.
* g++.dg/cpp1y/pr82373.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@254180 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/error.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1y/pr82373.C | 20 |
4 files changed, 37 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e9bdb60369b..3687757ee96 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2017-10-27 Jakub Jelinek <jakub@redhat.com> + + Backported from mainline + 2017-10-04 Jakub Jelinek <jakub@redhat.com> + + PR c++/82373 + * error.c (dump_function_decl): If show_return, call dump_type_suffix + on the same return type dump_type_prefix has been called on. + 2017-10-17 Nathan Sidwell <nathan@acm.org> PR c++/82560 diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 40a7eab4b9e..38bc0b2474a 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1531,6 +1531,7 @@ dump_function_decl (cxx_pretty_printer *pp, tree t, int flags) int do_outer_scope = ! (flags & TFF_UNQUALIFIED_NAME); tree exceptions; bool constexpr_p; + tree ret = NULL_TREE; flags &= ~(TFF_UNQUALIFIED_NAME | TFF_TEMPLATE_NAME); if (TREE_CODE (t) == TEMPLATE_DECL) @@ -1593,7 +1594,7 @@ dump_function_decl (cxx_pretty_printer *pp, tree t, int flags) && !DECL_DESTRUCTOR_P (t) && !deduction_guide_p (t)); if (show_return) { - tree ret = fndecl_declared_return_type (t); + ret = fndecl_declared_return_type (t); dump_type_prefix (pp, ret, flags); } @@ -1634,7 +1635,7 @@ dump_function_decl (cxx_pretty_printer *pp, tree t, int flags) } if (show_return) - dump_type_suffix (pp, TREE_TYPE (fntype), flags); + dump_type_suffix (pp, ret, flags); else if (deduction_guide_p (t)) { pp_cxx_ws_string (pp, "->"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4a37df1dca7..44709ed8d0f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2017-10-27 Jakub Jelinek <jakub@redhat.com> Backported from mainline + 2017-10-04 Jakub Jelinek <jakub@redhat.com> + + PR c++/82373 + * g++.dg/cpp1y/pr82373.C: New test. + 2017-09-21 Jakub Jelinek <jakub@redhat.com> PR sanitizer/81715 diff --git a/gcc/testsuite/g++.dg/cpp1y/pr82373.C b/gcc/testsuite/g++.dg/cpp1y/pr82373.C new file mode 100644 index 00000000000..8a2d75520fb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr82373.C @@ -0,0 +1,20 @@ +// PR c++/82373 +// { dg-do compile { target c++14 } } + +namespace N +{ + int (*fp)(int); + auto foo(int a) // { dg-message "In function 'auto N::foo\\(int\\)'" "" { target *-*-* } 0 } + { + if (a) + return fp; + return nullptr; // { dg-error "inconsistent deduction for auto return type: 'int \\(\\*\\)\\(int\\)' and then 'std::nullptr_t'" } */ + } +} +int (*fp2)(int); +auto bar(int a) // { dg-message "In function 'auto bar\\(int\\)'" "" { target *-*-* } 0 } +{ + if (a) + return fp2; + return nullptr; // { dg-error "inconsistent deduction for auto return type: 'int \\(\\*\\)\\(int\\)' and then 'std::nullptr_t'" } */ +} |