aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/expr.c4
-rw-r--r--gcc/expr.h3
-rw-r--r--gcc/internal-fn.c7
-rw-r--r--gcc/testsuite/c-c++-common/pr102285.c10
4 files changed, 20 insertions, 4 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index e0bcbcc..eb33643 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -5305,7 +5305,7 @@ get_bit_range (poly_uint64_pod *bitstart, poly_uint64_pod *bitend, tree exp,
has non-BLKmode. DECL_RTL must not be a MEM; if
DECL_RTL was not set yet, return false. */
-static inline bool
+bool
non_mem_decl_p (tree base)
{
if (!DECL_P (base)
@@ -5322,7 +5322,7 @@ non_mem_decl_p (tree base)
/* Returns true if REF refers to an object that does not
reside in memory and has non-BLKmode. */
-static inline bool
+bool
mem_ref_refers_to_non_mem_p (tree ref)
{
tree base;
diff --git a/gcc/expr.h b/gcc/expr.h
index 94a85b4..890ec19 100644
--- a/gcc/expr.h
+++ b/gcc/expr.h
@@ -346,4 +346,7 @@ extern void expand_operands (tree, tree, rtx, rtx*, rtx*,
/* Return an rtx for the size in bytes of the value of an expr. */
extern rtx expr_size (tree);
+extern bool mem_ref_refers_to_non_mem_p (tree);
+extern bool non_mem_decl_p (tree);
+
#endif /* GCC_EXPR_H */
diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c
index ef5dc90..1101452 100644
--- a/gcc/internal-fn.c
+++ b/gcc/internal-fn.c
@@ -3015,8 +3015,11 @@ expand_DEFERRED_INIT (internal_fn, gcall *stmt)
reg_lhs = true;
else
{
- rtx tem = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
- reg_lhs = !MEM_P (tem);
+ tree lhs_base = lhs;
+ while (handled_component_p (lhs_base))
+ lhs_base = TREE_OPERAND (lhs_base, 0);
+ reg_lhs = (mem_ref_refers_to_non_mem_p (lhs_base)
+ || non_mem_decl_p (lhs_base));
}
if (!reg_lhs)
diff --git a/gcc/testsuite/c-c++-common/pr102285.c b/gcc/testsuite/c-c++-common/pr102285.c
new file mode 100644
index 0000000..644054b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr102285.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O -ftrivial-auto-var-init=zero -Wuninitialized" } */
+
+int
+qy (void)
+{
+ int tw = 4;
+ int fb[tw];
+ return fb[2]; /* { dg-warning "uninitialized" } */
+}