public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/49508 (bogus return warning after error)
@ 2015-01-29 17:53 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2015-01-29 17:53 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 142 bytes --]

An erroneous return statement should not lead to a warning about a 
missing return statement.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 49508.patch --]
[-- Type: text/x-patch, Size: 1374 bytes --]

commit 2b9ed36f61ed17ee014cc8cd883eba6df2c9ef88
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jan 29 10:16:03 2015 -0500

    	PR c++/49508
    	* semantics.c (finish_return_stmt): Suppress -Wreturn-type on
    	erroneous return statement.

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 75aa501..f325e41 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -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)
diff --git a/gcc/testsuite/g++.old-deja/g++.jason/report.C b/gcc/testsuite/g++.old-deja/g++.jason/report.C
index b595662..e1079cf 100644
--- a/gcc/testsuite/g++.old-deja/g++.jason/report.C
+++ b/gcc/testsuite/g++.old-deja/g++.jason/report.C
@@ -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 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-01-29 16:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-29 17:53 C++ PATCH for c++/49508 (bogus return warning after error) Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).