backport: re PR c++/82373 (syntax error in error message)

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.

From-SVN: r254180
This commit is contained in:
Jakub Jelinek 2017-10-27 22:34:22 +02:00 committed by Jakub Jelinek
parent d84264fb75
commit 02a55dcbaf
4 changed files with 37 additions and 2 deletions

View File

@ -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

View File

@ -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, "->");

View File

@ -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

View File

@ -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'" } */
}