aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2019-09-19 08:14:23 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-09-19 08:14:23 +0000
commit9e0746fcd5bb14d164d3686b0940ae7129d05231 (patch)
treea0925593d1b606a60ed49952f71ea5226bb4163f /gcc/testsuite
parentfd0d7b4e3be10508119636f06807f23d5691088b (diff)
downloadgcc-9e0746fcd5bb14d164d3686b0940ae7129d05231.zip
gcc-9e0746fcd5bb14d164d3686b0940ae7129d05231.tar.gz
gcc-9e0746fcd5bb14d164d3686b0940ae7129d05231.tar.bz2
[Ada] Fix bogus visibility error with nested generics and inlining
This prevents the compiler from issuing a bogus error about the visibility of an operator in an instantiation of a nested generic package which is itself used as an actual of an instantiation of another generic package, when the instantiations are done in a unit withed from the main unit and containing an inlined subprogram, and cross-unit inlining is enabled. In most cases, the compiler does not check the visibility of operators in an instantiation context because this has already been done when the generic package has been analyzed. However, there are exceptions like the actuals of an instantiation of a generic child unit which is done as a compilation unit and the In_Instance predicate has a special check for these cases. This check would incorrectly trigger here and needs to be tightened. 2019-09-19 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * sem_util.adb (In_Instance): Test whether the current unit has been analyzed instead of being on the scope stack to detect the case of actuals of an instantiation of a generic child unit done as a compilation unit. gcc/testsuite/ * gnat.dg/inline20.adb, gnat.dg/inline20_g.adb, gnat.dg/inline20_g.ads, gnat.dg/inline20_h.ads, gnat.dg/inline20_i.ads, gnat.dg/inline20_q-io.ads, gnat.dg/inline20_q.ads, gnat.dg/inline20_r.ads: New testcase. From-SVN: r275952
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gnat.dg/inline20.adb9
-rw-r--r--gcc/testsuite/gnat.dg/inline20_g.adb18
-rw-r--r--gcc/testsuite/gnat.dg/inline20_g.ads18
-rw-r--r--gcc/testsuite/gnat.dg/inline20_h.ads15
-rw-r--r--gcc/testsuite/gnat.dg/inline20_i.ads19
-rw-r--r--gcc/testsuite/gnat.dg/inline20_q-io.ads1
-rw-r--r--gcc/testsuite/gnat.dg/inline20_q.ads3
-rw-r--r--gcc/testsuite/gnat.dg/inline20_r.ads12
9 files changed, 102 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a3534f1..f667897 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2019-09-19 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/inline20.adb, gnat.dg/inline20_g.adb,
+ gnat.dg/inline20_g.ads, gnat.dg/inline20_h.ads,
+ gnat.dg/inline20_i.ads, gnat.dg/inline20_q-io.ads,
+ gnat.dg/inline20_q.ads, gnat.dg/inline20_r.ads: New testcase.
+
2019-09-19 Ed Schonberg <schonberg@adacore.com>
* gnat.dg/generic2-child.ads, gnat.dg/generic2-io_any.adb,
diff --git a/gcc/testsuite/gnat.dg/inline20.adb b/gcc/testsuite/gnat.dg/inline20.adb
new file mode 100644
index 0000000..dde9a53
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/inline20.adb
@@ -0,0 +1,9 @@
+-- { dg-do compile }
+-- { dg-options "-O -gnatn2" }
+with Inline20_Q.IO;
+with Inline20_R;
+
+procedure Inline20 is
+begin
+ Inline20_R.Log (Inline20_Q.IO.F);
+end;
diff --git a/gcc/testsuite/gnat.dg/inline20_g.adb b/gcc/testsuite/gnat.dg/inline20_g.adb
new file mode 100644
index 0000000..dbae596
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/inline20_g.adb
@@ -0,0 +1,18 @@
+with Ada.Streams; use Ada.Streams;
+
+package body Inline20_G is
+
+ package body Nested_G is
+
+ procedure Get (Data : T; Into : out Offset_Type) is
+ begin
+ Into := (T'Descriptor_Size + Data'Size) / Standard'Storage_Unit;
+ end;
+
+ function F return Integer is
+ begin
+ return 0;
+ end;
+ end Nested_G;
+
+end Inline20_G;
diff --git a/gcc/testsuite/gnat.dg/inline20_g.ads b/gcc/testsuite/gnat.dg/inline20_g.ads
new file mode 100644
index 0000000..adf2df6
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/inline20_g.ads
@@ -0,0 +1,18 @@
+with Ada.Streams;
+
+generic
+package Inline20_G is
+
+ subtype Offset_Type is Ada.Streams.Stream_Element_Offset;
+
+ generic
+ type T is private;
+ package Nested_G is
+
+ procedure Get (Data : T; Into : out Offset_Type);
+
+ function F return Integer with Inline;
+
+ end Nested_G;
+
+end Inline20_G;
diff --git a/gcc/testsuite/gnat.dg/inline20_h.ads b/gcc/testsuite/gnat.dg/inline20_h.ads
new file mode 100644
index 0000000..5937798
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/inline20_h.ads
@@ -0,0 +1,15 @@
+with Inline20_G;
+
+generic
+ with package Msg is new Inline20_G (<>);
+package Inline20_H is
+
+ generic
+ type T is private;
+ with function Image (Data : T) return String;
+ package Nested_H is
+ package My_Nested_G is new Msg.Nested_G (T);
+ function F return Integer renames My_Nested_G.F;
+ end Nested_H;
+
+end Inline20_H;
diff --git a/gcc/testsuite/gnat.dg/inline20_i.ads b/gcc/testsuite/gnat.dg/inline20_i.ads
new file mode 100644
index 0000000..d946375
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/inline20_i.ads
@@ -0,0 +1,19 @@
+with Inline20_R;
+
+generic
+package Inline20_I is
+
+ type Rec is null record;
+
+ generic
+ package Generic_IO is
+
+ function Image (Quote : Rec) return String;
+
+ package My_Nested_H is new Inline20_R.My_H.Nested_H (Rec, Image);
+
+ function F return Integer renames My_Nested_H.F;
+
+ end Generic_IO;
+
+end Inline20_I; \ No newline at end of file
diff --git a/gcc/testsuite/gnat.dg/inline20_q-io.ads b/gcc/testsuite/gnat.dg/inline20_q-io.ads
new file mode 100644
index 0000000..8e81887
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/inline20_q-io.ads
@@ -0,0 +1 @@
+package Inline20_Q.IO is new Inline20_Q.Generic_IO;
diff --git a/gcc/testsuite/gnat.dg/inline20_q.ads b/gcc/testsuite/gnat.dg/inline20_q.ads
new file mode 100644
index 0000000..08c81cd
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/inline20_q.ads
@@ -0,0 +1,3 @@
+with Inline20_I;
+
+package Inline20_Q is new Inline20_I;
diff --git a/gcc/testsuite/gnat.dg/inline20_r.ads b/gcc/testsuite/gnat.dg/inline20_r.ads
new file mode 100644
index 0000000..4b96f75
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/inline20_r.ads
@@ -0,0 +1,12 @@
+with Inline20_G;
+with Inline20_H;
+
+package Inline20_R is
+
+ package My_G is new Inline20_G;
+
+ package My_H is new Inline20_H (My_G);
+
+ procedure Log (I : Integer);
+
+end Inline20_R;