aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2012-03-08 23:33:04 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-03-08 23:33:04 +0000
commit7d6be4c870c2a1fdb694222ee1f750badc3b3d8a (patch)
tree7a5ccba6a082f2d0a7ecff65d3eef03f31a471da /gcc/go/gofrontend
parentb97190553d2798af4c5c8e6e775b942e458ba09e (diff)
downloadgcc-7d6be4c870c2a1fdb694222ee1f750badc3b3d8a.zip
gcc-7d6be4c870c2a1fdb694222ee1f750badc3b3d8a.tar.gz
gcc-7d6be4c870c2a1fdb694222ee1f750badc3b3d8a.tar.bz2
compiler: Don't initialize zero sized variables.
* go-gcc.cc (Gcc_backend::init_statement): Don't initialize a zero-sized variable. (go_non_zero_struct): New global variable. (Gcc_backend::non_zero_size_type): New function. (Gcc_backend::global_variable): Don't build an assignment for a zero-sized value. * go-c.h (go_non_zero_struct): Declare. * config-lang.in (gtfiles): Add go-c.h. From-SVN: r185115
Diffstat (limited to 'gcc/go/gofrontend')
-rw-r--r--gcc/go/gofrontend/gogo-tree.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/gogo-tree.cc b/gcc/go/gofrontend/gogo-tree.cc
index 603b97e..fa22932 100644
--- a/gcc/go/gofrontend/gogo-tree.cc
+++ b/gcc/go/gofrontend/gogo-tree.cc
@@ -843,7 +843,9 @@ Gogo::write_globals()
this->backend()->global_variable_set_init(var,
tree_to_expr(init));
}
- else if (is_sink)
+ else if (is_sink
+ || int_size_in_bytes(TREE_TYPE(init)) == 0
+ || int_size_in_bytes(TREE_TYPE(vec[i])) == 0)
var_init_tree = init;
else
var_init_tree = fold_build2_loc(no->location().gcc_location(),