diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-12-14 14:48:01 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-12-14 14:48:01 +0000 |
commit | c623f8372c205a28a1f0aa35932690449a032eb6 (patch) | |
tree | 6fd59e1b0262a333a556497b187849b709191ce3 /gcc | |
parent | e6f5278487a76afcc219a9eeae150c7d3703659d (diff) | |
download | gcc-c623f8372c205a28a1f0aa35932690449a032eb6.zip gcc-c623f8372c205a28a1f0aa35932690449a032eb6.tar.gz gcc-c623f8372c205a28a1f0aa35932690449a032eb6.tar.bz2 |
compiler: Permit omitting &T in composite literal.
From-SVN: r182331
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 365e99c..3c75f8a 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -12783,14 +12783,23 @@ Composite_literal_expression::do_lower(Gogo* gogo, Named_object* function, } } + Type *pt = type->points_to(); + bool is_pointer = false; + if (pt != NULL) + { + is_pointer = true; + type = pt; + } + + Expression* ret; if (type->is_error()) return Expression::make_error(this->location()); else if (type->struct_type() != NULL) - return this->lower_struct(gogo, type); + ret = this->lower_struct(gogo, type); else if (type->array_type() != NULL) - return this->lower_array(type); + ret = this->lower_array(type); else if (type->map_type() != NULL) - return this->lower_map(gogo, function, inserter, type); + ret = this->lower_map(gogo, function, inserter, type); else { error_at(this->location(), @@ -12798,6 +12807,11 @@ Composite_literal_expression::do_lower(Gogo* gogo, Named_object* function, "for composite literal")); return Expression::make_error(this->location()); } + + if (is_pointer) + ret = Expression::make_heap_composite(ret, this->location()); + + return ret; } // Lower a struct composite literal. |