diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2023-05-29 09:45:57 +0200 |
---|---|---|
committer | Eric Botcazou <ebotcazou@adacore.com> | 2023-05-29 11:13:08 +0200 |
commit | 3fa303becdc877a77e67e04401a50246dd05bd81 (patch) | |
tree | 59900ba53dca1cb3243791b1ac1ac81f1f994ac8 /gcc/testsuite/gnat.dg | |
parent | 6c2b2de098af7d3bf42126301438b70ad1279bcd (diff) | |
download | gcc-3fa303becdc877a77e67e04401a50246dd05bd81.zip gcc-3fa303becdc877a77e67e04401a50246dd05bd81.tar.gz gcc-3fa303becdc877a77e67e04401a50246dd05bd81.tar.bz2 |
Fix artificial overflow during GENERIC folding
The Ada compiler gives a bogus warning:
storage_offset1.ads:16:52: warning: Constraint_Error will be raised at run
time [enabled by default]
Ironically enough, this occurs because of an intermediate conversion to an
unsigned type which is supposed to hide overflows but is counter-productive
for constants because TREE_OVERFLOW is always set for them, so it ends up
setting a bogus TREE_OVERFLOW when converting back to the original type.
The fix simply redirects INTEGER_CSTs to the other, direct path without the
intermediate conversion to the unsigned type.
gcc/
* match.pd ((T)P - (T)(P + A) -> -(T) A): Avoid artificial overflow
on constants.
gcc/testsuite/
* gnat.dg/specs/storage_offset1.ads: New test.
Diffstat (limited to 'gcc/testsuite/gnat.dg')
-rw-r--r-- | gcc/testsuite/gnat.dg/specs/storage_offset1.ads | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/testsuite/gnat.dg/specs/storage_offset1.ads b/gcc/testsuite/gnat.dg/specs/storage_offset1.ads new file mode 100644 index 0000000..f0f7a61 --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/storage_offset1.ads @@ -0,0 +1,18 @@ +-- { dg-do compile } + +with System.Storage_Elements; use System.Storage_Elements; +with System; + +package Storage_Offset1 is + + type Rec is record + I1, I2 : Integer; + end record; + + type Ptr is access all Rec; + + R : Ptr := new Rec; + + Offset : constant Storage_Offset := R.I1'Address - R.I2'Address; + +end Storage_Offset1; |