This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR c++/40749: g++ doesnt report missing return if return is of type const <type>


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);



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]