OSDN Git Service

2012-06-28 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 28 Jun 2012 11:52:49 +0000 (11:52 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 28 Jun 2012 11:52:49 +0000 (11:52 +0000)
PR middle-end/53790
* expr.c (expand_expr_real_1): Verify if the type is complete
before inspecting its size.

* gcc.dg/torture/pr53790.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@189047 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr53790.c [new file with mode: 0644]

index a6fc705..a4e9daa 100644 (file)
@@ -1,3 +1,9 @@
+2012-06-28  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/53790
+       * expr.c (expand_expr_real_1): Verify if the type is complete
+       before inspecting its size.
+
 2012-06-27  Nick Clifton  <nickc@redhat.com>
 
        * config/rx/rx.md (comparesi3_extend): Remove = modifier from
 2012-06-27  Nick Clifton  <nickc@redhat.com>
 
        * config/rx/rx.md (comparesi3_extend): Remove = modifier from
index 963bb7d..1dcb9f5 100644 (file)
@@ -9657,6 +9657,7 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
        orig_op0 = op0
          = expand_expr (tem,
                         (TREE_CODE (TREE_TYPE (tem)) == UNION_TYPE
        orig_op0 = op0
          = expand_expr (tem,
                         (TREE_CODE (TREE_TYPE (tem)) == UNION_TYPE
+                         && COMPLETE_TYPE_P (TREE_TYPE (tem))
                          && (TREE_CODE (TYPE_SIZE (TREE_TYPE (tem)))
                              != INTEGER_CST)
                          && modifier != EXPAND_STACK_PARM
                          && (TREE_CODE (TYPE_SIZE (TREE_TYPE (tem)))
                              != INTEGER_CST)
                          && modifier != EXPAND_STACK_PARM
index 35d91a9..6588b52 100644 (file)
@@ -1,3 +1,8 @@
+2012-06-28  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/53790
+       * gcc.dg/torture/pr53790.c: New testcase.
+
 2012-06-27  Fabien ChĂȘne  <fabien@gcc.gnu.org>
 
        PR c++/51214
 2012-06-27  Fabien ChĂȘne  <fabien@gcc.gnu.org>
 
        PR c++/51214
diff --git a/gcc/testsuite/gcc.dg/torture/pr53790.c b/gcc/testsuite/gcc.dg/torture/pr53790.c
new file mode 100644 (file)
index 0000000..0abd3dd
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+typedef struct s {
+    int value;
+} s_t;
+
+static inline int 
+read(s_t const *var)
+{
+  return var->value;
+}
+
+int main()
+{
+  extern union u extern_var;
+  return read((s_t *)&extern_var);
+}