This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH,committed] Fix PR13106 (no return warning)
- From: Kriang Lerdsuwanakij <lerdsuwa at users dot sourceforge dot net>
- To: <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 14 Dec 2003 18:03:35 +0700 (ICT)
- Subject: [C++ PATCH,committed] Fix PR13106 (no return warning)
- Reply-to: <lerdsuwa at users dot sourceforge dot net>
Hi
This patch fixes PR13106, which is a regression in 3.4. We issue more warning
about missing return statement for template functions. However only 'void'
type is check. When the return type is a dependent type, this should wait
until instantiation time to see what the return type becomes after template
substitution. The testcase below is rather simple, but this warning suppression
is more useful when the return type is more complex, for example, a trait class.
Committed to trunk as obvious. Tested on i686-pc-linux-gnu.
--Kriang
2003-12-14 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/13106
* decl.c (finish_function): Check if return type is dependent before
issuing no return statement warning.
2003-12-14 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/13106
* g++.dg/warn/noreturn-3.C: New test.
diff -cprN gcc-main-save/gcc/cp/decl.c gcc-main-new/gcc/cp/decl.c
*** gcc-main-save/gcc/cp/decl.c Sat Nov 22 13:45:04 2003
--- gcc-main-new/gcc/cp/decl.c Sat Dec 13 23:55:51 2003
*************** finish_function (int flags)
*** 10811,10816 ****
--- 10811,10817 ----
/* Complain if there's just no return statement. */
if (warn_return_type
&& TREE_CODE (TREE_TYPE (fntype)) != VOID_TYPE
+ && !dependent_type_p (TREE_TYPE (fntype))
&& !current_function_returns_value && !current_function_returns_null
/* Don't complain if we abort or throw. */
&& !current_function_returns_abnormally
diff -cprN gcc-main-save/gcc/testsuite/g++.dg/warn/noreturn-3.C gcc-main-new/gcc/testsuite/g++.dg/warn/noreturn-3.C
*** gcc-main-save/gcc/testsuite/g++.dg/warn/noreturn-3.C Thu Jan 1 07:00:00 1970
--- gcc-main-new/gcc/testsuite/g++.dg/warn/noreturn-3.C Sat Dec 13 23:50:17 2003
***************
*** 0 ****
--- 1,9 ----
+ // { dg-do compile }
+ // { dg-options "-Wall" }
+
+ // Origin: stip@mathematik.uni-ulm.de
+ // Andrew Pinski <pinskia@gcc.gnu.org>
+
+ // PR c++/13106: No return warning when return type is a dependent type.
+
+ template <typename T> T dummy() { }