aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYvan Roux <yvan.roux@linaro.org>2016-11-03 13:14:39 +0100
committerYvan Roux <yvan.roux@linaro.org>2016-11-10 15:45:18 +0100
commited3689248a072f10638651fc540f8f3d52b9d3c0 (patch)
treedae928d42952604e85f4820f4499b172d53319be
parent89c329d104d5f054a5c865205b7667e74f896527 (diff)
Change-Id: Ie8f19fcbb851bec5c2dbcab309b412a090e21417
-rw-r--r--gcc/testsuite/g++.dg/opt/pr78201.C11
-rw-r--r--gcc/varasm.c9
2 files changed, 16 insertions, 4 deletions
diff --git a/gcc/testsuite/g++.dg/opt/pr78201.C b/gcc/testsuite/g++.dg/opt/pr78201.C
new file mode 100644
index 00000000000..a1184d0edfe
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr78201.C
@@ -0,0 +1,11 @@
+// PR middle-end/78201
+// { dg-do compile }
+// { dg-options "-O2" }
+
+struct B { long d (); } *c;
+long e;
+
+void f() {
+ char a[e] = "";
+ c && c->d();
+}
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 6a7ffc22e22..1c711b1d8c8 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -6804,11 +6804,12 @@ default_use_anchors_for_symbol_p (const_rtx symbol)
return false;
/* Don't use section anchors for decls that won't fit inside a single
- anchor range to reduce the amount of instructions require to refer
+ anchor range to reduce the amount of instructions required to refer
to the entire declaration. */
- if (decl && DECL_SIZE (decl)
- && tree_to_shwi (DECL_SIZE (decl))
- >= (targetm.max_anchor_offset * BITS_PER_UNIT))
+ if (DECL_SIZE_UNIT (decl) == NULL_TREE
+ || !tree_fits_uhwi_p (DECL_SIZE_UNIT (decl))
+ || (tree_to_uhwi (DECL_SIZE_UNIT (decl))
+ >= (unsigned HOST_WIDE_INT) targetm.max_anchor_offset))
return false;
}