This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Go patch committed: Don't try to address of a constant
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org, gofrontend-dev at googlegroups dot com
- Date: Tue, 15 May 2012 13:00:59 -0700
- Subject: Go patch committed: Don't try to address of a constant
This patch changes the Go frontend to avoid trying to directly take the
address of a constant when generating GENERIC. That actually mostly
works--unless the DECL_INITIAL of the constant is another constant.
This patch changes the code to use a temporary variable instead.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline and 4.7 branch.
Ian
diff -r b66431f97fa7 go/expressions.cc
--- a/go/expressions.cc Tue May 15 11:56:03 2012 -0700
+++ b/go/expressions.cc Tue May 15 12:58:22 2012 -0700
@@ -4044,7 +4044,7 @@
if (this->create_temp_
&& !TREE_ADDRESSABLE(TREE_TYPE(expr))
- && !DECL_P(expr)
+ && (TREE_CODE(expr) == CONST_DECL || !DECL_P(expr))
&& TREE_CODE(expr) != INDIRECT_REF
&& TREE_CODE(expr) != COMPONENT_REF)
{
@@ -6194,7 +6194,9 @@
make_tmp = NULL_TREE;
arg = right_tree;
}
- else if (TREE_ADDRESSABLE(TREE_TYPE(right_tree)) || DECL_P(right_tree))
+ else if (TREE_ADDRESSABLE(TREE_TYPE(right_tree))
+ || (TREE_CODE(right_tree) != CONST_DECL
+ && DECL_P(right_tree)))
{
make_tmp = NULL_TREE;
arg = build_fold_addr_expr_loc(location.gcc_location(), right_tree);