This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] support static nested constructors in bitfields (2/2)


Olivier Hainque <hainque@adacore.com> writes:

> 2009-04-27  Olivier Hainque  <hainque@adacore.com>
>             Eric Botcazou  <ebotcazou@adacore.com>
>
> 	Support for output of static nested constructors within bitfields
> 	* varasm.c (initializer_constant_valid_for_bitfield_p): New
> 	predicate. Whether VALUE is a valid constant-valued expression
> 	for use in initializing a static bit-field.
> 	(oc_outer_state): New type. output_constructor outer state of
> 	relevance in recursive calls.
> 	(oc_local_state): byte_buffer_in_use is bool, not int.  Add a
> 	"last_relative_index" field to memorize the index of the last
> 	array element output within a bitfield.
> 	(output_constructor_array_range): Minor prototype and head
> 	comment adjustments.
> 	(output_constructor_regular_field): Likewise.  Adjust assignments
> 	to byte_buffer_in_use, now bool.
> 	(output_constructor_bitfield): Likewise.  Accept an OUTER state
> 	argument for recursive processing.  Recurse on record or array
> 	CONSTRUCTOR values, possibly past noop conversions.
> 	(output_constructor): Accept and honor an OUTER state argument for
> 	recursive calls + return total size.  Be prepared for nested
> 	constructors initializing bitfields and consider BLKmode toplevel
> 	fields as regular even if DECL_BIT_FIELD is set.
> 	(output_constant): Feed OUTER in calls to output_constructor.
> 	* output.h (initializer_constant_valid_for_bitfield_p): Declare.
>
> 	ada/
> 	* utils2.c (gnat_build_constructor): Factor out code.  Use
> 	initializer_constant_valid_for_bitfield_p for bit-fields and
> 	account for BLKmode in addition to DECL_BIT_FIELD as in
> 	output_constructor.
>
> 	testsuite/
> 	* gnat.dg/oconst[1-6].ad[bs]: New tests. Also support for ...
> 	* gnat.dg/test_oconst.adb: New test.



> +   if (TREE_CODE (local->val) != INTEGER_CST
> +       && TREE_CODE (local->val) != CONSTRUCTOR)
> +       error ("invalid initial value for member %qs",
> + 	     IDENTIFIER_POINTER (DECL_NAME (local->field)));

You may need to return, or change local->var, to avoid useless follow-on
errors.


This is OK with those changes.

Thanks.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]