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
This commit is contained in:
parent
a4d25453fa
commit
51b15ede49
5 changed files with 42 additions and 14 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
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>
|
2005-10-12 David Edelsohn <edelsohn@gnu.org>
|
||||||
|
|
||||||
PR c++/23730
|
PR c++/23730
|
||||||
|
|
|
@ -10012,25 +10012,20 @@ check_function_type (tree decl, tree current_function_parms)
|
||||||
return;
|
return;
|
||||||
if (!COMPLETE_OR_VOID_TYPE_P (return_type))
|
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
|
/* Make it return void instead. */
|
||||||
type of the DECL_RESULT, in case we have a named return value. */
|
|
||||||
if (TREE_CODE (fntype) == METHOD_TYPE)
|
if (TREE_CODE (fntype) == METHOD_TYPE)
|
||||||
{
|
fntype = build_method_type_directly (TREE_TYPE (TREE_VALUE (args)),
|
||||||
tree ctype = TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fntype)));
|
void_type_node,
|
||||||
TREE_TYPE (decl)
|
TREE_CHAIN (args));
|
||||||
= build_method_type_directly (ctype,
|
|
||||||
void_type_node,
|
|
||||||
FUNCTION_ARG_CHAIN (decl));
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
TREE_TYPE (decl)
|
fntype = build_function_type (void_type_node, args);
|
||||||
= build_function_type (void_type_node,
|
|
||||||
TYPE_ARG_TYPES (TREE_TYPE (decl)));
|
|
||||||
TREE_TYPE (decl)
|
TREE_TYPE (decl)
|
||||||
= build_exception_variant (fntype,
|
= build_exception_variant (fntype,
|
||||||
TYPE_RAISES_EXCEPTIONS (fntype));
|
TYPE_RAISES_EXCEPTIONS (TREE_TYPE (decl)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
abstract_virtuals_error (decl, TREE_TYPE (fntype));
|
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. */
|
/* The type the function is declared to return. */
|
||||||
tree functype = TREE_TYPE (TREE_TYPE (current_function_decl));
|
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
|
/* First convert the value to the function's return type, then
|
||||||
to the type of return value's location to handle the
|
to the type of return value's location to handle the
|
||||||
case that functype is smaller than the valtype. */
|
case that functype is smaller than the valtype. */
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
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>
|
2005-10-12 Paolo Bonzini <bonzini@gnu.org>
|
||||||
|
|
||||||
PR c++/24052
|
PR c++/24052
|
||||||
|
|
15
gcc/testsuite/g++.dg/other/return1.C
Normal file
15
gcc/testsuite/g++.dg/other/return1.C
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue