]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/53790 (ICE on dereferencing a extern union in asm statement)
authorRichard Guenther <rguenther@suse.de>
Thu, 28 Jun 2012 12:01:16 +0000 (12:01 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 28 Jun 2012 12:01:16 +0000 (12:01 +0000)
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.

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

From-SVN: r189048

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

index 740f812e4987745eae8137aac3e73607d94501d9..229718c6c8f912cacd5256bafb79d4b2570a6cab 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-22  Richard Guenther  <rguenther@suse.de>
 
        * gcov-iov.c: Include bconfig.h and system.h.
index 83ecc039abf09cdbb4774977141d11235e20ec4c..e4f6cae80b051fa711962b14f3b8ab7b60292c2a 100644 (file)
@@ -9184,6 +9184,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
+                         && COMPLETE_TYPE_P (TREE_TYPE (tem))
                          && (TREE_CODE (TYPE_SIZE (TREE_TYPE (tem)))
                              != INTEGER_CST)
                          && modifier != EXPAND_STACK_PARM
index 33920f8651a2faa7e8274359863e1b5ee7390362..9b46faa45bb536b4fa354d829d9934066bcc3868 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-25  Jason Merrill  <jason@redhat.com>
 
        PR c++/52988
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);
+}