From d19aa6af6634b1e97f38431ad091f3b3f12baf2f Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Sun, 20 Nov 2022 18:06:04 +0100 Subject: c++: Set the locus of the function result decl gcc/cp/ChangeLog: * decl.cc (grokdeclarator): Build RESULT_DECL. (start_preparsed_function): Copy location from template. * semantics.cc (apply_deduced_return_type): Handle arg != current_function_decl. * method.cc (implicitly_declare_fn): Use it. gcc/ChangeLog: * function.cc (init_function_start): Use DECL_RESULT location for -Waggregate-return warning. gcc/testsuite/ChangeLog: * g++.dg/diagnostic/return-type-loc1.C: New test. Co-authored-by: Jason Merrill --- gcc/function.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/function.cc') diff --git a/gcc/function.cc b/gcc/function.cc index 9c8773b..dc333c2 100644 --- a/gcc/function.cc +++ b/gcc/function.cc @@ -4997,7 +4997,8 @@ init_function_start (tree subr) /* Warn if this value is an aggregate type, regardless of which calling convention we are using for it. */ if (AGGREGATE_TYPE_P (TREE_TYPE (DECL_RESULT (subr)))) - warning (OPT_Waggregate_return, "function returns an aggregate"); + warning_at (DECL_SOURCE_LOCATION (DECL_RESULT (subr)), + OPT_Waggregate_return, "function returns an aggregate"); } /* Expand code to verify the stack_protect_guard. This is invoked at -- cgit v1.1