summaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2014-01-20 15:49:09 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2014-01-20 15:49:09 +0000
commitde38f22670455a6cb1b4fe9a758ebf39ba899b83 (patch)
treec8c46af2f929af435dfa8c412687eb407790b1dd /gcc/ada
parent596336afbb593298e22110c215c31174139f1685 (diff)
downloadgcc-de38f22670455a6cb1b4fe9a758ebf39ba899b83.tar.gz
2014-01-20 Robert Dewar <dewar@adacore.com>
* gnat_rm.texi (Allow_Integer_Address): Remove note about not allowed if address is non-private, no longer true. * sem_prag.adb (Analyze_Pragma, case Allow_Integer_Address): Remove check for address being private, causes difficulty when pragma used in gnat.adc file and is not needed, since we guard this in Address_Integer_Convert_OK. * exp_ch7.adb: Minor reformatting. * sem_ch4.adb: Handle operator operands in Allow_Integer_Address mode. 2014-01-20 Robert Dewar <dewar@adacore.com> * checks.adb (Apply_Range_Check): Remove gnatprove special casing of exponentiation. * sem_res.adb (Resolve_Op_Expon): Apply range check to right operand for integer case to check range against Natural. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@206833 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog18
-rw-r--r--gcc/ada/checks.adb13
-rw-r--r--gcc/ada/exp_ch7.adb2
-rw-r--r--gcc/ada/gnat_rm.texi12
-rw-r--r--gcc/ada/sem_ch4.adb21
-rw-r--r--gcc/ada/sem_prag.adb6
-rw-r--r--gcc/ada/sem_res.adb6
7 files changed, 47 insertions, 31 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 93c1d9fa1d3..395cc96cfbb 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,23 @@
2014-01-20 Robert Dewar <dewar@adacore.com>
+ * gnat_rm.texi (Allow_Integer_Address): Remove note about not
+ allowed if address is non-private, no longer true.
+ * sem_prag.adb (Analyze_Pragma, case Allow_Integer_Address):
+ Remove check for address being private, causes difficulty when
+ pragma used in gnat.adc file and is not needed, since we guard
+ this in Address_Integer_Convert_OK.
+ * exp_ch7.adb: Minor reformatting.
+ * sem_ch4.adb: Handle operator operands in Allow_Integer_Address mode.
+
+2014-01-20 Robert Dewar <dewar@adacore.com>
+
+ * checks.adb (Apply_Range_Check): Remove gnatprove special
+ casing of exponentiation.
+ * sem_res.adb (Resolve_Op_Expon): Apply range check to right
+ operand for integer case to check range against Natural.
+
+2014-01-20 Robert Dewar <dewar@adacore.com>
+
* s-tataat.adb: Minor reformatting.
2014-01-20 Robert Dewar <dewar@adacore.com>
diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index 8b8fdd86ed1..1e4cff810c5 100644
--- a/gcc/ada/checks.adb
+++ b/gcc/ada/checks.adb
@@ -2797,19 +2797,6 @@ package body Checks is
return;
end if;
- -- Ensure that the exponent is a natural. The flag is set only in formal
- -- verification mode as the expander takes care of this check and there
- -- is no expansion phase in GNATprove_Mode.
-
- -- Doesn't seem right to do this unconditionally, we should check the
- -- range of the exponent operand. If we do that, it seems like we should
- -- then set the flag unconditionally and have the expander check the
- -- flag to see whether to generate a check ???
-
- if GNATprove_Mode and then Nkind (Expr) = N_Op_Expon then
- Set_Do_Range_Check (Right_Opnd (Expr));
- end if;
-
Is_Unconstrained_Subscr_Ref :=
Is_Subscr_Ref and then not Is_Constrained (Arr_Typ);
diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
index 42d499b2d18..9739cad5313 100644
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -7987,7 +7987,7 @@ package body Exp_Ch7 is
-- signalling the decision outcome occurs before the cleanup actions.
if Opt.Suppress_Control_Flow_Optimizations
- and then Is_Boolean_Type (Typ)
+ and then Is_Boolean_Type (Typ)
then
Expr :=
Make_If_Expression (Loc,
diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi
index 53286d8b5c4..64bfce13f8d 100644
--- a/gcc/ada/gnat_rm.texi
+++ b/gcc/ada/gnat_rm.texi
@@ -1231,9 +1231,9 @@ pragma Allow_Integer_Address;
@end smallexample
@noindent
-This configuration pragma is allowed only
-if type @code{System.Address} is a private type,
-which is true in most versions of GNAT. which means that integer values,
+In almost all versions of GNAT, @code{System.Address} is a private
+type in accordance with the implementation advice in the RM. This
+means that integer values,
in particular integer literals, are not allowed as address values.
If the configuration pragma
@code{Allow_Integer_Address} is given, then integer expressions may
@@ -1263,12 +1263,6 @@ package AddrAsInt is
end AddrAsInt;
@end smallexample
-@noindent
-Note that these automatic conversions do not apply to expressions used
-as subprogram arguments, because in general overloading can take place,
-so that the required type is not fixed by the context. If necessary
-adjust the type of the subprogram argument, e.g. by adding a conversion.
-
@node Pragma Annotate
@unnumberedsec Pragma Annotate
@findex Annotate
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index daf8afe353b..bf4e31774c4 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -6367,16 +6367,33 @@ package body Sem_Ch4 is
N_Op_Rem,
N_Op_Subtract)
then
+ -- If Allow_Integer_Address is active, check whether the
+ -- operation becomes legal after converting an operand.
+
if Is_Numeric_Type (Etype (L))
and then not Is_Numeric_Type (Etype (R))
then
- Resolve (R, Etype (L));
+ if Address_Integer_Convert_OK (Etype (R), Etype (L)) then
+ Rewrite (R,
+ Unchecked_Convert_To (Etype (L), Relocate_Node (R)));
+ Analyze_Arithmetic_Op (N);
+
+ else
+ Resolve (R, Etype (L));
+ end if;
return;
elsif Is_Numeric_Type (Etype (R))
and then not Is_Numeric_Type (Etype (L))
then
- Resolve (L, Etype (R));
+ if Address_Integer_Convert_OK (Etype (L), Etype (R)) then
+ Rewrite (L,
+ Unchecked_Convert_To (Etype (R), Relocate_Node (L)));
+ Analyze_Arithmetic_Op (N);
+
+ else
+ Resolve (L, Etype (R));
+ end if;
return;
end if;
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index ad5e00494e4..7520856e392 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -9853,12 +9853,6 @@ package body Sem_Prag is
when Pragma_Allow_Integer_Address =>
GNAT_Pragma;
Check_Arg_Count (0);
-
- if not Is_Private_Type (RTE (RE_Address)) then
- Error_Pragma
- ("pragma% allowed only if Address is a private type");
- end if;
-
Opt.Allow_Integer_Address := True;
--------------
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 89fbb754905..e9d62a48188 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -8393,6 +8393,12 @@ package body Sem_Res is
Resolve (Left_Opnd (N), B_Typ);
Resolve (Right_Opnd (N), Standard_Integer);
+ -- For integer types, right argument must be in Natural range
+
+ if Is_Integer_Type (Typ) then
+ Apply_Scalar_Range_Check (Right_Opnd (N), Standard_Natural);
+ end if;
+
Check_Unset_Reference (Left_Opnd (N));
Check_Unset_Reference (Right_Opnd (N));