From: Jakub Jelinek Date: Wed, 4 Oct 2017 16:15:36 +0000 (+0200) Subject: re PR c++/82373 (syntax error in error message) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=420db57431715a5aed988c5ba600c913dc779f0e;p=gcc.git re PR c++/82373 (syntax error in error message) 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. From-SVN: r253418 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b1eaaba5bc6..18e4b9997b6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-10-04 Jakub Jelinek + + 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-04 Jason Merrill PR c++/81525 - broken handling of auto in generic lambda. diff --git a/gcc/cp/error.c b/gcc/cp/error.c index e4071547091..7a98d2e3594 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1574,6 +1574,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) @@ -1636,7 +1637,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); } @@ -1677,7 +1678,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 eb9f5b88fe8..0153b3d0458 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-04 Jakub Jelinek + + PR c++/82373 + * g++.dg/cpp1y/pr82373.C: New test. + 2017-10-04 David Malcolm * gcc.dg/diagnostic-range-bad-called-object.c: Update expected 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'" } */ +}