]> gcc.gnu.org Git - gcc.git/commitdiff
tree.h (CONSTRUCTOR_NO_CLEARING): Define.
authorTristan Gingold <gingold@adacore.com>
Mon, 11 Nov 2013 16:55:29 +0000 (16:55 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Mon, 11 Nov 2013 16:55:29 +0000 (16:55 +0000)
* tree.h (CONSTRUCTOR_NO_CLEARING): Define.
* tree-core.h (CONSTRUCTOR_NO_CLEARING): Document it.
* tree.def (CONSTRUCTOR): Likewise.
* doc/generic.texi (CONSTRUCTOR): Likewise.  Update description.
* gimplify.c (gimplify_init_constructor): Do not clear the object when
the constructor is incomplete and CONSTRUCTOR_NO_CLEARING is set.
ada/
* gcc-interface/utils2.c (gnat_build_constructor): Also set the flag
CONSTRUCTOR_NO_CLEARING on the constructor.

From-SVN: r204677

gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/gcc-interface/utils2.c
gcc/doc/generic.texi
gcc/tree-core.h
gcc/tree.def
gcc/tree.h

index b5631b97c8eafcdc4acca69fb35e9fa09d9f1e2b..ca7e6a01f0ce15e566a3a06abd9069e8778da07a 100644 (file)
@@ -1,8 +1,17 @@
+2013-11-11  Tristan Gingold  <gingold@adacore.com>
+           Eric Botcazou  <ebotcazou@adacore.com>
+
+       * tree.h (CONSTRUCTOR_NO_CLEARING): Define.
+       * tree-core.h (CONSTRUCTOR_NO_CLEARING): Document it.
+       * tree.def (CONSTRUCTOR): Likewise.
+       * doc/generic.texi (CONSTRUCTOR): Likewise.  Update description.
+       * gimplify.c (gimplify_init_constructor): Do not clear the object when
+       the constructor is incomplete and CONSTRUCTOR_NO_CLEARING is set.
 
 2013-11-11  Basile Starynkevitch  <basile@starynkevitch.net>
 
-         * toplev.c (toplev_main): Move PLUGIN_FINISH invocation before
-           diagnostic_finish.
+       * toplev.c (toplev_main): Move PLUGIN_FINISH invocation before
+       diagnostic_finish.
 
 2013-11-11  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
index 44d04845b9e3465c0db5bb008afb7b550fb8abb6..a5c9456e4c575ac88d5511e07fcaa12c3394722b 100644 (file)
@@ -1,3 +1,9 @@
+2013-11-11  Tristan Gingold  <gingold@adacore.com>
+           Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/utils2.c (gnat_build_constructor): Also set the flag
+       CONSTRUCTOR_NO_CLEARING on the constructor.
+
 2013-10-30  Sharad Singhai  <singhai@google.com>
 
        * gnat_ugn.texi: Remove option description for PR middle-end/58134.
index 64f7564a75d008fff92d7640cea98d68ac556370..9410b4083bf25ae23fb2402e523601d5eb3fe8a9 100644 (file)
@@ -1874,6 +1874,7 @@ gnat_build_constructor (tree type, vec<constructor_elt, va_gc> *v)
     v->qsort (compare_elmt_bitpos);
 
   result = build_constructor (type, v);
+  CONSTRUCTOR_NO_CLEARING (result) = 1;
   TREE_CONSTANT (result) = TREE_STATIC (result) = allconstant;
   TREE_SIDE_EFFECTS (result) = side_effects;
   TREE_READONLY (result) = TYPE_READONLY (type) || allconstant;
index 73dd1236412468e38a1e9b081c4e67d2f6000a41..f2dd0ffae65deee306806035144fda67d75d8666 100644 (file)
@@ -1616,29 +1616,31 @@ of temporaries during the evaluation of that expression should be
 performed immediately after the expression is evaluated.
 
 @item CONSTRUCTOR
-These nodes represent the brace-enclosed initializers for a structure or
-array.  The first operand is reserved for use by the back end.  The
-second operand is a @code{TREE_LIST}.  If the @code{TREE_TYPE} of the
-@code{CONSTRUCTOR} is a @code{RECORD_TYPE} or @code{UNION_TYPE}, then
-the @code{TREE_PURPOSE} of each node in the @code{TREE_LIST} will be a
-@code{FIELD_DECL} and the @code{TREE_VALUE} of each node will be the
-expression used to initialize that field.
-
-If the @code{TREE_TYPE} of the @code{CONSTRUCTOR} is an
-@code{ARRAY_TYPE}, then the @code{TREE_PURPOSE} of each element in the
-@code{TREE_LIST} will be an @code{INTEGER_CST} or a @code{RANGE_EXPR} of
-two @code{INTEGER_CST}s.  A single @code{INTEGER_CST} indicates which
-element of the array (indexed from zero) is being assigned to.  A
-@code{RANGE_EXPR} indicates an inclusive range of elements to
-initialize.  In both cases the @code{TREE_VALUE} is the corresponding
+These nodes represent the brace-enclosed initializers for a structure or an
+array.  They contain a sequence of component values made out of a vector of
+constructor_elt, which is a (@code{INDEX}, @code{VALUE}) pair.
+
+If the @code{TREE_TYPE} of the @code{CONSTRUCTOR} is a @code{RECORD_TYPE},
+@code{UNION_TYPE} or @code{QUAL_UNION_TYPE} then the @code{INDEX} of each
+node in the sequence will be a @code{FIELD_DECL} and the @code{VALUE} will
+be the expression used to initialize that field.
+
+If the @code{TREE_TYPE} of the @code{CONSTRUCTOR} is an @code{ARRAY_TYPE},
+then the @code{INDEX} of each node in the sequence will be an
+@code{INTEGER_CST} or a @code{RANGE_EXPR} of two @code{INTEGER_CST}s.
+A single @code{INTEGER_CST} indicates which element of the array is being
+assigned to.  A @code{RANGE_EXPR} indicates an inclusive range of elements
+to initialize.  In both cases the @code{VALUE} is the corresponding
 initializer.  It is re-evaluated for each element of a
-@code{RANGE_EXPR}.  If the @code{TREE_PURPOSE} is @code{NULL_TREE}, then
+@code{RANGE_EXPR}.  If the @code{INDEX} is @code{NULL_TREE}, then
 the initializer is for the next available array element.
 
 In the front end, you should not depend on the fields appearing in any
 particular order.  However, in the middle end, fields must appear in
 declaration order.  You should not assume that all fields will be
-represented.  Unrepresented fields will be set to zero.
+represented.  Unrepresented fields will be cleared (zeroed), unless the
+CONSTRUCTOR_NO_CLEARING flag is set, in which case their value becomes
+undefined.
 
 @item COMPOUND_LITERAL_EXPR
 @findex COMPOUND_LITERAL_EXPR_DECL_EXPR
index 351f906f001c97c10bcc0ba48effbbe372a6f942..94ff7f85b16faf33bfc15ccf3213aeb5715226dd 100644 (file)
@@ -831,6 +831,9 @@ struct GTY(()) tree_base {
            VAR_DECL, FUNCTION_DECL
            IDENTIFIER_NODE
 
+       CONSTRUCTOR_NO_CLEARING in
+           CONSTRUCTOR
+
        ASM_VOLATILE_P in
            ASM_EXPR
 
index 399b5af6cbeecbf5719415f4642976890189651b..6763e78835fa6413773ada26a65508b7b3e9324e 100644 (file)
@@ -445,10 +445,12 @@ DEFTREECODE (INDIRECT_REF, "indirect_ref", tcc_reference, 1)
    OBJ_TYPE_REF_TOKEN: An integer index to the virtual method table.  */
 DEFTREECODE (OBJ_TYPE_REF, "obj_type_ref", tcc_expression, 3)
 
-/* Constructor: return an aggregate value made from specified components.
-   In C, this is used only for structure and array initializers.
-   The operand is a sequence of component values made out of a VEC of
-   struct constructor_elt.
+/* Used to represent the brace-enclosed initializers for a structure or an
+   array.  It contains a sequence of component values made out of a VEC of
+   constructor_elt.
+
+   For RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE:
+   The field INDEX of each constructor_elt is a FIELD_DECL.
 
    For ARRAY_TYPE:
    The field INDEX of each constructor_elt is the corresponding index.
@@ -457,8 +459,9 @@ DEFTREECODE (OBJ_TYPE_REF, "obj_type_ref", tcc_expression, 3)
    has side-effects, they are evaluated once for each element.  Wrap the
    value in a SAVE_EXPR if you want to evaluate side effects only once.)
 
-   For RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE:
-   The field INDEX of each node is a FIELD_DECL.  */
+   Components that aren't present are cleared as per the C semantics,
+   unless the CONSTRUCTOR_NO_CLEARING flag is set, in which case their
+   value becomes undefined.  */
 DEFTREECODE (CONSTRUCTOR, "constructor", tcc_exceptional, 0)
 
 /* The expression types are mostly straightforward, with the fourth argument
index c4b23d0864ab906355c166d8e56acd5c45935d38..3633caf183919a148080b80d01f934689a82f4fe 100644 (file)
@@ -957,6 +957,8 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int,
   (&(*CONSTRUCTOR_ELTS (NODE))[IDX])
 #define CONSTRUCTOR_NELTS(NODE) \
   (vec_safe_length (CONSTRUCTOR_ELTS (NODE)))
+#define CONSTRUCTOR_NO_CLEARING(NODE) \
+  (CONSTRUCTOR_CHECK (NODE)->base.public_flag)
 
 /* Iterate through the vector V of CONSTRUCTOR_ELT elements, yielding the
    value of each element (stored within VAL). IX must be a scratch variable
This page took 0.127308 seconds and 5 git commands to generate.