@@ -814,6 +814,15 @@
continue;
}
+ // Skip blank named functions and constants.
+ if ((no->is_function() && no->func_value()->is_sink())
+ || (no->is_const() && no->const_value()->is_sink()))
+ {
+ --i;
+ --count;
+ continue;
+ }
+
// There is nothing useful we can output for constants which
// have ideal or non-integral type.
if (no->is_const())
@@ -829,14 +838,6 @@
}
}
- // Skip blank named functions.
- if (no->is_function() && no->func_value()->is_sink())
- {
- --i;
- --count;
- continue;
- }
-
if (!no->is_variable())
{
vec[i] = no->get_tree(this, NULL);
@@ -1687,7 +1687,7 @@
Named_constant(Type* type, Expression* expr, int iota_value,
Location location)
: type_(type), expr_(expr), iota_value_(iota_value), location_(location),
- lowering_(false)
+ lowering_(false), is_sink_(false)
{ }
Type*
@@ -1721,6 +1721,14 @@
clear_lowering()
{ this->lowering_ = false; }
+ bool
+ is_sink() const
+ { return this->is_sink_; }
+
+ void
+ set_is_sink()
+ { this->is_sink_ = true; }
+
// Traverse the expression.
int
traverse_expression(Traverse*);
@@ -1756,6 +1764,8 @@
Location location_;
// Whether we are currently lowering this constant.
bool lowering_;
+ // Whether this constant is blank named and needs only type checking.
+ bool is_sink_;
};
// A type declaration.
@@ -1457,6 +1457,16 @@
if (!Gogo::is_sink_name(pi->name()))
this->gogo_->add_constant(*pi, *pe, this->iota_value());
+ else
+ {
+ static int count;
+ char buf[30];
+ snprintf(buf, sizeof buf, ".$sinkconst%d", count);
+ ++count;
+ Typed_identifier ti(std::string(buf), type, pi->location());
+ Named_object* no = this->gogo_->add_constant(ti, *pe, this->iota_value());
+ no->const_value()->set_is_sink();
+ }
}
if (pe != expr_list->end())
error_at(this->location(), "too many initializers");