aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/parse.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/go/gofrontend/parse.cc')
-rw-r--r--gcc/go/gofrontend/parse.cc21
1 files changed, 15 insertions, 6 deletions
diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc
index 34a7765..84840fb 100644
--- a/gcc/go/gofrontend/parse.cc
+++ b/gcc/go/gofrontend/parse.cc
@@ -1515,7 +1515,7 @@ Parse::type_decl()
this->decl(&Parse::type_spec, NULL);
}
-// TypeSpec = identifier Type .
+// TypeSpec = identifier ["="] Type .
void
Parse::type_spec(void*)
@@ -1531,6 +1531,13 @@ Parse::type_spec(void*)
Location location = token->location();
token = this->advance_token();
+ bool is_alias = false;
+ if (token->is_op(OPERATOR_EQ))
+ {
+ is_alias = true;
+ token = this->advance_token();
+ }
+
// The scope of the type name starts at the point where the
// identifier appears in the source code. We implement this by
// declaring the type before we read the type definition.
@@ -1542,13 +1549,13 @@ Parse::type_spec(void*)
}
Type* type;
- if (name == "_" && this->peek_token()->is_keyword(KEYWORD_INTERFACE))
+ if (name == "_" && token->is_keyword(KEYWORD_INTERFACE))
{
// We call Parse::interface_type explicity here because we do not want
// to record an interface with a blank type name.
type = this->interface_type(false);
}
- else if (!this->peek_token()->is_op(OPERATOR_SEMICOLON))
+ else if (!token->is_op(OPERATOR_SEMICOLON))
type = this->type();
else
{
@@ -1579,9 +1586,11 @@ Parse::type_spec(void*)
type = Type::make_error_type();
}
- this->gogo_->define_type(named_type,
- Type::make_named_type(named_type, type,
- location));
+ Named_type* nt = Type::make_named_type(named_type, type, location);
+ if (is_alias)
+ nt->set_is_alias();
+
+ this->gogo_->define_type(named_type, nt);
go_assert(named_type->package() == NULL);
}
else