diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2020-12-04 10:04:56 +0100 |
---|---|---|
committer | Eric Botcazou <ebotcazou@adacore.com> | 2020-12-04 10:07:42 +0100 |
commit | 241a2c498005207d52a3d64884e41953fc00275c (patch) | |
tree | 06c62e18f86f6236c9ccabcbbc9313fd97de2c2a | |
parent | 9199da4b59c34cbcf2cea912b39400d7e90525d6 (diff) | |
download | gcc-241a2c498005207d52a3d64884e41953fc00275c.zip gcc-241a2c498005207d52a3d64884e41953fc00275c.tar.gz gcc-241a2c498005207d52a3d64884e41953fc00275c.tar.bz2 |
Fix checking failure in IPA-SRA
This is a regression present on the mainline and 10 branch: on the one
hand, IPA-SRA does *not* disqualify accesses with zero size but, on the
other hand, it checks that accesses present in the tree have a (strictly)
positive size, thus trivially yielding an ICE in some cases.
gcc/ChangeLog:
* ipa-sra.c (verify_access_tree_1): Relax assertion on the size.
gcc/testsuite/ChangeLog:
* gnat.dg/opt91.ads, gnat.dg/opt91.adb: New test.
* gnat.dg/opt91_pkg.ads, gnat.dg/opt91_pkg.adb: New helper.
-rw-r--r-- | gcc/ipa-sra.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt91.adb | 11 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt91.ads | 10 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt91_pkg.adb | 12 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/opt91_pkg.ads | 19 |
5 files changed, 53 insertions, 1 deletions
diff --git a/gcc/ipa-sra.c b/gcc/ipa-sra.c index 82acc6a..7adc4b6 100644 --- a/gcc/ipa-sra.c +++ b/gcc/ipa-sra.c @@ -1480,7 +1480,7 @@ verify_access_tree_1 (gensum_param_access *access, HOST_WIDE_INT parent_offset, { while (access) { - gcc_assert (access->offset >= 0 && access->size > 0); + gcc_assert (access->offset >= 0 && access->size >= 0); if (parent_size != 0) { diff --git a/gcc/testsuite/gnat.dg/opt91.adb b/gcc/testsuite/gnat.dg/opt91.adb new file mode 100644 index 0000000..b0132f8 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt91.adb @@ -0,0 +1,11 @@ +-- { dg-do compile } +-- { dg-options "-O2 -fchecking=1" } + +package body Opt91 is + + function Custom_Image (Self : True_Relation_Rec) return String is + begin + return "<True>"; + end; + +end Opt91; diff --git a/gcc/testsuite/gnat.dg/opt91.ads b/gcc/testsuite/gnat.dg/opt91.ads new file mode 100644 index 0000000..b31aa8d --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt91.ads @@ -0,0 +1,10 @@ +with Opt91_Pkg; use Opt91_Pkg; + +package Opt91 is + + type True_Relation_Rec is null record; + function Custom_Image (Self : True_Relation_Rec) return String; + + package True_Relation is new Pure_Relation (Ty => True_Relation_Rec); + +end Opt91; diff --git a/gcc/testsuite/gnat.dg/opt91_pkg.adb b/gcc/testsuite/gnat.dg/opt91_pkg.adb new file mode 100644 index 0000000..5b95fb2e --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt91_pkg.adb @@ -0,0 +1,12 @@ +package body Opt91_Pkg is + + package body Pure_Relation is + + overriding function Custom_Image (Self : Rel) return String is + begin + return Custom_Image (Self.Rel); + end Custom_Image; + + end Pure_Relation; + +end Opt91_Pkg; diff --git a/gcc/testsuite/gnat.dg/opt91_pkg.ads b/gcc/testsuite/gnat.dg/opt91_pkg.ads new file mode 100644 index 0000000..9bfd0f0 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt91_pkg.ads @@ -0,0 +1,19 @@ +package Opt91_Pkg is + + type Base_Relation is abstract tagged null record; + + function Custom_Image (Self : Base_Relation) return String is abstract; + + generic + type Ty is private; + with function Custom_Image (Self : Ty) return String is <>; + package Pure_Relation is + + type Rel is new Base_Relation with record + Rel : Ty; + end record; + + overriding function Custom_Image (Self : Rel) return String; + end Pure_Relation; + +end Opt91_Pkg; |