Skip to content

Commit

Permalink
compiler: Use context to determine types of complex expressions.
Browse files Browse the repository at this point in the history
    
    When determining the type of a complex expression, it is important
    to recognize cases where a complex value can be represented as a
    real number.
    
    Fixes golang/go#11572.
    
    Reviewed-on: https://go-review.googlesource.com/12541

From-SVN: r226596
  • Loading branch information
Ian Lance Taylor committed Aug 4, 2015
1 parent f12021e commit d69eea1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gcc/go/gofrontend/MERGE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bdd98c601f2c8dbd0bf821548ba09c038f7645c4
df080adb06f0e423820f3f6b9604b0c1093ff20a

The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
5 changes: 2 additions & 3 deletions gcc/go/gofrontend/expressions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2396,7 +2396,7 @@ class Complex_expression : public Expression

void
do_dump_expression(Ast_dump_context*) const;

private:
// The complex value.
mpc_t val_;
Expand All @@ -2423,8 +2423,7 @@ Complex_expression::do_determine_type(const Type_context* context)
{
if (this->type_ != NULL && !this->type_->is_abstract())
;
else if (context->type != NULL
&& context->type->complex_type() != NULL)
else if (context->type != NULL && context->type->is_numeric_type())
this->type_ = context->type;
else if (!context->may_be_abstract)
this->type_ = Type::lookup_complex_type("complex128");
Expand Down

0 comments on commit d69eea1

Please sign in to comment.