Commit 4f0eaba2 by Ian Lance Taylor

compiler: traverse types of constant expressions

    
    We forgot to ever traverse types of constant expressions.  This rarely
    makes a difference--evidently, since nobody noticed--but it does
    matter when we inline constant expressions: we need to ensure that the
    type is visible to the importing code.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194317

From-SVN: r275539
parent 0b0310e9
8f2b844acda70330f7c50b360f8c983d2676ecbb 28c9053b3d507bef7bd56cb01c6b22deea354cdd
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -1812,6 +1812,9 @@ class Boolean_expression : public Expression ...@@ -1812,6 +1812,9 @@ class Boolean_expression : public Expression
do_import(Import_expression*, Location); do_import(Import_expression*, Location);
protected: protected:
int
do_traverse(Traverse*);
bool bool
do_is_constant() const do_is_constant() const
{ return true; } { return true; }
...@@ -1864,6 +1867,17 @@ class Boolean_expression : public Expression ...@@ -1864,6 +1867,17 @@ class Boolean_expression : public Expression
Type* type_; Type* type_;
}; };
// Traverse a boolean expression. We just need to traverse the type
// if there is one.
int
Boolean_expression::do_traverse(Traverse* traverse)
{
if (this->type_ != NULL)
return Type::traverse(this->type_, traverse);
return TRAVERSE_CONTINUE;
}
// Get the type. // Get the type.
Type* Type*
...@@ -1916,6 +1930,17 @@ Expression::make_boolean(bool val, Location location) ...@@ -1916,6 +1930,17 @@ Expression::make_boolean(bool val, Location location)
// Class String_expression. // Class String_expression.
// Traverse a string expression. We just need to traverse the type
// if there is one.
int
String_expression::do_traverse(Traverse* traverse)
{
if (this->type_ != NULL)
return Type::traverse(this->type_, traverse);
return TRAVERSE_CONTINUE;
}
// Get the type. // Get the type.
Type* Type*
...@@ -2290,6 +2315,9 @@ class Integer_expression : public Expression ...@@ -2290,6 +2315,9 @@ class Integer_expression : public Expression
dump_integer(Ast_dump_context* ast_dump_context, const mpz_t val); dump_integer(Ast_dump_context* ast_dump_context, const mpz_t val);
protected: protected:
int
do_traverse(Traverse*);
bool bool
do_is_constant() const do_is_constant() const
{ return true; } { return true; }
...@@ -2353,6 +2381,17 @@ class Integer_expression : public Expression ...@@ -2353,6 +2381,17 @@ class Integer_expression : public Expression
bool is_character_constant_; bool is_character_constant_;
}; };
// Traverse an integer expression. We just need to traverse the type
// if there is one.
int
Integer_expression::do_traverse(Traverse* traverse)
{
if (this->type_ != NULL)
return Type::traverse(this->type_, traverse);
return TRAVERSE_CONTINUE;
}
// Return a numeric constant for this expression. We have to mark // Return a numeric constant for this expression. We have to mark
// this as a character when appropriate. // this as a character when appropriate.
...@@ -2714,6 +2753,9 @@ class Float_expression : public Expression ...@@ -2714,6 +2753,9 @@ class Float_expression : public Expression
dump_float(Ast_dump_context* ast_dump_context, const mpfr_t val); dump_float(Ast_dump_context* ast_dump_context, const mpfr_t val);
protected: protected:
int
do_traverse(Traverse*);
bool bool
do_is_constant() const do_is_constant() const
{ return true; } { return true; }
...@@ -2773,6 +2815,17 @@ class Float_expression : public Expression ...@@ -2773,6 +2815,17 @@ class Float_expression : public Expression
Type* type_; Type* type_;
}; };
// Traverse a float expression. We just need to traverse the type if
// there is one.
int
Float_expression::do_traverse(Traverse* traverse)
{
if (this->type_ != NULL)
return Type::traverse(this->type_, traverse);
return TRAVERSE_CONTINUE;
}
// Return the current type. If we haven't set the type yet, we return // Return the current type. If we haven't set the type yet, we return
// an abstract float type. // an abstract float type.
...@@ -2932,6 +2985,9 @@ class Complex_expression : public Expression ...@@ -2932,6 +2985,9 @@ class Complex_expression : public Expression
dump_complex(Ast_dump_context* ast_dump_context, const mpc_t val); dump_complex(Ast_dump_context* ast_dump_context, const mpc_t val);
protected: protected:
int
do_traverse(Traverse*);
bool bool
do_is_constant() const do_is_constant() const
{ return true; } { return true; }
...@@ -2995,6 +3051,17 @@ class Complex_expression : public Expression ...@@ -2995,6 +3051,17 @@ class Complex_expression : public Expression
Type* type_; Type* type_;
}; };
// Traverse a complex expression. We just need to traverse the type
// if there is one.
int
Complex_expression::do_traverse(Traverse* traverse)
{
if (this->type_ != NULL)
return Type::traverse(this->type_, traverse);
return TRAVERSE_CONTINUE;
}
// Return the current type. If we haven't set the type yet, we return // Return the current type. If we haven't set the type yet, we return
// an abstract complex type. // an abstract complex type.
......
...@@ -1670,6 +1670,9 @@ class String_expression : public Expression ...@@ -1670,6 +1670,9 @@ class String_expression : public Expression
do_import(Import_expression*, Location); do_import(Import_expression*, Location);
protected: protected:
int
do_traverse(Traverse*);
bool bool
do_is_constant() const do_is_constant() const
{ return true; } { return true; }
......
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