re PR c++/30988 (Incorrect "no return statement" warning with __attribute__ ((noreturn)) and __FUNCTION__)

PR c++/30988
	semantics.c (finish_call_expr): Set current_function_returns_abnormally
	if fn is noreturn FUNCTION_DECL or OVERLOAD with all noreturn
	functions.

	* g++.dg/warn/noreturn-4.C: New test.
	* g++.dg/warn/noreturn-5.C: New test.
	* g++.dg/warn/noreturn-6.C: New test.
	* g++.dg/warn/noreturn-7.C: New test.

From-SVN: r130280
This commit is contained in:
Jakub Jelinek 2007-11-18 23:20:54 +01:00 committed by Jakub Jelinek
parent bce8455643
commit be461b8fb9
7 changed files with 85 additions and 0 deletions

View File

@ -1,3 +1,10 @@
2007-11-18 Jakub Jelinek <jakub@redhat.com>
PR c++/30988
semantics.c (finish_call_expr): Set current_function_returns_abnormally
if fn is noreturn FUNCTION_DECL or OVERLOAD with all noreturn
functions.
2007-11-16 Jakub Jelinek <jakub@redhat.com>
PR c++/34100

View File

@ -1846,6 +1846,20 @@ finish_call_expr (tree fn, tree args, bool disallow_virtual, bool koenig_p)
{
result = build_nt_call_list (fn, args);
KOENIG_LOOKUP_P (result) = koenig_p;
if (cfun)
{
do
{
tree fndecl = OVL_CURRENT (fn);
if (TREE_CODE (fndecl) != FUNCTION_DECL
|| !TREE_THIS_VOLATILE (fndecl))
break;
fn = OVL_NEXT (fn);
}
while (fn);
if (!fn)
current_function_returns_abnormally = 1;
}
return result;
}
if (!BASELINK_P (fn)

View File

@ -1,3 +1,11 @@
2007-11-18 Jakub Jelinek <jakub@redhat.com>
PR c++/30988
* g++.dg/warn/noreturn-4.C: New test.
* g++.dg/warn/noreturn-5.C: New test.
* g++.dg/warn/noreturn-6.C: New test.
* g++.dg/warn/noreturn-7.C: New test.
2007-11-18 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/32770

View File

@ -0,0 +1,13 @@
// PR c++/30988
// { dg-do compile }
// { dg-options "-O2 -Wall" }
void f (const char *) __attribute__ ((noreturn));
template <typename T> struct A
{
int g ()
{
f (__FUNCTION__);
}
};

View File

@ -0,0 +1,15 @@
// PR c++/30988
// { dg-do compile }
// { dg-options "-O2 -Wall" }
void f (const char *) __attribute__ ((noreturn));
void f (int) __attribute__ ((noreturn));
void f (double) __attribute__ ((noreturn));
template <typename T> struct A
{
int g ()
{
f ((T) 0);
}
};

View File

@ -0,0 +1,13 @@
// PR c++/30988
// { dg-do compile }
// { dg-options "-O2 -Wall" }
void f (const char *);
template <typename T> struct A
{
int g ()
{
f (__FUNCTION__);
} // { dg-warning "no return statement in function returning non-void" }
};

View File

@ -0,0 +1,15 @@
// PR c++/30988
// { dg-do compile }
// { dg-options "-O2 -Wall" }
void f (const char *) __attribute__ ((noreturn));
void f (int);
void f (double) __attribute__ ((noreturn));
template <typename T> struct A
{
int g ()
{
f ((T) 0);
} // { dg-warning "no return statement in function returning non-void" }
};