mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-18 20:31:00 +08:00
Don't crash when declaring methods on unknown name.
From-SVN: r168131
This commit is contained in:
parent
7a8de70f01
commit
059e2a26f5
@ -3710,6 +3710,18 @@ Named_object::set_function_value(Function* function)
|
||||
this->u_.func_value = function;
|
||||
}
|
||||
|
||||
// Declare an unknown object as a type declaration.
|
||||
|
||||
void
|
||||
Named_object::declare_as_type()
|
||||
{
|
||||
gcc_assert(this->classification_ == NAMED_OBJECT_UNKNOWN);
|
||||
Unknown_name* unk = this->u_.unknown_value;
|
||||
this->classification_ = NAMED_OBJECT_TYPE_DECLARATION;
|
||||
this->u_.type_declaration = new Type_declaration(unk->location());
|
||||
delete unk;
|
||||
}
|
||||
|
||||
// Return the location of a named object.
|
||||
|
||||
source_location
|
||||
|
@ -1815,6 +1815,10 @@ class Named_object
|
||||
void
|
||||
set_function_value(Function*);
|
||||
|
||||
// Declare an unknown name as a type declaration.
|
||||
void
|
||||
declare_as_type();
|
||||
|
||||
// Export this object.
|
||||
void
|
||||
export_named_object(Export*) const;
|
||||
|
@ -8013,7 +8013,8 @@ Forward_declaration_type::add_method(const std::string& name,
|
||||
Function* function)
|
||||
{
|
||||
Named_object* no = this->named_object();
|
||||
gcc_assert(no->is_type_declaration());
|
||||
if (no->is_unknown())
|
||||
no->declare_as_type();
|
||||
return no->type_declaration_value()->add_method(name, function);
|
||||
}
|
||||
|
||||
@ -8026,7 +8027,8 @@ Forward_declaration_type::add_method_declaration(const std::string& name,
|
||||
source_location location)
|
||||
{
|
||||
Named_object* no = this->named_object();
|
||||
gcc_assert(no->is_type_declaration());
|
||||
if (no->is_unknown())
|
||||
no->declare_as_type();
|
||||
Type_declaration* td = no->type_declaration_value();
|
||||
return td->add_method_declaration(name, type, location);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user