Commit 1aa291f7 by Eric Botcazou Committed by Eric Botcazou

utils.c (maybe_unconstrained_array): Declare TYPE local variable and use it throughout.

	* gcc-interface/utils.c (maybe_unconstrained_array): Declare TYPE local
	variable and use it throughout.
	<UNCONSTRAINED_ARRAY_TYPE>: Add 'break' at the end.
	<RECORD_TYPE>: Do not unconditionally convert to the unpadded type as a
	first step.  Also convert to the unpadded type as a last step.

From-SVN: r179186
parent 7d76717d
2011-09-26 Eric Botcazou <ebotcazou@adacore.com> 2011-09-26 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/utils.c (maybe_unconstrained_array): Declare TYPE local
variable and use it throughout.
<UNCONSTRAINED_ARRAY_TYPE>: Add 'break' at the end.
<RECORD_TYPE>: Do not unconditionally convert to the unpadded type as a
first step. Also convert to the unpadded type as a last step.
2011-09-26 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/gigi.h (create_subprog_decl): Replace TREE_CHAIN with * gcc-interface/gigi.h (create_subprog_decl): Replace TREE_CHAIN with
DECL_CHAIN in comment. DECL_CHAIN in comment.
* gcc-interface/trans.c (gigi): Likewise. * gcc-interface/trans.c (gigi): Likewise.
......
...@@ -4264,8 +4264,9 @@ tree ...@@ -4264,8 +4264,9 @@ tree
maybe_unconstrained_array (tree exp) maybe_unconstrained_array (tree exp)
{ {
enum tree_code code = TREE_CODE (exp); enum tree_code code = TREE_CODE (exp);
tree type = TREE_TYPE (exp);
switch (TREE_CODE (TREE_TYPE (exp))) switch (TREE_CODE (type))
{ {
case UNCONSTRAINED_ARRAY_TYPE: case UNCONSTRAINED_ARRAY_TYPE:
if (code == UNCONSTRAINED_ARRAY_REF) if (code == UNCONSTRAINED_ARRAY_REF)
...@@ -4274,68 +4275,66 @@ maybe_unconstrained_array (tree exp) ...@@ -4274,68 +4275,66 @@ maybe_unconstrained_array (tree exp)
const bool no_trap = TREE_THIS_NOTRAP (exp); const bool no_trap = TREE_THIS_NOTRAP (exp);
exp = TREE_OPERAND (exp, 0); exp = TREE_OPERAND (exp, 0);
type = TREE_TYPE (exp);
if (TREE_CODE (exp) == COND_EXPR) if (TREE_CODE (exp) == COND_EXPR)
{ {
tree op1 tree op1
= build_unary_op (INDIRECT_REF, NULL_TREE, = build_unary_op (INDIRECT_REF, NULL_TREE,
build_component_ref (TREE_OPERAND (exp, 1), build_component_ref (TREE_OPERAND (exp, 1),
NULL_TREE, NULL_TREE,
TYPE_FIELDS TYPE_FIELDS (type),
(TREE_TYPE (exp)),
false)); false));
tree op2 tree op2
= build_unary_op (INDIRECT_REF, NULL_TREE, = build_unary_op (INDIRECT_REF, NULL_TREE,
build_component_ref (TREE_OPERAND (exp, 2), build_component_ref (TREE_OPERAND (exp, 2),
NULL_TREE, NULL_TREE,
TYPE_FIELDS TYPE_FIELDS (type),
(TREE_TYPE (exp)),
false)); false));
exp = build3 (COND_EXPR, exp = build3 (COND_EXPR,
TREE_TYPE (TREE_TYPE (TYPE_FIELDS TREE_TYPE (TREE_TYPE (TYPE_FIELDS (type))),
(TREE_TYPE (exp)))),
TREE_OPERAND (exp, 0), op1, op2); TREE_OPERAND (exp, 0), op1, op2);
} }
else else
{ {
exp = build_unary_op (INDIRECT_REF, NULL_TREE, exp = build_unary_op (INDIRECT_REF, NULL_TREE,
build_component_ref (exp, NULL_TREE, build_component_ref (exp, NULL_TREE,
TYPE_FIELDS TYPE_FIELDS (type),
(TREE_TYPE (exp)),
false)); false));
TREE_READONLY (exp) = read_only; TREE_READONLY (exp) = read_only;
TREE_THIS_NOTRAP (exp) = no_trap; TREE_THIS_NOTRAP (exp) = no_trap;
} }
return exp;
} }
else if (code == NULL_EXPR) else if (code == NULL_EXPR)
return build1 (NULL_EXPR, exp = build1 (NULL_EXPR,
TREE_TYPE (TREE_TYPE (TYPE_FIELDS TREE_TYPE (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (type)))),
(TREE_TYPE (TREE_TYPE (exp))))), TREE_OPERAND (exp, 0));
TREE_OPERAND (exp, 0)); break;
case RECORD_TYPE: case RECORD_TYPE:
/* If this is a padded type, convert to the unpadded type and see if /* If this is a padded type and it contains a template, convert to the
it contains a template. */ unpadded type first. */
if (TYPE_PADDING_P (TREE_TYPE (exp))) if (TYPE_PADDING_P (type)
&& TREE_CODE (TREE_TYPE (TYPE_FIELDS (type))) == RECORD_TYPE
&& TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (TYPE_FIELDS (type))))
{ {
tree new_exp exp = convert (TREE_TYPE (TYPE_FIELDS (type)), exp);
= convert (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (exp))), exp); type = TREE_TYPE (exp);
if (TREE_CODE (TREE_TYPE (new_exp)) == RECORD_TYPE }
&& TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (new_exp)))
return if (TYPE_CONTAINS_TEMPLATE_P (type))
build_component_ref (new_exp, NULL_TREE, {
DECL_CHAIN exp = build_component_ref (exp, NULL_TREE,
(TYPE_FIELDS (TREE_TYPE (new_exp))), DECL_CHAIN (TYPE_FIELDS (type)),
false); false);
type = TREE_TYPE (exp);
/* If the array type is padded, convert to the unpadded type. */
if (TYPE_IS_PADDING_P (type))
exp = convert (TREE_TYPE (TYPE_FIELDS (type)), exp);
} }
else if (TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (exp)))
return
build_component_ref (exp, NULL_TREE,
DECL_CHAIN (TYPE_FIELDS (TREE_TYPE (exp))),
false);
break; break;
default: default:
......
2011-09-26 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/array17.adb: New test.
* gnat.dg/array17_pkg.ads: New helper.
2011-09-25 Jason Merrill <jason@redhat.com> 2011-09-25 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/nsdmi-defer4.C: New. * g++.dg/cpp0x/nsdmi-defer4.C: New.
......
-- { dg-do compile }
with Array17_Pkg; use Array17_Pkg;
procedure Array17 is
X : aliased Varray := (1 .. 8 => 1.0);
Y : Varray (1 .. 8) := (others => -1.0);
R : Varray (1 .. 8);
begin
R (1 .. 4) := Y (1 .. 4) + X (1 .. 4);
end;
package Array17_Pkg is
type Varray is array (Integer range <>) of Long_Float;
for Varray'Alignment use 16;
function "+" (X, Y : Varray) return Varray;
end Array17_Pkg;
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