This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR c++/40749: g++ doesnt report missing return if return is of type const <type>
- From: Simon Martin <simartin at users dot sourceforge dot net>
- To: Jason Merrill <jason at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, dmueller at suse dot de
- Date: Sat, 25 Jul 2009 15:09:49 +0200
- Subject: Re: [PATCH] Fix PR c++/40749: g++ doesnt report missing return if return is of type const <type>
- References: <4A60F4E7.8020700@users.sourceforge.net> <4A686B3B.3080808@redhat.com>
Hello!
I think the TREE_NO_WARNING bit is to avoid double warnings on code like
template <class T>
const int f(T t) { return 0; }
but clearly TREE_NO_WARNING is too big a hammer to use for that. I
think the right answer is just to remove the tsubst_function_type hunk
from the 18313 fix entirely; I don't think it's useful to warn when
substituting into a template happens to produce a const-qualified return
type. Could you do that as well?
This has actually already been done in
http://gcc.gnu.org/viewcvs/trunk/gcc/cp/pt.c?r1=137660&r2=137672&diff_format=h
Is the initial patch therefore OK, with this modified version of the
testcase (I've checked that it still passes)?
Thanks,
Simon
/* PR c++/40749 */
/* { dg-do "compile" } */
/* { dg-options "-Wreturn-type" } */
struct A {};
const A a() {} /* { dg-warning "no return statement" } */
const A& b() {} /* { dg-warning "no return statement" } */
const int c() {} /* { dg-warning "no return statement" } */
template<class T>
const int foo(T t) {} /* { dg-warning "no return statement" } */
int d = foo<int>(0), e = foo<int>(1);