Commit 08ffbdad by Eric Botcazou Committed by Eric Botcazou

* trans.c (call_to_gnu):Invoke the addressable_p predicate only

	when necessary.  Merge some conditional statements.  Update comments.
	Rename unchecked_convert_p local variable to suppress_type_conversion.
	Do not suppress conversions in the In case.
	(addressable_p) <VIEW_CONVERT_EXPR>: Do not take alignment issues
	into account on non strict-alignment platforms.

From-SVN: r131510
parent 2cb207f7
2008-01-13 Eric Botcazou <ebotcazou@adacore.com>
* trans.c (call_to_gnu):Invoke the addressable_p predicate only
when necessary. Merge some conditional statements. Update comments.
Rename unchecked_convert_p local variable to suppress_type_conversion.
Do not suppress conversions in the In case.
(addressable_p) <VIEW_CONVERT_EXPR>: Do not take alignment issues
into account on non strict-alignment platforms.
2008-01-12 Eric Botcazou <ebotcazou@adacore.com>
* utils.c (aggregate_type_contains_array_p): New predicate.
......@@ -6,7 +6,7 @@
* *
* C Implementation File *
* *
* Copyright (C) 1992-2007, Free Software Foundation, Inc. *
* Copyright (C) 1992-2008, 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- *
......@@ -495,7 +495,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
case E_Out_Parameter:
case E_Variable:
/* Simple variables, loop variables, OUT parameters, and exceptions. */
/* Simple variables, loop variables, Out parameters, and exceptions. */
object:
{
bool used_by_ref = false;
......@@ -3395,7 +3395,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
Each parameter is first checked by calling must_pass_by_ref on its
type to determine if it is passed by reference. For parameters which
are copied in, if they are Ada IN OUT or OUT parameters, their return
are copied in, if they are Ada In Out or Out parameters, their return
value becomes part of a record which becomes the return type of the
function (C function - note that this applies only to Ada procedures
so there is no Ada return type). Additional code to store back the
......@@ -3406,7 +3406,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
equivalent source rewritings that follow:
struct temp {int a,b};
procedure P (A,B: IN OUT ...) is temp P (int A,B)
procedure P (A,B: In Out ...) is temp P (int A,B)
begin {
.. ..
end P; return {A,B};
......@@ -3438,7 +3438,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
parameters. */
tree gnu_field_list = NULL_TREE;
/* Non-null for subprograms containing parameters passed by copy-in
copy-out (Ada IN OUT or OUT parameters not passed by reference),
copy-out (Ada In Out or Out parameters not passed by reference),
in which case it is the list of nodes used to specify the values of
the in out/out parameters that are returned as a record upon
procedure return. The TREE_PURPOSE of an element of this list is
......@@ -4545,7 +4545,7 @@ gnat_to_gnu_param (Entity_Id gnat_param, Mechanism_Type mech,
/* If we must pass or were requested to pass by reference, do so.
If we were requested to pass by copy, do so.
Otherwise, for foreign conventions, pass IN OUT or OUT parameters
Otherwise, for foreign conventions, pass In Out or Out parameters
or aggregates by reference. For COBOL and Fortran, pass all
integer and FP types that way too. For Convention Ada, use
the standard Ada default. */
......@@ -4566,22 +4566,22 @@ gnat_to_gnu_param (Entity_Id gnat_param, Mechanism_Type mech,
by_ref = true;
}
/* Pass IN OUT or OUT parameters using copy-in copy-out mechanism. */
/* Pass In Out or Out parameters using copy-in copy-out mechanism. */
else if (!in_param)
*cico = true;
if (mech == By_Copy && (by_ref || by_component_ptr))
post_error ("?cannot pass & by copy", gnat_param);
/* If this is an OUT parameter that isn't passed by reference and isn't
/* If this is an Out parameter that isn't passed by reference and isn't
a pointer or aggregate, we don't make a PARM_DECL for it. Instead,
it will be a VAR_DECL created when we process the procedure, so just
return its type. For the special parameter of a valued procedure,
never pass it in.
An exception is made to cover the RM-6.4.1 rule requiring "by copy"
OUT parameters with discriminants or implicit initial values to be
handled like IN OUT parameters. These type are normally built as
Out parameters with discriminants or implicit initial values to be
handled like In Out parameters. These type are normally built as
aggregates, hence passed by reference, except for some packed arrays
which end up encoded in special integer types.
......
......@@ -6,7 +6,7 @@
* *
* C Header File *
* *
* Copyright (C) 1992-2007, Free Software Foundation, Inc. *
* Copyright (C) 1992-2008, 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- *
......@@ -608,7 +608,7 @@ extern tree create_field_decl (tree field_name, tree field_type,
/* Returns a PARM_DECL node. PARAM_NAME is the name of the parameter,
PARAM_TYPE is its type. READONLY is true if the parameter is
readonly (either an IN parameter or an address of a pass-by-ref
readonly (either an In parameter or an address of a pass-by-ref
parameter). */
extern tree create_param_decl (tree param_name, tree param_type,
bool readonly);
......
......@@ -6,7 +6,7 @@
* *
* C Implementation File *
* *
* Copyright (C) 1992-2007, Free Software Foundation, Inc. *
* Copyright (C) 1992-2008, 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- *
......@@ -1683,7 +1683,7 @@ create_field_decl (tree field_name, tree field_type, tree record_type,
/* Returns a PARM_DECL node. PARAM_NAME is the name of the parameter,
PARAM_TYPE is its type. READONLY is true if the parameter is
readonly (either an IN parameter or an address of a pass-by-ref
readonly (either an In parameter or an address of a pass-by-ref
parameter). */
tree
......
2008-01-13 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/unchecked_convert1.adb.
2008-01-13 Richard Guenther <rguenther@suse.de>
* gcc.dg/struct-ret-3.c: Adjust testcase to make stack
-- { dg-do run }
-- { dg-options "-gnatws" }
with Ada.Unchecked_Conversion;
procedure Unchecked_Convert1 is
type Byte is mod 2**8;
type Stream is array (Natural range <>) of Byte;
type Rec is record
I1, I2 : Integer;
end record;
function Do_Sum (R : Rec) return Integer is
begin
return R.I1 + R.I2;
end;
function Sum (S : Stream) return Integer is
subtype Chunk is Stream (1 .. Rec'Size / 8);
function To_Chunk is new Ada.Unchecked_Conversion (Chunk, Rec);
begin
return Do_Sum (To_Chunk (S(S'First .. S'First + Rec'Size / 8 - 1)));
end;
A : Stream (1..9);
I : Integer;
begin
I := Sum (A(1..8));
end;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment