[PATCH] Fix PR53790
Richard Guenther
rguenther@suse.de
Thu Jun 28 11:48:00 GMT 2012
This fixes PR53790 - with MEM_REF you can get base decls of
incomplete type. Deal with that.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied
everywhere.
Richard.
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.
Index: gcc/expr.c
===================================================================
*** gcc/expr.c (revision 189041)
--- gcc/expr.c (working copy)
*************** expand_expr_real_1 (tree exp, rtx target
*** 9832,9837 ****
--- 9832,9838 ----
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: gcc/testsuite/gcc.dg/torture/pr53790.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr53790.c (revision 0)
--- gcc/testsuite/gcc.dg/torture/pr53790.c (working copy)
***************
*** 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);
+ }
More information about the Gcc-patches
mailing list