aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2022-10-05 12:21:03 +0200
committerEric Botcazou <ebotcazou@adacore.com>2022-10-05 13:48:57 +0200
commit853ce8eea4ff97850a987167e603387b3d0f1401 (patch)
treee3491bc0be8ba478000800fc3038f91b25a72baf /gcc/testsuite/gnat.dg
parentbcc27369910b818047bca466fbcef6a3034dfc7f (diff)
downloadgcc-853ce8eea4ff97850a987167e603387b3d0f1401.zip
gcc-853ce8eea4ff97850a987167e603387b3d0f1401.tar.gz
gcc-853ce8eea4ff97850a987167e603387b3d0f1401.tar.bz2
Fix bogus -Wstringop-overflow warning in Ada
It comes from a discrepancy between get_offset_range, which uses a signed type, and handle_array_ref, which uses an unsigned one, to do computations. gcc/ PR tree-optimization/106698 * pointer-query.cc (handle_array_ref): Fix handling of low bound. gcc/testsuite/ * gnat.dg/lto26.adb: New test. * gnat.dg/lto26_pkg1.ads, gnat.dg/lto26_pkg1.adb: New helper. * gnat.dg/lto26_pkg2.ads, gnat.dg/lto26_pkg2.adb: Likewise.
Diffstat (limited to 'gcc/testsuite/gnat.dg')
-rw-r--r--gcc/testsuite/gnat.dg/lto26.adb13
-rw-r--r--gcc/testsuite/gnat.dg/lto26_pkg1.adb11
-rw-r--r--gcc/testsuite/gnat.dg/lto26_pkg1.ads11
-rw-r--r--gcc/testsuite/gnat.dg/lto26_pkg2.adb15
-rw-r--r--gcc/testsuite/gnat.dg/lto26_pkg2.ads9
5 files changed, 59 insertions, 0 deletions
diff --git a/gcc/testsuite/gnat.dg/lto26.adb b/gcc/testsuite/gnat.dg/lto26.adb
new file mode 100644
index 0000000..a27348b
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/lto26.adb
@@ -0,0 +1,13 @@
+-- { dg-do run }
+-- { dg-options "-O2 -flto" { target lto } }
+
+with Ada.Streams; use Ada.Streams;
+with Lto26_Pkg1; use Lto26_Pkg1;
+
+procedure Lto26 is
+ R : Rec;
+begin
+ for I in 1 .. 10 loop
+ Set (R, (7, 0, 84, Stream_Element (I), 0, 0, 0), 1);
+ end loop;
+end;
diff --git a/gcc/testsuite/gnat.dg/lto26_pkg1.adb b/gcc/testsuite/gnat.dg/lto26_pkg1.adb
new file mode 100644
index 0000000..c68b134
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/lto26_pkg1.adb
@@ -0,0 +1,11 @@
+with Lto26_Pkg2; use Lto26_Pkg2;
+
+package body Lto26_Pkg1 is
+
+ procedure Set (R : Rec; A : Stream_Element_Array; C :Unsigned_8) is
+ procedure My_Build is new Build;
+ begin
+ My_Build (A, C);
+ end;
+
+end Lto26_Pkg1;
diff --git a/gcc/testsuite/gnat.dg/lto26_pkg1.ads b/gcc/testsuite/gnat.dg/lto26_pkg1.ads
new file mode 100644
index 0000000..5279747
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/lto26_pkg1.ads
@@ -0,0 +1,11 @@
+with Ada.Finalization;
+with Ada.Streams; use Ada.Streams;
+with Interfaces; use Interfaces;
+
+package Lto26_Pkg1 is
+
+ type Rec is new Ada.Finalization.Limited_Controlled with null record;
+
+ procedure Set (R : Rec; A : Stream_Element_Array; C :Unsigned_8);
+
+end Lto26_Pkg1;
diff --git a/gcc/testsuite/gnat.dg/lto26_pkg2.adb b/gcc/testsuite/gnat.dg/lto26_pkg2.adb
new file mode 100644
index 0000000..9f89733
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/lto26_pkg2.adb
@@ -0,0 +1,15 @@
+package body Lto26_Pkg2 is
+
+ procedure Build (A : Stream_Element_Array; C : Unsigned_8) is
+ Start : Stream_Element_Offset := A'First;
+ Next : Stream_Element_Offset;
+ Length : Unsigned_8;
+ begin
+ for I in 1 .. C loop
+ Length := Unsigned_8 (A (A'First));
+ Next := Start + Stream_Element_Offset (Length);
+ Start := Next;
+ end loop;
+ end;
+
+end Lto26_Pkg2;
diff --git a/gcc/testsuite/gnat.dg/lto26_pkg2.ads b/gcc/testsuite/gnat.dg/lto26_pkg2.ads
new file mode 100644
index 0000000..68741bb8
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/lto26_pkg2.ads
@@ -0,0 +1,9 @@
+with Ada.Streams; use Ada.Streams;
+with Interfaces; use Interfaces;
+
+package Lto26_Pkg2 is
+
+ generic
+ procedure Build (A : Stream_Element_Array; C : Unsigned_8);
+
+end Lto26_Pkg2;