aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2017-01-19 12:51:22 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2017-01-19 12:51:22 +0100
commit0929d66bf81be1b0fca5537d946cd068dd731f99 (patch)
tree27e5a6435029e91ddba30a57d86b60a06a5b3912 /gcc
parentc63a2ad68bc0704fc2926badc46f3ccd952dbbb9 (diff)
downloadgcc-0929d66bf81be1b0fca5537d946cd068dd731f99.zip
gcc-0929d66bf81be1b0fca5537d946cd068dd731f99.tar.gz
gcc-0929d66bf81be1b0fca5537d946cd068dd731f99.tar.bz2
[multiple changes]
2017-01-19 Ed Schonberg <schonberg@adacore.com> * sem_ch4.ads, sem_ch4.adb (Try_Object_Operation): Make subprogram public, for use elsewhere. * sem_ch6.adb (Analyze_Procedure_Call): In SPARK_Mode and within an Inlined_body, recognize a call that uses object notation and has not been rewritten as a regular call because regular expansion has not taken place. 2017-01-19 Bob Duff <duff@adacore.com> * checks.adb (Apply_Type_Conversion_Checks): Disable small optimization in case of generic formal discrete types, because it causes crashes in the compiler when built with assertions on. From-SVN: r244620
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog15
-rw-r--r--gcc/ada/checks.adb11
-rw-r--r--gcc/ada/sem_ch4.adb12
-rw-r--r--gcc/ada/sem_ch4.ads14
-rw-r--r--gcc/ada/sem_ch6.adb26
5 files changed, 60 insertions, 18 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 7f7fcd8..5eda557 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,18 @@
+2017-01-19 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_ch4.ads, sem_ch4.adb (Try_Object_Operation): Make subprogram
+ public, for use elsewhere.
+ * sem_ch6.adb (Analyze_Procedure_Call): In SPARK_Mode and within
+ an Inlined_body, recognize a call that uses object notation
+ and has not been rewritten as a regular call because regular
+ expansion has not taken place.
+
+2017-01-19 Bob Duff <duff@adacore.com>
+
+ * checks.adb (Apply_Type_Conversion_Checks): Disable small optimization
+ in case of generic formal discrete types, because it causes crashes in
+ the compiler when built with assertions on.
+
2017-01-19 Hristian Kirtchev <kirtchev@adacore.com>
* lib-xref-spark_specific.adb, sem_util.adb, sem_util.ads,
diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index 80b4b4b..1e2231b 100644
--- a/gcc/ada/checks.adb
+++ b/gcc/ada/checks.adb
@@ -3391,14 +3391,17 @@ package body Checks is
and then not Float_To_Int
then
-- A small optimization: the attribute 'Pos applied to an
- -- enumeration type has a known range, even though its type
- -- is Universal_Integer. So in numeric conversions it is
- -- usually within range of the target integer type. Use the
- -- static bounds of the base types to check.
+ -- enumeration type has a known range, even though its type is
+ -- Universal_Integer. So in numeric conversions it is usually
+ -- within range of the target integer type. Use the static
+ -- bounds of the base types to check. Disable this optimization
+ -- in case of a generic formal discrete type, because we don't
+ -- necessarily know the upper bound yet.
if Nkind (Expr) = N_Attribute_Reference
and then Attribute_Name (Expr) = Name_Pos
and then Is_Enumeration_Type (Etype (Prefix (Expr)))
+ and then not Is_Generic_Type (Etype (Prefix (Expr)))
and then Is_Integer_Type (Target_Type)
then
declare
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index db41afb..56da406 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -323,18 +323,6 @@ package body Sem_Ch4 is
-- subprogram, and the call F (X) interpreted as F.all (X). In this case
-- the call may be overloaded with both interpretations.
- function Try_Object_Operation
- (N : Node_Id;
- CW_Test_Only : Boolean := False) return Boolean;
- -- Ada 2005 (AI-252): Support the object.operation notation. If node N
- -- is a call in this notation, it is transformed into a normal subprogram
- -- call where the prefix is a parameter, and True is returned. If node
- -- N is not of this form, it is unchanged, and False is returned. If
- -- CW_Test_Only is true then N is an N_Selected_Component node which
- -- is part of a call to an entry or procedure of a tagged concurrent
- -- type and this routine is invoked to search for class-wide subprograms
- -- conflicting with the target entity.
-
procedure wpo (T : Entity_Id);
pragma Warnings (Off, wpo);
-- Used for debugging: obtain list of primitive operations even if
diff --git a/gcc/ada/sem_ch4.ads b/gcc/ada/sem_ch4.ads
index 0a19643..a6105c1 100644
--- a/gcc/ada/sem_ch4.ads
+++ b/gcc/ada/sem_ch4.ads
@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
--- Copyright (C) 1992-2012, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -64,4 +64,16 @@ package Sem_Ch4 is
-- The resolution of the construct requires some semantic information
-- on the prefix and the indexes.
+ function Try_Object_Operation
+ (N : Node_Id;
+ CW_Test_Only : Boolean := False) return Boolean;
+ -- Ada 2005 (AI-252): Support the object.operation notation. If node N
+ -- is a call in this notation, it is transformed into a normal subprogram
+ -- call where the prefix is a parameter, and True is returned. If node
+ -- N is not of this form, it is unchanged, and False is returned. If
+ -- CW_Test_Only is true then N is an N_Selected_Component node which
+ -- is part of a call to an entry or procedure of a tagged concurrent
+ -- type and this routine is invoked to search for class-wide subprograms
+ -- conflicting with the target entity.
+
end Sem_Ch4;
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index 21f0769..6e4818d 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -1711,7 +1711,31 @@ package body Sem_Ch6 is
E_Function,
E_Procedure)
then
- Analyze_Call_And_Resolve;
+ -- When front-end inlining is enabled, as with SPARK_Mode, a call
+ -- in prefix notation may still be missing its controlling argument,
+ -- so perform the transformation now.
+
+ if SPARK_Mode = On and then In_Inlined_Body then
+ declare
+ Subp : constant Entity_Id := Entity (Selector_Name (P));
+ Typ : constant Entity_Id := Etype (Prefix (P));
+
+ begin
+ if Is_Tagged_Type (Typ)
+ and then Present (First_Formal (Subp))
+ and then Etype (First_Formal (Subp)) = Typ
+ and then Try_Object_Operation (P)
+ then
+ return;
+
+ else
+ Analyze_Call_And_Resolve;
+ end if;
+ end;
+
+ else
+ Analyze_Call_And_Resolve;
+ end if;
elsif Nkind (P) = N_Selected_Component
and then Ekind (Entity (Selector_Name (P))) = E_Entry_Family