diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2022-07-14 12:15:35 +0200 |
---|---|---|
committer | Eric Botcazou <ebotcazou@adacore.com> | 2022-07-14 12:18:42 +0200 |
commit | b0f02eeb906b6351099ac97066ef74b6167d9ecb (patch) | |
tree | a2328234213a4e55c84fe46648ec6aab7f60a56b /gcc/testsuite/gnat.dg | |
parent | 9f7f04998964451ff487b546d77ea48d0ce01451 (diff) | |
download | gcc-b0f02eeb906b6351099ac97066ef74b6167d9ecb.zip gcc-b0f02eeb906b6351099ac97066ef74b6167d9ecb.tar.gz gcc-b0f02eeb906b6351099ac97066ef74b6167d9ecb.tar.bz2 |
Fix ICE on view conversion between struct and integer
This happens from prepare_gimple_addressable for the variable to be marked
with DECL_NOT_GIMPLE_REG_P when its initialization is gimplified, so it's
apparently just a matter of setting the flag earlier.
gcc/
* gimplify.cc (lookup_tmp_var): Add NOT_GIMPLE_REG boolean parameter
and set DECL_NOT_GIMPLE_REG_P on the variable according to it.
(internal_get_tmp_var): Add NOT_GIMPLE_REG boolean parameter and
pass it in the call to lookup_tmp_var.
(get_formal_tmp_var): Pass false in the call to lookup_tmp_var.
(get_initialized_tmp_var): Likewise.
(prepare_gimple_addressable): Call internal_get_tmp_var instead of
get_initialized_tmp_var with NOT_GIMPLE_REG set to true.
gcc/testsuite/
* gnat.dg/opt98.ads, gnat.dg/opt98.adb: New test.
Diffstat (limited to 'gcc/testsuite/gnat.dg')
-rw-r--r-- | gcc/testsuite/gnat.dg/opt98.adb | 14 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt98.ads | 19 |
2 files changed, 33 insertions, 0 deletions
diff --git a/gcc/testsuite/gnat.dg/opt98.adb b/gcc/testsuite/gnat.dg/opt98.adb new file mode 100644 index 0000000..6d42338 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt98.adb @@ -0,0 +1,14 @@ +-- { dg-do compile } +-- { dg-options "-O -gnatws" } + +package body Opt98 is + + function Func return Rec is + R :Rec; + begin + A := To_Address ((I => 0)); + R := To_Rec (A); + return R; + end; + +end Opt98; diff --git a/gcc/testsuite/gnat.dg/opt98.ads b/gcc/testsuite/gnat.dg/opt98.ads new file mode 100644 index 0000000..fcc70577 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt98.ads @@ -0,0 +1,19 @@ +with Ada.Unchecked_Conversion; +with System; + +package Opt98 is + + type Rec is record + I : Integer; + end record; + + function To_Address is new Ada.Unchecked_Conversion (Rec, System.Address); + + function To_Rec is new Ada.Unchecked_Conversion (System.Address, Rec); + + A : System.Address with Atomic; + + function Func return Rec; + +end Opt98; + |