compiler: fix infinite recursion in string constant evaluation.
Fixes compilation of incorrect code: const f, g = g, f func S() []byte { return []byte(f) } The problem was already handled for numerical constants. Part of issue 3186 (go). From-SVN: r186511
This commit is contained in:
parent
4a1016814c
commit
2dfc736cc7
@ -2403,8 +2403,7 @@ class Const_expression : public Expression
|
|||||||
do_numeric_constant_value(Numeric_constant* nc) const;
|
do_numeric_constant_value(Numeric_constant* nc) const;
|
||||||
|
|
||||||
bool
|
bool
|
||||||
do_string_constant_value(std::string* val) const
|
do_string_constant_value(std::string* val) const;
|
||||||
{ return this->constant_->const_value()->expr()->string_constant_value(val); }
|
|
||||||
|
|
||||||
Type*
|
Type*
|
||||||
do_type();
|
do_type();
|
||||||
@ -2514,6 +2513,21 @@ Const_expression::do_numeric_constant_value(Numeric_constant* nc) const
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Const_expression::do_string_constant_value(std::string* val) const
|
||||||
|
{
|
||||||
|
if (this->seen_)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Expression* e = this->constant_->const_value()->expr();
|
||||||
|
|
||||||
|
this->seen_ = true;
|
||||||
|
bool ok = e->string_constant_value(val);
|
||||||
|
this->seen_ = false;
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
// Return the type of the const reference.
|
// Return the type of the const reference.
|
||||||
|
|
||||||
Type*
|
Type*
|
||||||
|
Loading…
Reference in New Issue
Block a user