Commit 51b15ede by Nathan Sidwell Committed by Nathan Sidwell

re PR c++/21117 (ICE after error about returning an incomplete type)

cp:
	PR c++/21117
	* decl.c (check_function_type): Correctly overwrite incomplete
	return type with void type.
	* typeck.c (check_return_expr): If the function's return type is
	void, don't try and convert a return expr.
testsuite:
	PR c++/21117
	* g++.dg/other/return1.C: New.

From-SVN: r105310
parent a4d25453
2005-10-12 Nathan Sidwell <nathan@codesourcery.com>
PR c++/21117
* decl.c (check_function_type): Correctly overwrite incomplete
return type with void type.
* typeck.c (check_return_expr): If the function's return type is
void, don't try and convert a return expr.
2005-10-12 David Edelsohn <edelsohn@gnu.org>
PR c++/23730
......
......@@ -10012,25 +10012,20 @@ check_function_type (tree decl, tree current_function_parms)
return;
if (!COMPLETE_OR_VOID_TYPE_P (return_type))
{
error ("return type %q#T is incomplete", TREE_TYPE (fntype));
tree args = TYPE_ARG_TYPES (fntype);
error ("return type %q#T is incomplete", return_type);
/* Make it return void instead, but don't change the
type of the DECL_RESULT, in case we have a named return value. */
/* Make it return void instead. */
if (TREE_CODE (fntype) == METHOD_TYPE)
{
tree ctype = TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fntype)));
TREE_TYPE (decl)
= build_method_type_directly (ctype,
void_type_node,
FUNCTION_ARG_CHAIN (decl));
}
fntype = build_method_type_directly (TREE_TYPE (TREE_VALUE (args)),
void_type_node,
TREE_CHAIN (args));
else
TREE_TYPE (decl)
= build_function_type (void_type_node,
TYPE_ARG_TYPES (TREE_TYPE (decl)));
fntype = build_function_type (void_type_node, args);
TREE_TYPE (decl)
= build_exception_variant (fntype,
TYPE_RAISES_EXCEPTIONS (fntype));
TYPE_RAISES_EXCEPTIONS (TREE_TYPE (decl)));
}
else
abstract_virtuals_error (decl, TREE_TYPE (fntype));
......
......@@ -6326,6 +6326,11 @@ check_return_expr (tree retval, bool *no_warning)
/* The type the function is declared to return. */
tree functype = TREE_TYPE (TREE_TYPE (current_function_decl));
/* The functype's return type will have been set to void, if it
was an incomplete type. Just treat this as 'return;' */
if (VOID_TYPE_P (functype))
return error_mark_node;
/* First convert the value to the function's return type, then
to the type of return value's location to handle the
case that functype is smaller than the valtype. */
......
2005-10-12 Nathan Sidwell <nathan@codesourcery.com>
PR c++/21117
* g++.dg/other/return1.C: New.
2005-10-12 Paolo Bonzini <bonzini@gnu.org>
PR c++/24052
// Copyright (C) 2005 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 12 Oct 2005 <nathan@codesourcery.com>
// PR 21117:ICE after error
// Origin: Andrew Pinski <pinskia@gcc.gnu.org>
struct wxString;
struct wxString* wxGetEmptyString();
struct wxString GetHeader() // { dg-error "return type" "" }
{
return *wxGetEmptyString();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment