aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface
diff options
context:
space:
mode:
authorOlivier Hainque <hainque@adacore.com>2009-06-01 14:42:56 +0000
committerOlivier Hainque <hainque@gcc.gnu.org>2009-06-01 14:42:56 +0000
commit324c9b0242c7ea8604f8aa694d75a2e4ba075636 (patch)
tree2fb071a57ee2fbe016eadc8f563a7c7f8a70a306 /gcc/ada/gcc-interface
parent0980d7fe0b2f311dfc8e8d644d07a0a04f3cdf0c (diff)
downloadgcc-324c9b0242c7ea8604f8aa694d75a2e4ba075636.zip
gcc-324c9b0242c7ea8604f8aa694d75a2e4ba075636.tar.gz
gcc-324c9b0242c7ea8604f8aa694d75a2e4ba075636.tar.bz2
tree.h (CONSTRUCTOR_BITFIELD_P): True if NODE...
* tree.h (CONSTRUCTOR_BITFIELD_P): True if NODE, a FIELD_DECL, is to be processed as a bitfield for constructor output purposes. * output.h (initializer_constant_valid_for_bitfield_p): Declare new function. * varasm.c (oc_local_state): New type, output_constructor local state to support communication with helpers. (oc_outer_state): New type, output_constructor outer state of relevance in recursive calls. (output_constructor_array_range): New output_constructor helper, extracted code for an array range element. (output_constructor_regular_field): New output_constructor helper, extracted code for an element that is not a bitfield. (output_constructor_bitfield): New output_constructor helper, extracted code for a bitfield element. Accept an OUTER state argument for recursive processing. Recurse on record or array CONSTRUCTOR values, possibly past noop conversions. (initializer_constant_valid_for_bitfield_p): New predicate. Whether VALUE is a valid constant-valued expression for use in a static bit-field initializer. (output_constructor): Rework to use helpers. Accept and honor an OUTER state argument for recursive calls. Return total size. Be prepared for nested constructors initializing bitfields. (output_constant): Feed OUTER in calls to output_constructor. ada/ * gcc-interface/utils2.c (gnat_build_constructor): Factor out code. Use initializer_constant_valid_for_bitfield_p and CONSTRUCTOR_BITFIELD_P for bit-fields. testsuite/ * gnat.dg/oconst[1-6].ad[bs]: New tests. Also support for ... * gnat.dg/test_oconst.adb: New test. Co-Authored-By: Eric Botcazou <ebotcazou@adacore.com> From-SVN: r148045
Diffstat (limited to 'gcc/ada/gcc-interface')
-rw-r--r--gcc/ada/gcc-interface/utils2.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c
index 3fe8585..ec72a27 100644
--- a/gcc/ada/gcc-interface/utils2.c
+++ b/gcc/ada/gcc-interface/utils2.c
@@ -1623,34 +1623,35 @@ compare_elmt_bitpos (const PTR rt1, const PTR rt2)
tree
gnat_build_constructor (tree type, tree list)
{
- tree elmt;
- int n_elmts;
bool allconstant = (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST);
bool side_effects = false;
- tree result;
+ tree elmt, result;
+ int n_elmts;
/* Scan the elements to see if they are all constant or if any has side
effects, to let us set global flags on the resulting constructor. Count
the elements along the way for possible sorting purposes below. */
for (n_elmts = 0, elmt = list; elmt; elmt = TREE_CHAIN (elmt), n_elmts ++)
{
- if (!TREE_CONSTANT (TREE_VALUE (elmt))
+ tree obj = TREE_PURPOSE (elmt);
+ tree val = TREE_VALUE (elmt);
+
+ /* The predicate must be in keeping with output_constructor. */
+ if (!TREE_CONSTANT (val)
|| (TREE_CODE (type) == RECORD_TYPE
- && DECL_BIT_FIELD (TREE_PURPOSE (elmt))
- && TREE_CODE (TREE_VALUE (elmt)) != INTEGER_CST)
- || !initializer_constant_valid_p (TREE_VALUE (elmt),
- TREE_TYPE (TREE_VALUE (elmt))))
+ && CONSTRUCTOR_BITFIELD_P (obj)
+ && !initializer_constant_valid_for_bitfield_p (val))
+ || !initializer_constant_valid_p (val, TREE_TYPE (val)))
allconstant = false;
- if (TREE_SIDE_EFFECTS (TREE_VALUE (elmt)))
+ if (TREE_SIDE_EFFECTS (val))
side_effects = true;
/* Propagate an NULL_EXPR from the size of the type. We won't ever
be executing the code we generate here in that case, but handle it
specially to avoid the compiler blowing up. */
if (TREE_CODE (type) == RECORD_TYPE
- && (0 != (result
- = contains_null_expr (DECL_SIZE (TREE_PURPOSE (elmt))))))
+ && (result = contains_null_expr (DECL_SIZE (obj))) != NULL_TREE)
return build1 (NULL_EXPR, type, TREE_OPERAND (result, 0));
}