aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorVincent Pucci <pucci@adacore.com>2012-03-15 09:11:57 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2012-03-15 10:11:57 +0100
commitb3e42de5be47e747f427cda06482e2bddc3b9947 (patch)
tree5df50424df7a99df4de4e32954b6f54cc9a79869 /gcc
parent2a1b208c0c0ff053d205c576c34377ce0c948b52 (diff)
downloadgcc-b3e42de5be47e747f427cda06482e2bddc3b9947.zip
gcc-b3e42de5be47e747f427cda06482e2bddc3b9947.tar.gz
gcc-b3e42de5be47e747f427cda06482e2bddc3b9947.tar.bz2
sem.ads, sem.adb (Preanalyze): New routine.
2012-03-15 Vincent Pucci <pucci@adacore.com> * sem.ads, sem.adb (Preanalyze): New routine. * sem_ch4.adb (Analyze_Quantified_Expression): Call to the Preanalyze routine in Sem added. Renaming of Needs_Expansion into Need_Preanalysis. * sem_ch6.adb (Preanalyze): Removed. From-SVN: r185421
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog8
-rw-r--r--gcc/ada/sem.adb17
-rw-r--r--gcc/ada/sem.ads7
-rw-r--r--gcc/ada/sem_ch4.adb51
-rw-r--r--gcc/ada/sem_ch6.adb22
5 files changed, 63 insertions, 42 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 864c3dd..1617c1a 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,11 @@
+2012-03-15 Vincent Pucci <pucci@adacore.com>
+
+ * sem.ads, sem.adb (Preanalyze): New routine.
+ * sem_ch4.adb (Analyze_Quantified_Expression): Call to the
+ Preanalyze routine in Sem added. Renaming of Needs_Expansion
+ into Need_Preanalysis.
+ * sem_ch6.adb (Preanalyze): Removed.
+
2012-03-15 Robert Dewar <dewar@adacore.com>
* sem_ch4.adb (Analyze_Quantified_Expression): Add comment.
diff --git a/gcc/ada/sem.adb b/gcc/ada/sem.adb
index fdd6ec3..6966f45 100644
--- a/gcc/ada/sem.adb
+++ b/gcc/ada/sem.adb
@@ -1288,6 +1288,23 @@ package body Sem is
Scope_Stack.Release;
end Lock;
+ ----------------
+ -- Preanalyze --
+ ----------------
+
+ procedure Preanalyze (N : Node_Id) is
+ Save_Full_Analysis : constant Boolean := Full_Analysis;
+
+ begin
+ Full_Analysis := False;
+ Expander_Mode_Save_And_Set (False);
+
+ Analyze (N);
+
+ Expander_Mode_Restore;
+ Full_Analysis := Save_Full_Analysis;
+ end Preanalyze;
+
--------------------------------------
-- Push_Global_Suppress_Stack_Entry --
--------------------------------------
diff --git a/gcc/ada/sem.ads b/gcc/ada/sem.ads
index 7dec902..3fa25f9 100644
--- a/gcc/ada/sem.ads
+++ b/gcc/ada/sem.ads
@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
--- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2012, 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- --
@@ -644,6 +644,11 @@ package Sem is
-- is False, then the status of the check can be determined simply by
-- examining Scope_Checks (C), so this routine is not called in that case.
+ procedure Preanalyze (N : Node_Id);
+ -- Performs a pre-analysis of node N. During pre-analysis no expansion is
+ -- carried out for N or its children. For more info on pre-analysis read
+ -- the spec of Sem.
+
generic
with procedure Action (Item : Node_Id);
procedure Walk_Library_Items;
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index 5ab5d3f..ffc3a27 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -29,7 +29,6 @@ with Debug; use Debug;
with Einfo; use Einfo;
with Elists; use Elists;
with Errout; use Errout;
-with Expander; use Expander;
with Exp_Util; use Exp_Util;
with Fname; use Fname;
with Itypes; use Itypes;
@@ -3391,22 +3390,33 @@ package body Sem_Ch4 is
-----------------------------------
procedure Analyze_Quantified_Expression (N : Node_Id) is
- Loc : constant Source_Ptr := Sloc (N);
- Ent : constant Entity_Id :=
- New_Internal_Entity
- (E_Loop, Current_Scope, Sloc (N), 'L');
- Needs_Expansion : constant Boolean :=
- Operating_Mode /= Check_Semantics
- and then not Alfa_Mode;
+ Loc : constant Source_Ptr := Sloc (N);
+ Ent : constant Entity_Id :=
+ New_Internal_Entity (E_Loop, Current_Scope, Sloc (N), 'L');
+
+ Need_Preanalysis : constant Boolean :=
+ Operating_Mode /= Check_Semantics
+ and then not Alfa_Mode;
Iterator : Node_Id;
Original_N : Node_Id;
begin
+ -- The approach in this procedure is very non-standard and at the
+ -- very least, extensive comments are required saying why this very
+ -- non-standard approach is needed???
+
+ -- Also general comments are needed in any case saying what is going
+ -- on here, since tree rewriting of this kind should normally be done
+ -- by the expander and not by the analyzer ??? Probably Ent, Iterator,
+ -- and Original_N, and Needs_Preanalysis, all need comments above ???
+
-- Preserve the original node used for the expansion of the quantified
-- expression.
- if Needs_Expansion then
+ -- This is a very unusual use of Copy_Separate_Tree, needs looking at???
+
+ if Need_Preanalysis then
Original_N := Copy_Separate_Tree (N);
end if;
@@ -3416,6 +3426,9 @@ package body Sem_Ch4 is
Check_SPARK_Restriction ("quantified expression is not allowed", N);
+ -- The following seems like expansion activity done at analysis
+ -- time, which seems weird ???
+
if Present (Loop_Parameter_Specification (N)) then
Iterator :=
Make_Iteration_Scheme (Loc,
@@ -3443,21 +3456,21 @@ package body Sem_Ch4 is
Set_Parent (Iterator_Specification (Iterator), Iterator);
end if;
- if Needs_Expansion then
+ if Need_Preanalysis then
-- The full analysis will be performed during the expansion of the
-- quantified expression, only a preanalysis of the condition needs
-- to be done.
- -- This is weird and irregular code for several reasons. First, doing
- -- an Analyze with no Resolve is very suspicious, how can this be
- -- right for the overloaded case ??? Second, doing two calls to
- -- analyze on the same node is peculiar ??? Why can't we use the
- -- normal Preanalyze calls here ???
+ -- This is strange for two reasons
- Expander_Mode_Save_And_Set (False);
- Analyze (Condition (N));
- Expander_Mode_Restore;
+ -- First, there is almost no situation in which Preanalyze vs
+ -- Analyze should be conditioned on -gnatc mode (since error msgs
+ -- must be 100% unaffected by -gnatc). Seconed doing a Preanalyze
+ -- with no resolution almost certainly means that some messages are
+ -- either missed, or flagged differently in the two cases.
+
+ Preanalyze (Condition (N));
else
Analyze (Condition (N));
end if;
@@ -3468,7 +3481,7 @@ package body Sem_Ch4 is
-- Attach the original node to the iteration scheme created above
- if Needs_Expansion then
+ if Need_Preanalysis then
Set_Etype (Original_N, Standard_Boolean);
Set_Parent (Iterator, Original_N);
end if;
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index a63cb79..d9be307 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -4280,11 +4280,6 @@ package body Sem_Ch6 is
-- analysis of the non-inlined body will handle these pragmas properly).
-- A new internal name is associated with Body_To_Inline.
- procedure Preanalyze (N : Node_Id);
- -- Performs a pre-analysis of node N. During pre-analysis no expansion
- -- is carried out for N or its children. For more info on pre-analysis
- -- read the spec of Sem.
-
procedure Split_Unconstrained_Function
(N : Node_Id;
Spec_Id : Entity_Id);
@@ -5059,23 +5054,6 @@ package body Sem_Ch6 is
Set_Corresponding_Spec (Body_To_Inline, Empty);
end Generate_Body_To_Inline;
- ----------------
- -- Preanalyze --
- ----------------
-
- procedure Preanalyze (N : Node_Id) is
- Save_Full_Analysis : constant Boolean := Full_Analysis;
-
- begin
- Full_Analysis := False;
- Expander_Mode_Save_And_Set (False);
-
- Analyze (N);
-
- Expander_Mode_Restore;
- Full_Analysis := Save_Full_Analysis;
- end Preanalyze;
-
----------------------------------
-- Split_Unconstrained_Function --
----------------------------------