re PR c++/49508 (Bogus "control reaches end of non-void function" warning)
authorJason Merrill <jason@redhat.com>
Thu, 29 Jan 2015 16:10:08 +0000 (11:10 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 29 Jan 2015 16:10:08 +0000 (11:10 -0500)
PR c++/49508
* semantics.c (finish_return_stmt): Suppress -Wreturn-type on
erroneous return statement.

From-SVN: r220252

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/g++.old-deja/g++.jason/report.C

index fb3e2dc79e4d8044b64687237af81dab4965530c..2280e6bd0942f9512adafeebb60f438b7cf876b6 100644 (file)
@@ -1,5 +1,9 @@
 2015-01-29  Jason Merrill  <jason@redhat.com>
 
+       PR c++/49508
+       * semantics.c (finish_return_stmt): Suppress -Wreturn-type on
+       erroneous return statement.
+
        PR c++/64521
        * repo.c (repo_emit_p): It's OK for a clone to be extern at this
        point.
index 75aa501fe8c00627866f290060c8dd6a41f85dac..f325e41f417fa65dbbf946a6701881cca828587f 100644 (file)
@@ -888,7 +888,13 @@ finish_return_stmt (tree expr)
 
   if (error_operand_p (expr)
       || (flag_openmp && !check_omp_return ()))
-    return error_mark_node;
+    {
+      /* Suppress -Wreturn-type for this function.  */
+      if (warn_return_type)
+       TREE_NO_WARNING (current_function_decl) = true;
+      return error_mark_node;
+    }
+
   if (!processing_template_decl)
     {
       if (warn_sequence_point)
index b595662c22850b7bc27c9f4c0c39f28e9897f049..e1079cfb0aaf0a0d76af841aec0d01df3327adf3 100644 (file)
@@ -72,6 +72,3 @@ int darg (char X::*p)
 {
    undef3 (1); // { dg-error "" } implicit declaration
 }                              // { dg-warning "no return statement" }
-
-// { dg-message "warning: control reaches end of non-void function" "" { target *-*-* } 36 }
-// { dg-message "warning: control reaches end of non-void function" "" { target *-*-* } 65 }