re PR tree-optimization/14107 (Return warnings don't work without optimizations enabled)
authorJason Merrill <jason@redhat.com>
Tue, 15 Jun 2004 20:38:40 +0000 (16:38 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 15 Jun 2004 20:38:40 +0000 (16:38 -0400)
        PR tree-optimization/14107
        * decl.c (finish_function): Warn about no return in all functions.

From-SVN: r83198

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/init/new10.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/Wreturn-type-1.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.brendan/crash52.C
gcc/testsuite/g++.old-deja/g++.jason/report.C

index 518d73a17eb50990c623e15bc6f4f804bd216801..7b61cfc338c2cb975d8a7fa3200ee635be211689 100644 (file)
@@ -1,3 +1,8 @@
+2004-06-12  Jason Merrill  <jason@redhat.com>
+
+       PR tree-optimization/14107
+       * decl.c (finish_function): Warn about no return in all functions.
+
 2004-06-15  Paolo Bonzini  <bonzini@gnu.org>
 
        * cp-tree.h (struct language_function): Remove cannot_inline.
index 44a83d4345cc84c1a98804ab35db7b2f24c3788b..92c6cf0397682563c57bfdede0d0eeb69c971088 100644 (file)
@@ -10803,10 +10803,13 @@ finish_function (int flags)
       && !current_function_returns_value && !current_function_returns_null
       /* Don't complain if we abort or throw.  */
       && !current_function_returns_abnormally
-      && !DECL_NAME (DECL_RESULT (fndecl))
+      && !DECL_NAME (DECL_RESULT (fndecl)))
+#if 0
+    /* Enable this for all functions until bug 14107 is fixed properly.  */
       /* Normally, with -Wreturn-type, flow will complain.  Unless we're an
         inline function, as we might never be compiled separately.  */
       && (DECL_INLINE (fndecl) || processing_template_decl))
+#endif
     warning ("no return statement in function returning non-void");
 
   /* Store the end of the function, so that we get good line number
diff --git a/gcc/testsuite/g++.dg/init/new10.C b/gcc/testsuite/g++.dg/init/new10.C
new file mode 100644 (file)
index 0000000..e19629b
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/14452
+// We got confused trying to preevaluate the new-initializer.
+
+struct S {}; 
+void foo (bool b) 
+{ 
+  new S(b ? S() : S()); 
+} 
diff --git a/gcc/testsuite/g++.dg/warn/Wreturn-type-1.C b/gcc/testsuite/g++.dg/warn/Wreturn-type-1.C
new file mode 100644 (file)
index 0000000..fb9a862
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/11725
+// { dg-options "-Wreturn-type" }
+
+template <class T>
+struct A 
+{
+  int foo()
+  {
+    throw "Stop";
+  }
+};
index 9e72fb5cbb034354639c23f1352f8f8b903605fe..95c6a08322e76268b477db2bdd13bbd3e13d293f 100644 (file)
@@ -10,4 +10,5 @@ public:
 
 A &f(A &a) {// { dg-error "" }  new decl.*
   std::cout << "Blah\n";
-}
+} // { dg-warning "" } no return
+
index 13557f166ef2f3f910916983cd778af876c59b4b..0149129fefeedaf904e60f13c060b1e2e2fe6f1b 100644 (file)
@@ -56,7 +56,7 @@ bar2 baz (X::Y y)
   bar2 wa [5];
   wa[0] = baz(f);
   undef2 (1); // { dg-error "" } implicit declaration
-}
+} // { dg-warning "" } no return
 
 int ninny ()
 {
@@ -71,4 +71,4 @@ int ninny ()
 int darg (char X::*p)
 {
    undef3 (1); // { dg-error "" } implicit declaration
-}
+} // { dg-warning "" } no return