aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2018-12-03 15:49:12 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-12-03 15:49:12 +0000
commit9f8483ca8f858ea19e3e0fcf567820e3195fe2de (patch)
tree66452a5079e3ab6a4a9e1bf0d4c9aaced7b77d29
parentc899d4bafcad17c7d493123cdf75ce4f54e0f8c1 (diff)
downloadgcc-9f8483ca8f858ea19e3e0fcf567820e3195fe2de.zip
gcc-9f8483ca8f858ea19e3e0fcf567820e3195fe2de.tar.gz
gcc-9f8483ca8f858ea19e3e0fcf567820e3195fe2de.tar.bz2
[Ada] Fix problematic overloading of operator in Ada 95 mode
The change reverts the test deciding whether an initialization procedure can be inherited from parent to derived type to the original implementation, which allowed inheriting a null procedure. This prevents the creation of another null initialization procedure for the derived type, which in turn can avoid an artificial overloading which can wreak havoc in the analysis of private declarations of a package. 2018-12-03 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * exp_ch3.adb (Build_Record_Init_Proc): Inherit an initialization procedure if it is present, even if it is null. gcc/testsuite/ * gnat.dg/overload2.adb, gnat.dg/overload2_p.adb, gnat.dg/overload2_p.ads, gnat.dg/overload2_q.adb, gnat.dg/overload2_q.ads: New testcase. From-SVN: r266753
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/exp_ch3.adb2
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gnat.dg/overload2.adb13
-rw-r--r--gcc/testsuite/gnat.dg/overload2_p.adb6
-rw-r--r--gcc/testsuite/gnat.dg/overload2_p.ads6
-rw-r--r--gcc/testsuite/gnat.dg/overload2_q.adb5
-rw-r--r--gcc/testsuite/gnat.dg/overload2_q.ads4
8 files changed, 46 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index dae6574..481f9da 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,8 @@
+2018-12-03 Eric Botcazou <ebotcazou@adacore.com>
+
+ * exp_ch3.adb (Build_Record_Init_Proc): Inherit an
+ initialization procedure if it is present, even if it is null.
+
2018-12-03 Patrick Bernardi <bernardi@adacore.com>
* libgnarl/s-taskin.ads (ATC_Level_Base): Redefine to span from
diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb
index 65f6805..35b8fe3 100644
--- a/gcc/ada/exp_ch3.adb
+++ b/gcc/ada/exp_ch3.adb
@@ -3712,7 +3712,7 @@ package body Exp_Ch3 is
and then not Is_Unchecked_Union (Rec_Type)
and then not Has_New_Non_Standard_Rep (Rec_Type)
and then not Parent_Subtype_Renaming_Discrims
- and then Has_Non_Null_Base_Init_Proc (Etype (Rec_Type))
+ and then Present (Base_Init_Proc (Etype (Rec_Type)))
then
Copy_TSS (Base_Init_Proc (Etype (Rec_Type)), Rec_Type);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fdb6f8b..b69ad66 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2018-12-03 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/overload2.adb, gnat.dg/overload2_p.adb,
+ gnat.dg/overload2_p.ads, gnat.dg/overload2_q.adb,
+ gnat.dg/overload2_q.ads: New testcase.
+
2018-12-03 Fritz Reese <fritzoreese@gmail.com>
Mark Eggleston <mark.eggleston@codethink.co.uk>
diff --git a/gcc/testsuite/gnat.dg/overload2.adb b/gcc/testsuite/gnat.dg/overload2.adb
new file mode 100644
index 0000000..56c8587
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/overload2.adb
@@ -0,0 +1,13 @@
+-- { dg-do compile }
+-- { dg-options "-gnat95" }
+
+with Overload2_P; use Overload2_P;
+with text_io; use text_io;
+procedure overload2 is
+ this, that: t;
+ yes : boolean := this /= that;
+begin
+ if not yes then
+ put_line ("FAILED");
+ end if;
+end;
diff --git a/gcc/testsuite/gnat.dg/overload2_p.adb b/gcc/testsuite/gnat.dg/overload2_p.adb
new file mode 100644
index 0000000..49343cd
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/overload2_p.adb
@@ -0,0 +1,6 @@
+-- { dg-options "-gnat95 -gnatws" }
+
+package body overload2_p is
+ function "=" (this, that: t) return boolean is begin return True; end;
+ this, that : t;
+end;
diff --git a/gcc/testsuite/gnat.dg/overload2_p.ads b/gcc/testsuite/gnat.dg/overload2_p.ads
new file mode 100644
index 0000000..8d4da74
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/overload2_p.ads
@@ -0,0 +1,6 @@
+with overload2_q;
+package overload2_p is
+ type t is new overload2_q.t;
+private
+ function "=" (this, that: t) return boolean;
+end;
diff --git a/gcc/testsuite/gnat.dg/overload2_q.adb b/gcc/testsuite/gnat.dg/overload2_q.adb
new file mode 100644
index 0000000..55a756e
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/overload2_q.adb
@@ -0,0 +1,5 @@
+-- { dg-options "-gnat95" }
+
+package body overload2_q is
+ function "=" (this, that: t) return boolean is begin return False; end;
+end;
diff --git a/gcc/testsuite/gnat.dg/overload2_q.ads b/gcc/testsuite/gnat.dg/overload2_q.ads
new file mode 100644
index 0000000..c4e89aa
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/overload2_q.ads
@@ -0,0 +1,4 @@
+package overload2_q is
+ type t is null record;
+ function "=" (this, that: t) return boolean;
+end;