From: Marek Polacek Date: Thu, 1 Oct 2015 14:53:10 +0000 (+0000) Subject: re PR c/65345 (ICE with _Generic selection on _Atomic int) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f6f69fb09c5f81dff3b9edcd03f5107d96e10a55;p=gcc.git re PR c/65345 (ICE with _Generic selection on _Atomic int) PR c/65345 * config/i386/i386.c (ix86_atomic_assign_expand_fenv): Adjust to use create_tmp_var_raw rather than create_tmp_var. * gcc.dg/atomic/pr65345-4.c: New test. * gcc.dg/pr65345-3.c: New test. From-SVN: r228343 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c9f987ea815..eac6a74e0aa 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-10-01 Marek Polacek + + PR c/65345 + * config/i386/i386.c (ix86_atomic_assign_expand_fenv): Adjust to use + create_tmp_var_raw rather than create_tmp_var. + 2015-10-01 Marek Polacek PR tree-optimization/67769 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index fe9c756ba2f..cfeba76e8f2 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -53128,13 +53128,13 @@ ix86_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update) { if (!TARGET_80387 && !TARGET_SSE_MATH) return; - tree exceptions_var = create_tmp_var (integer_type_node); + tree exceptions_var = create_tmp_var_raw (integer_type_node); if (TARGET_80387) { tree fenv_index_type = build_index_type (size_int (6)); tree fenv_type = build_array_type (unsigned_type_node, fenv_index_type); - tree fenv_var = create_tmp_var (fenv_type); - mark_addressable (fenv_var); + tree fenv_var = create_tmp_var_raw (fenv_type); + TREE_ADDRESSABLE (fenv_var) = 1; tree fenv_ptr = build_pointer_type (fenv_type); tree fenv_addr = build1 (ADDR_EXPR, fenv_ptr, fenv_var); fenv_addr = fold_convert (ptr_type_node, fenv_addr); @@ -53144,10 +53144,12 @@ ix86_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update) tree fnclex = ix86_builtins[IX86_BUILTIN_FNCLEX]; tree hold_fnstenv = build_call_expr (fnstenv, 1, fenv_addr); tree hold_fnclex = build_call_expr (fnclex, 0); - *hold = build2 (COMPOUND_EXPR, void_type_node, hold_fnstenv, + fenv_var = build4 (TARGET_EXPR, fenv_type, fenv_var, hold_fnstenv, + NULL_TREE, NULL_TREE); + *hold = build2 (COMPOUND_EXPR, void_type_node, fenv_var, hold_fnclex); *clear = build_call_expr (fnclex, 0); - tree sw_var = create_tmp_var (short_unsigned_type_node); + tree sw_var = create_tmp_var_raw (short_unsigned_type_node); tree fnstsw_call = build_call_expr (fnstsw, 0); tree sw_mod = build2 (MODIFY_EXPR, short_unsigned_type_node, sw_var, fnstsw_call); @@ -53161,8 +53163,8 @@ ix86_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update) } if (TARGET_SSE_MATH) { - tree mxcsr_orig_var = create_tmp_var (unsigned_type_node); - tree mxcsr_mod_var = create_tmp_var (unsigned_type_node); + tree mxcsr_orig_var = create_tmp_var_raw (unsigned_type_node); + tree mxcsr_mod_var = create_tmp_var_raw (unsigned_type_node); tree stmxcsr = ix86_builtins[IX86_BUILTIN_STMXCSR]; tree ldmxcsr = ix86_builtins[IX86_BUILTIN_LDMXCSR]; tree stmxcsr_hold_call = build_call_expr (stmxcsr, 0); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1d4713d6799..e7e22461de5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-10-01 Marek Polacek + + PR c/65345 + * gcc.dg/atomic/pr65345-4.c: New test. + * gcc.dg/pr65345-3.c: New test. + 2015-10-01 Marek Polacek PR tree-optimization/67769 diff --git a/gcc/testsuite/gcc.dg/atomic/pr65345-4.c b/gcc/testsuite/gcc.dg/atomic/pr65345-4.c new file mode 100644 index 00000000000..6d44def7c2d --- /dev/null +++ b/gcc/testsuite/gcc.dg/atomic/pr65345-4.c @@ -0,0 +1,58 @@ +/* PR c/65345 */ +/* { dg-options "" } */ + +#define CHECK(X) if (!(X)) __builtin_abort () + +_Atomic float i = 5; +_Atomic float j = 2; + +void +fn1 (float a[(int) (i = 0)]) +{ +} + +void +fn2 (float a[(int) (i += 2)]) +{ +} + +void +fn3 (float a[(int) ++i]) +{ +} + +void +fn4 (float a[(int) ++i]) +{ +} + +void +fn5 (float a[(int) ++i][(int) (j = 10)]) +{ +} + +void +fn6 (float a[(int) (i = 7)][(int) j--]) +{ +} + +int +main () +{ + float a[10]; + float aa[10][10]; + fn1 (a); + CHECK (i == 0); + fn2 (a); + CHECK (i == 2); + fn3 (a); + CHECK (i == 3); + fn4 (a); + CHECK (i == 4); + fn5 (aa); + CHECK (i == 5); + CHECK (j == 10); + fn6 (aa); + CHECK (i == 7); + CHECK (j == 9); +} diff --git a/gcc/testsuite/gcc.dg/pr65345-3.c b/gcc/testsuite/gcc.dg/pr65345-3.c new file mode 100644 index 00000000000..cda9364628e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr65345-3.c @@ -0,0 +1,35 @@ +/* PR c/65345 */ +/* { dg-options "" } */ + +_Atomic float i = 3.0f; + +float a1 = sizeof (i + 1.2); +float a2 = sizeof (i = 0); +float a3 = sizeof (i++); +float a4 = sizeof (i--); +float a5 = sizeof (-i); + +float b1 = _Alignof (i + 1); +float b2 = _Alignof (i = 0); +float b3 = _Alignof (i++); +float b4 = _Alignof (i--); +float b5 = _Alignof (-i); + +float c1 = i; /* { dg-error "initializer element is not constant" } */ +float c2 = (i ? 1 : 2); /* { dg-error "initializer element is not constant" } */ +float c3[(int) i]; /* { dg-error "variably modified" } */ +float c4 = 0 || i; /* { dg-error "initializer element is not constant" } */ +float c5 = (i += 10); /* { dg-error "initializer element is not constant" } */ + +_Static_assert (_Generic (i, float: 1, default: 0) == 1, "1"); +_Static_assert (_Generic (i + 1, float: 1, default: 0) == 1, "2"); +_Static_assert (_Generic (i = 0, float: 1, default: 0) == 1, "3"); +_Static_assert (_Generic (i++, float: 1, default: 0) == 1, "4"); +_Static_assert (_Generic (i--, float: 1, default: 0) == 1, "5"); + +_Atomic int sz = 2; +void fn1 (float a[sz + 1]); +void fn2 (float a[sz = 0]); +void fn3 (float a[sz++]); +void fn4 (float a[sz--]); +void fn5 (float a[-sz]);