re PR c++/40749 (g++ doesnt report missing return if return is of type const <type>)

gcc/cp/

2009-07-26  Simon Martin  <simartin@users.sourceforge.net>

	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  <simartin@users.sourceforge.net>

	PR c++/40749
	* g++.dg/warn/Wreturn-type-6.C: New test.

From-SVN: r150099
This commit is contained in:
Simon Martin 2009-07-26 16:05:22 +00:00 committed by Simon Martin
parent 2acd0e1b57
commit 4347646ec2
4 changed files with 24 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2009-07-26 Simon Martin <simartin@users.sourceforge.net>
PR c++/40749
* decl.c (grokdeclarator): Do not set TREE_NO_WARNING for functions
with a qualified return type.
2009-07-24 Jason Merrill <jason@redhat.com>
Core issue 702

View File

@ -7611,7 +7611,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;
signed_p = declspecs->specs[(int)ds_signed];
@ -8290,7 +8289,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;
}
/* Error about some types functions can't return. */
@ -9492,9 +9490,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;
}
}

View File

@ -1,3 +1,8 @@
2007-07-26 Simon Martin <simartin@users.sourceforge.net>
PR c++/40749
* g++.dg/warn/Wreturn-type-6.C: New test.
2009-07-25 Uros Bizjak <ubizjak@gmail.com>
* lib/target-supports.exp (check_effective_target_static): New

View File

@ -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<class T>
const int foo(T t) {} /* { dg-warning "no return statement" } */
int d = foo<int>(0), e = foo<int>(1);