aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2012-10-24 11:08:56 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2012-10-24 11:08:56 +0200
commit848be0946c097a25e63acea3e16eee11fc41e6c9 (patch)
tree5d960bdbe98ce91b7d6e48d032f6ef7eee82c859 /gcc
parent9106d8d2153532281e2527d997e2a570ac06669b (diff)
downloadgcc-848be0946c097a25e63acea3e16eee11fc41e6c9.zip
gcc-848be0946c097a25e63acea3e16eee11fc41e6c9.tar.gz
gcc-848be0946c097a25e63acea3e16eee11fc41e6c9.tar.bz2
re PR debug/54828 (ICE in based_loc_descr at dwarf2out.c:10560 with -g -O0)
PR debug/54828 * gimple.h (is_gimple_sizepos): New inline function. * gimplify.c (gimplify_one_sizepos): Use it. Remove useless final assignment to expr variable. * tree.c (RETURN_TRUE_IF_VAR): Return true also if !TYPE_SIZES_GIMPLIFIED (type) and _t is going to be gimplified into a local temporary. * g++.dg/debug/pr54828.C: New test. From-SVN: r192759
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/gimple.h18
-rw-r--r--gcc/gimplify.c5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/debug/pr54828.C14
-rw-r--r--gcc/tree.c9
6 files changed, 55 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e5714c5..e8be541 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2012-10-24 Jakub Jelinek <jakub@redhat.com>
+
+ PR debug/54828
+ * gimple.h (is_gimple_sizepos): New inline function.
+ * gimplify.c (gimplify_one_sizepos): Use it. Remove useless
+ final assignment to expr variable.
+ * tree.c (RETURN_TRUE_IF_VAR): Return true also if
+ !TYPE_SIZES_GIMPLIFIED (type) and _t is going to be gimplified
+ into a local temporary.
+
2012-10-23 David S. Miller <davem@davemloft.net>
* config/sparc/constraints.md ("T", "W"): Change
diff --git a/gcc/gimple.h b/gcc/gimple.h
index bca1e14..b34016a 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -957,6 +957,24 @@ struct gimplify_ctx
bool in_cleanup_point_expr;
};
+/* Return true if gimplify_one_sizepos doesn't need to gimplify
+ expr (when in TYPE_SIZE{,_UNIT} and similar type/decl size/bitsize
+ fields). */
+static inline bool
+is_gimple_sizepos (tree expr)
+{
+ /* gimplify_one_sizepos doesn't need to do anything if the value isn't there,
+ is constant, or contains A PLACEHOLDER_EXPR. We also don't want to do
+ anything if it's already a VAR_DECL. If it's a VAR_DECL from another
+ function, the gimplifier will want to replace it with a new variable,
+ but that will cause problems if this type is from outside the function.
+ It's OK to have that here. */
+ return (expr == NULL_TREE
+ || TREE_CONSTANT (expr)
+ || TREE_CODE (expr) == VAR_DECL
+ || CONTAINS_PLACEHOLDER_P (expr));
+}
+
extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
bool (*) (tree), fallback_t);
extern void gimplify_type_sizes (tree, gimple_seq *);
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 14e7007..0919d9f 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -8147,15 +8147,12 @@ gimplify_one_sizepos (tree *expr_p, gimple_seq *stmt_p)
a VAR_DECL. If it's a VAR_DECL from another function, the gimplifier
will want to replace it with a new variable, but that will cause problems
if this type is from outside the function. It's OK to have that here. */
- if (expr == NULL_TREE || TREE_CONSTANT (expr)
- || TREE_CODE (expr) == VAR_DECL
- || CONTAINS_PLACEHOLDER_P (expr))
+ if (is_gimple_sizepos (expr))
return;
*expr_p = unshare_expr (expr);
gimplify_expr (expr_p, stmt_p, NULL, is_gimple_val, fb_rvalue);
- expr = *expr_p;
}
/* Gimplify the body of statements of FNDECL and return a GIMPLE_BIND node
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8a2bb1d..0648f1e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-10-24 Jakub Jelinek <jakub@redhat.com>
+
+ PR debug/54828
+ * g++.dg/debug/pr54828.C: New test.
+
2012-10-23 Dominique d'Humieres <dominiq@lps.ens.fr>
* gcc.dg/vect/vect-82_64.c: Adjust the dump file.
diff --git a/gcc/testsuite/g++.dg/debug/pr54828.C b/gcc/testsuite/g++.dg/debug/pr54828.C
new file mode 100644
index 0000000..80b9a3c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/pr54828.C
@@ -0,0 +1,14 @@
+// PR debug/54828
+// { dg-do compile }
+// { dg-options "-g" }
+
+struct T { T (); virtual ~T (); };
+struct S : public virtual T { S (); virtual ~S (); };
+int v;
+void foo (char *);
+
+S::S ()
+{
+ char s[v];
+ foo (s);
+}
diff --git a/gcc/tree.c b/gcc/tree.c
index d974362..7cb1ea1 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -8467,14 +8467,19 @@ variably_modified_type_p (tree type, tree fn)
tree t;
/* Test if T is either variable (if FN is zero) or an expression containing
- a variable in FN. */
+ a variable in FN. If TYPE isn't gimplified, return true also if
+ gimplify_one_sizepos would gimplify the expression into a local
+ variable. */
#define RETURN_TRUE_IF_VAR(T) \
do { tree _t = (T); \
if (_t != NULL_TREE \
&& _t != error_mark_node \
&& TREE_CODE (_t) != INTEGER_CST \
&& TREE_CODE (_t) != PLACEHOLDER_EXPR \
- && (!fn || walk_tree (&_t, find_var_from_fn, fn, NULL))) \
+ && (!fn \
+ || (!TYPE_SIZES_GIMPLIFIED (type) \
+ && !is_gimple_sizepos (_t)) \
+ || walk_tree (&_t, find_var_from_fn, fn, NULL))) \
return true; } while (0)
if (type == error_mark_node)