+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:
/* 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)
/* 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))
+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:
struct A;
-A foo() // { dg-error "" }
-{
- A a; // { dg-error "" }
+A foo()
+{ // { dg-error "incomplete" }
+ A a; // { dg-error "incomplete" }
return a;
}