diff options
author | Jakub Jelinek <jakub@redhat.com> | 2020-04-25 00:11:35 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2020-04-25 00:11:35 +0200 |
commit | 4ff685a8705e8ee55fa86e75afb769ffb0975aea (patch) | |
tree | f30cb664d202ea08360b3706cbca5a5b5853bc3f /gcc/testsuite | |
parent | cf39dccf9284d2fd9f9aa7050760adea110c8d88 (diff) | |
download | gcc-4ff685a8705e8ee55fa86e75afb769ffb0975aea.zip gcc-4ff685a8705e8ee55fa86e75afb769ffb0975aea.tar.gz gcc-4ff685a8705e8ee55fa86e75afb769ffb0975aea.tar.bz2 |
c++: Avoid -Wreturn-type warning if a template fn calls noreturn template fn [PR94742]
finish_call_expr already has code to set current_function_returns_abnormally
if a template calls a noreturn function, but on the following testcase it
doesn't call a FUNCTION_DECL, but TEMPLATE_DECL instead, in which case
we didn't check noreturn at all and just assumed it could return.
2020-04-25 Jakub Jelinek <jakub@redhat.com>
PR c++/94742
* semantics.c (finish_call_expr): When looking if all overloads
are noreturn, use STRIP_TEMPLATE to look through TEMPLATE_DECLs.
* g++.dg/warn/Wreturn-type-12.C: New test.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wreturn-type-12.C | 23 |
2 files changed, 26 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fa58367..b9be668 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2020-04-25 Jakub Jelinek <jakub@redhat.com> + PR c++/94742 + * g++.dg/warn/Wreturn-type-12.C: New test. + PR tree-optimization/94734 PR tree-optimization/89430 * gcc.dg/tree-ssa/pr89430-1.c: Add xfail. diff --git a/gcc/testsuite/g++.dg/warn/Wreturn-type-12.C b/gcc/testsuite/g++.dg/warn/Wreturn-type-12.C new file mode 100644 index 0000000..b35d3fa --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wreturn-type-12.C @@ -0,0 +1,23 @@ +// PR c++/94742 +// { dg-do compile { target c++11 } } +// { dg-options "-Wreturn-type" } + +template <class T> +[[noreturn]] void +foo (T const &t, char const *) +{ + throw T (t); +} + +template <class U> +int +bar () +{ + foo (42, __FUNCTION__); +} // { dg-bogus "no return statement in function returning non-void" } + +int +main () +{ + bar<long>(); +} |