]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add testcase for PR ada/113536
authorEric Botcazou <ebotcazou@adacore.com>
Sun, 5 Oct 2025 08:42:25 +0000 (10:42 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Sun, 5 Oct 2025 08:42:25 +0000 (10:42 +0200)
gcc/testsuite/
PR ada/113536
* gnat.dg/reduce2.adb: New test.

gcc/testsuite/gnat.dg/reduce2.adb [new file with mode: 0644]

diff --git a/gcc/testsuite/gnat.dg/reduce2.adb b/gcc/testsuite/gnat.dg/reduce2.adb
new file mode 100644 (file)
index 0000000..0246709
--- /dev/null
@@ -0,0 +1,18 @@
+-- { dg-do compile }
+-- { dg-options "-gnat2022" }
+
+procedure Reduce2 is
+
+  subtype Value is Natural range 0 .. 255;
+
+  function Do_Something (Accumulator : Value; Symbol : Character) return Value
+    is (((Accumulator + Character'Pos (Symbol)) * 17) mod 256);
+
+  function Do_It_By_Reduction (S : String) return Value is
+    (S'Reduce (Do_Something, 0));
+
+  Test_It : constant Value := Do_It_By_Reduction ("Hello, world!");
+
+begin
+  null;
+end;