aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2015-12-22 00:10:53 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2015-12-22 00:10:53 +0000
commit37e840afa66d715f9141acdf25a5e2741976dc2a (patch)
treeca7aacb9f681304f728bfdde7ffcd44647ae1852
parent19aede8bd0d551f730e31902b4046ac7d943636f (diff)
downloadgcc-37e840afa66d715f9141acdf25a5e2741976dc2a.zip
gcc-37e840afa66d715f9141acdf25a5e2741976dc2a.tar.gz
gcc-37e840afa66d715f9141acdf25a5e2741976dc2a.tar.bz2
go-gcc.cc (Gcc_backend::global_variable): If type is zero-sized, add a VIEW_CONVERT_EXPR to the tree.
* go-gcc.cc (Gcc_backend::global_variable): If type is zero-sized, add a VIEW_CONVERT_EXPR to the tree. (Gcc_backend::global_variable_set_init): Remove any VIEW_CONVERT_EXPR. (Gcc_backend::write_global_definitions): Likewise. From-SVN: r231889
-rw-r--r--gcc/go/ChangeLog8
-rw-r--r--gcc/go/go-gcc.cc16
2 files changed, 23 insertions, 1 deletions
diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog
index 6ae7397..5d66dac 100644
--- a/gcc/go/ChangeLog
+++ b/gcc/go/ChangeLog
@@ -1,3 +1,11 @@
+2015-12-21 Ian Lance Taylor <iant@google.com>
+
+ * go-gcc.cc (Gcc_backend::global_variable): If type is zero-sized,
+ add a VIEW_CONVERT_EXPR to the tree.
+ (Gcc_backend::global_variable_set_init): Remove any
+ VIEW_CONVERT_EXPR.
+ (Gcc_backend::write_global_definitions): Likewise.
+
2015-11-11 Andrew MacLeod <amacleod@redhat.com>
* go-backend.c: Remove unused header files.
diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc
index 31aac2e..7739d4d 100644
--- a/gcc/go/go-gcc.cc
+++ b/gcc/go/go-gcc.cc
@@ -2391,6 +2391,7 @@ Gcc_backend::global_variable(const std::string& package_name,
return this->error_variable();
// The GNU linker does not like dynamic variables with zero size.
+ tree orig_type_tree = type_tree;
if ((is_external || !is_hidden) && int_size_in_bytes(type_tree) == 0)
type_tree = this->non_zero_size_type(type_tree);
@@ -2420,6 +2421,10 @@ Gcc_backend::global_variable(const std::string& package_name,
go_preserve_from_gc(decl);
+ if (orig_type_tree != type_tree)
+ decl = fold_build1_loc(location.gcc_location(), VIEW_CONVERT_EXPR,
+ orig_type_tree, decl);
+
return new Bvariable(decl);
}
@@ -2435,6 +2440,10 @@ Gcc_backend::global_variable_set_init(Bvariable* var, Bexpression* expr)
tree var_decl = var->get_tree();
if (var_decl == error_mark_node)
return;
+ // Undo the VIEW_CONVERT_EXPR that may have been added by
+ // global_variable.
+ if (TREE_CODE(var_decl) == VIEW_CONVERT_EXPR)
+ var_decl = TREE_OPERAND(var_decl, 0);
DECL_INITIAL(var_decl) = expr_tree;
// If this variable goes in a unique section, it may need to go into
@@ -3031,7 +3040,12 @@ Gcc_backend::write_global_definitions(
{
if ((*p)->get_tree() != error_mark_node)
{
- defs[i] = (*p)->get_tree();
+ tree t = (*p)->get_tree();
+ // Undo the VIEW_CONVERT_EXPR that may have been added by
+ // global_variable.
+ if (TREE_CODE(t) == VIEW_CONVERT_EXPR)
+ t = TREE_OPERAND(t, 0);
+ defs[i] = t;
go_preserve_from_gc(defs[i]);
++i;
}