From c2600c676cfe1b90c6536476c3dbf887953fcc50 Mon Sep 17 00:00:00 2001 From: Simon Martin Date: Sun, 26 Jul 2009 08:16:41 +0000 Subject: [PATCH] re PR c++/40749 (g++ doesnt report missing return if return is of type const ) gcc/cp/ 2009-07-26 Simon Martin PR c++/40749 * decl.c (grokdeclarator): Do not set TREE_NO_WARNING for functions with a qualified return type. gcc/testsuite/ 2007-07-26 Simon Martin PR c++/40749 * g++.dg/warn/Wreturn-type-6.C: New test. From-SVN: r150097 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/decl.c | 5 ----- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/warn/Wreturn-type-6.C | 13 +++++++++++++ 4 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/warn/Wreturn-type-6.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2ee951c907d..ee37b654aed 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2009-07-26 Simon Martin + + PR c++/40749 + * decl.c (grokdeclarator): Do not set TREE_NO_WARNING for functions + with a qualified return type. + 2009-07-24 Jason Merrill Core issue 901 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 7f4509e774a..be1b5b7b5ef 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7636,7 +7636,6 @@ grokdeclarator (const cp_declarator *declarator, bool unsigned_p, signed_p, short_p, long_p, thread_p; bool type_was_error_mark_node = false; bool parameter_pack_p = declarator? declarator->parameter_pack_p : false; - bool set_no_warning = false; bool template_type_arg = false; const char *errmsg; @@ -8316,7 +8315,6 @@ grokdeclarator (const cp_declarator *declarator, /* We now know that the TYPE_QUALS don't apply to the decl, but to its return type. */ type_quals = TYPE_UNQUALIFIED; - set_no_warning = true; } errmsg = targetm.invalid_return_type (type); if (errmsg) @@ -9538,9 +9536,6 @@ grokdeclarator (const cp_declarator *declarator, if (!processing_template_decl) cp_apply_type_quals_to_decl (type_quals, decl); - if (set_no_warning) - TREE_NO_WARNING (decl) = 1; - return decl; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6139e0dc0d6..a8cea7576d3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-07-26 Simon Martin + + PR c++/40749 + * g++.dg/warn/Wreturn-type-6.C: New test. + 2009-07-26 Ira Rosen PR tree-optimization/40801 diff --git a/gcc/testsuite/g++.dg/warn/Wreturn-type-6.C b/gcc/testsuite/g++.dg/warn/Wreturn-type-6.C new file mode 100644 index 00000000000..497e3b9ebad --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wreturn-type-6.C @@ -0,0 +1,13 @@ +/* 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 +const int foo(T t) {} /* { dg-warning "no return statement" } */ +int d = foo(0), e = foo(1);