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:
parent
bce8455643
commit
be461b8fb9
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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__);
|
||||
}
|
||||
};
|
|
@ -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);
|
||||
}
|
||||
};
|
|
@ -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" }
|
||||
};
|
|
@ -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" }
|
||||
};
|
Loading…
Reference in New Issue