]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport:
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Thu, 1 Sep 2005 15:06:16 +0000 (15:06 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Thu, 1 Sep 2005 15:06:16 +0000 (15:06 +0000)
2004-11-25  Mark Mitchell  <mark@codesourcery.com>
PR c++/18545
* typeck.c (check_return_expr): Robustify.

* g++.dg/expr/return1.C: New test.

From-SVN: r103732

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/expr/return1.C

index e24c72bddd4bdfffafd90cab9c03361bab8f2bf1..b485511eaf4c3702f8f22f2bdad2a9c3fb418371 100644 (file)
@@ -1,3 +1,11 @@
+2005-09-01  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       Backport:
+
+       2004-11-25  Mark Mitchell  <mark@codesourcery.com>
+       PR c++/18545
+       * typeck.c (check_return_expr): Robustify.
+
 2005-09-01  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        Backport:
index e0f6868a6d7e112ce6889ce9bd5c2021bf118553..50e2ea9e52b689ccdca2ff93365f380b1250a75d 100644 (file)
@@ -6084,6 +6084,15 @@ check_return_expr (tree retval)
     /* Remember that this function did return a value.  */
     current_function_returns_value = 1;
 
+  /* Check for erroneous operands -- but after giving ourselves a
+     chance to provide an error about returning a value from a void
+     function.  */
+  if (error_operand_p (retval))
+    {
+      current_function_return_value = error_mark_node;
+      return error_mark_node;
+    }
+
   /* Only operator new(...) throw(), can return NULL [expr.new/13].  */
   if ((DECL_OVERLOADED_OPERATOR_P (current_function_decl) == NEW_EXPR
        || DECL_OVERLOADED_OPERATOR_P (current_function_decl) == VEC_NEW_EXPR)
@@ -6140,8 +6149,8 @@ check_return_expr (tree retval)
 
   /* We don't need to do any conversions when there's nothing being
      returned.  */
-  if (!retval || retval == error_mark_node)
-    return retval;
+  if (!retval)
+    return NULL_TREE;
 
   /* Do any required conversions.  */
   if (retval == result || DECL_CONSTRUCTOR_P (current_function_decl))
index e4356b2faa962028caf0d2ee1ea49cc701862b1b..0bd2505f77345afbd62fde658f2b44b4179bb905 100644 (file)
@@ -1,3 +1,11 @@
+2005-09-01  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       Backport:
+
+       2004-11-25  Mark Mitchell  <mark@codesourcery.com>
+       PR c++/18545
+       * g++.dg/expr/return1.C: New test. 
+
 2005-09-01  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        Backport:
index 7a64988e4b32426252ccd9767807c75c62f7688c..74fb32f192f13267b7b4f8e01b701b65c046729d 100644 (file)
@@ -2,8 +2,8 @@
 
 struct A;
 
-A foo()  // { dg-error "" }
-{
-  A a; // { dg-error "" }
+A foo()
+{      // { dg-error "incomplete" }
+  A a; // { dg-error "incomplete" }
   return a;
 }