summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gnat.dg
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gnat.dg')
-rw-r--r--gcc/testsuite/gnat.dg/opt21.adb11
-rw-r--r--gcc/testsuite/gnat.dg/opt21_pkg.adb17
-rw-r--r--gcc/testsuite/gnat.dg/opt21_pkg.ads15
3 files changed, 43 insertions, 0 deletions
diff --git a/gcc/testsuite/gnat.dg/opt21.adb b/gcc/testsuite/gnat.dg/opt21.adb
new file mode 100644
index 00000000000..c73fe9f228f
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/opt21.adb
@@ -0,0 +1,11 @@
+-- { dg-do run }
+-- { dg-options "-O2" }
+
+with System;
+with Opt21_Pkg; use Opt21_Pkg;
+
+procedure Opt21 is
+ V : System.Address := Convert (null);
+begin
+ null;
+end;
diff --git a/gcc/testsuite/gnat.dg/opt21_pkg.adb b/gcc/testsuite/gnat.dg/opt21_pkg.adb
new file mode 100644
index 00000000000..3c87321dbff
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/opt21_pkg.adb
@@ -0,0 +1,17 @@
+package body Opt21_Pkg is
+
+ function Get_Object (Object : not null access R) return System.Address is
+ begin
+ return Object.Ptr;
+ end;
+
+ function Convert (W : Obj) return System.Address is
+ begin
+ if W = null then
+ return System.Null_Address;
+ else
+ return Get_Object (W);
+ end if;
+ end;
+
+end Opt21_Pkg;
diff --git a/gcc/testsuite/gnat.dg/opt21_pkg.ads b/gcc/testsuite/gnat.dg/opt21_pkg.ads
new file mode 100644
index 00000000000..251bf847748
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/opt21_pkg.ads
@@ -0,0 +1,15 @@
+with System;
+
+package Opt21_Pkg is
+
+ type R is record
+ Ptr : System.Address := System.Null_Address;
+ end record;
+
+ type Obj is access all R;
+
+ function Get_Object (Object : not null access R) return System.Address;
+
+ function Convert (W : Obj) return System.Address;
+
+end Opt21_Pkg;