re PR middle-end/20739 (ICE in gimplify_addr_expr)
authorAlexandre Oliva <aoliva@redhat.com>
Fri, 15 Apr 2005 03:09:50 +0000 (03:09 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Fri, 15 Apr 2005 03:09:50 +0000 (03:09 +0000)
gcc/ChangeLog:
PR middle-end/20739
* gimplify.c (gimplify_addr_expr): Compensate for removal of
e.g. cv-qualification conversions.
gcc/testsuite/ChangeLog:
PR middle-end/20739
* gcc.dg/tree-ssa/pr20739.c: New test.

From-SVN: r98167

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr20739.c [new file with mode: 0644]

index 6cd1f287de21ad8e4f4db4a908ef74cdb2acb45b..f06d0597ba544b6f0dc7ef206ed07d8e5f688a7a 100644 (file)
@@ -1,3 +1,9 @@
+2005-04-15  Alexandre Oliva  <aoliva@redhat.com>
+
+       PR middle-end/20739
+       * gimplify.c (gimplify_addr_expr): Compensate for removal of
+       e.g. cv-qualification conversions.
+
 2005-04-14  Mike Stump  <mrs@apple.com>
 
        * config/darwin-c.c (framework_construct_pathname): We must
index 23713df01defc1ed52d015644540cac8713058f4..5eb1d49bd1ce043035012eb5ad4332fcec959900 100644 (file)
@@ -3229,6 +3229,9 @@ gimplify_addr_expr (tree *expr_p, tree *pre_p, tree *post_p)
         builtins like __builtin_va_end).  */
       /* Caution: the silent array decomposition semantics we allow for
         ADDR_EXPR means we can't always discard the pair.  */
+      /* Gimplification of the ADDR_EXPR operand may drop
+        cv-qualification conversions, so make sure we add them if
+        needed.  */
       {
        tree op00 = TREE_OPERAND (op0, 0);
        tree t_expr = TREE_TYPE (expr);
@@ -3238,9 +3241,9 @@ gimplify_addr_expr (tree *expr_p, tree *pre_p, tree *post_p)
          {
 #ifdef ENABLE_CHECKING
            tree t_op0 = TREE_TYPE (op0);
-           gcc_assert (TREE_CODE (t_op0) == ARRAY_TYPE
-                       && POINTER_TYPE_P (t_expr)
-                       && cpt_same_type (TREE_TYPE (t_op0),
+           gcc_assert (POINTER_TYPE_P (t_expr)
+                       && cpt_same_type (TREE_CODE (t_op0) == ARRAY_TYPE
+                                         ? TREE_TYPE (t_op0) : t_op0,
                                          TREE_TYPE (t_expr))
                        && POINTER_TYPE_P (t_op00)
                        && cpt_same_type (t_op0, TREE_TYPE (t_op00)));
index b480eeafd48eb8dc79c9c118884472570c2e6df7..5d78e17783dd7496880882b933e80539e8ee6f48 100644 (file)
@@ -1,3 +1,8 @@
+2005-04-15  Alexandre Oliva  <aoliva@redhat.com>
+
+       PR middle-end/20739
+       * gcc.dg/tree-ssa/pr20739.c: New test.
+
 2005-04-14  Mike Stump  <mrs@apple.com>
 
        * gcc.dg/Foundation.framework/empty: New.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr20739.c b/gcc/testsuite/gcc.dg/tree-ssa/pr20739.c
new file mode 100644 (file)
index 0000000..c1e7b58
--- /dev/null
@@ -0,0 +1,24 @@
+/* PR middle-end/20739 */
+
+/* dg-do compile */
+/* dg-options "-O" */
+
+/* We used to fail to compile this because gimplification dropped the
+   conversion that added the const qualifier to the sub-expression
+   involving baz, and then immediately noticed and reported its
+   absence.  */
+
+typedef struct 
+{ 
+    char chars[5]; 
+} 
+baz_t; 
+extern baz_t * baz; 
+extern void foo (baz_t); 
+int 
+bar (const baz_t * ls) 
+{ 
+    foo (ls == 0 ? *(&baz[0]) : *ls); 
+}