OSDN Git Service

gcc/cp/
authorsimartin <simartin@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 26 Jul 2009 08:16:41 +0000 (08:16 +0000)
committersimartin <simartin@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 26 Jul 2009 08:16:41 +0000 (08:16 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150097 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wreturn-type-6.C [new file with mode: 0644]

index 2ee951c..ee37b65 100644 (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 901
index 7f4509e..be1b5b7 100644 (file)
@@ -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;
   }
 }
index 6139e0d..a8cea75 100644 (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-26  Ira Rosen  <irar@il.ibm.com>
 
        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 (file)
index 0000000..497e3b9
--- /dev/null
@@ -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);