From 5e0f1fca62d34663d2e2040c61d711c09fa9762d Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sat, 22 Nov 2014 12:15:53 +0000 Subject: [PATCH] trans.c (gnat_gimplify_expr): Add 'type' variable. * gcc-interface/trans.c (gnat_gimplify_expr): Add 'type' variable. : Deal with unconstrained array types and use 'type'. : Use 'type'. : Likewise. From-SVN: r217964 --- gcc/ada/ChangeLog | 7 +++++++ gcc/ada/gcc-interface/trans.c | 22 ++++++++++++---------- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gnat.dg/specs/no_streams.ads | 14 ++++++++++++++ 4 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/gnat.dg/specs/no_streams.ads diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 90c685ad9de..881c2f8f7ef 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2014-11-22 Eric Botcazou + + * gcc-interface/trans.c (gnat_gimplify_expr): Add 'type' variable. + : Deal with unconstrained array types and use 'type'. + : Use 'type'. + : Likewise. + 2014-11-20 Arnaud Charlet PR ada/63931 diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 01c9234e166..3d27dde709f 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -7657,6 +7657,7 @@ gnat_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p ATTRIBUTE_UNUSED) { tree expr = *expr_p; + tree type = TREE_TYPE (expr); tree op; if (IS_ADA_STMT (expr)) @@ -7665,16 +7666,17 @@ gnat_gimplify_expr (tree *expr_p, gimple_seq *pre_p, switch (TREE_CODE (expr)) { case NULL_EXPR: - /* If this is for a scalar, just make a VAR_DECL for it. If for - an aggregate, get a null pointer of the appropriate type and - dereference it. */ - if (AGGREGATE_TYPE_P (TREE_TYPE (expr))) - *expr_p = build1 (INDIRECT_REF, TREE_TYPE (expr), - convert (build_pointer_type (TREE_TYPE (expr)), - integer_zero_node)); + /* If this is an aggregate type, build a null pointer of the appropriate + type and dereference it. */ + if (AGGREGATE_TYPE_P (type) + || TREE_CODE (type) == UNCONSTRAINED_ARRAY_TYPE) + *expr_p = build_unary_op (INDIRECT_REF, NULL_TREE, + convert (build_pointer_type (type), + integer_zero_node)); + /* Otherwise, just make a VAR_DECL. */ else { - *expr_p = create_tmp_var (TREE_TYPE (expr), NULL); + *expr_p = create_tmp_var (type, NULL); TREE_NO_WARNING (*expr_p) = 1; } @@ -7697,7 +7699,7 @@ gnat_gimplify_expr (tree *expr_p, gimple_seq *pre_p, if (TREE_CODE (op) == CONSTRUCTOR && TREE_CONSTANT (op)) { tree addr = build_fold_addr_expr (tree_output_constant_def (op)); - *expr_p = fold_convert (TREE_TYPE (expr), addr); + *expr_p = fold_convert (type, addr); return GS_ALL_DONE; } @@ -7711,7 +7713,7 @@ gnat_gimplify_expr (tree *expr_p, gimple_seq *pre_p, required if the type is passed by reference. */ if ((TREE_CODE (op) == CONSTRUCTOR || TREE_CODE (op) == CALL_EXPR) && AGGREGATE_TYPE_P (TREE_TYPE (op)) - && !AGGREGATE_TYPE_P (TREE_TYPE (expr))) + && !AGGREGATE_TYPE_P (type)) { tree mod, new_var = create_tmp_var_raw (TREE_TYPE (op), "C"); gimple_add_tmp_var (new_var); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 11d5fd28237..80deed0d419 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-11-22 Eric Botcazou + + * gnat.dg/specs/no_streams.ads: New test. + 2014-11-22 Uros Bizjak * gcc.dg/store-motion-fgcse-sm.c (dg-final): Cleanup diff --git a/gcc/testsuite/gnat.dg/specs/no_streams.ads b/gcc/testsuite/gnat.dg/specs/no_streams.ads new file mode 100644 index 00000000000..e5a07424a55 --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/no_streams.ads @@ -0,0 +1,14 @@ +-- { dg-do compile } + +pragma Restrictions (No_Streams); + +with Ada.Containers.Ordered_Maps; + +package No_Streams is + + type Arr is new String (1..8); + + package My_Ordered_Map is new Ada.Containers.Ordered_Maps + (Key_Type => Natural, Element_Type => Arr); + +end No_Streams; -- 2.30.2