@@ -872,6 +872,26 @@ exprt c_typecheck_baset::do_initializer_list(
872
872
873
873
const typet &full_type=follow (type);
874
874
875
+ // 6.7.9, 14: An array of character type may be initialized by a character
876
+ // string literal or UTF-8 string literal, optionally enclosed in braces.
877
+ if (
878
+ full_type.id () == ID_array && value.operands ().size () >= 1 &&
879
+ to_multi_ary_expr (value).op0 ().id () == ID_string_constant &&
880
+ (full_type.subtype ().id () == ID_signedbv ||
881
+ full_type.subtype ().id () == ID_unsignedbv) &&
882
+ to_bitvector_type (full_type.subtype ()).get_width () ==
883
+ char_type ().get_width ())
884
+ {
885
+ if (value.operands ().size () > 1 )
886
+ {
887
+ warning ().source_location = value.find_source_location ();
888
+ warning () << " ignoring excess initializers" << eom;
889
+ }
890
+
891
+ return do_initializer_rec (
892
+ to_multi_ary_expr (value).op0 (), type, force_constant);
893
+ }
894
+
875
895
exprt result;
876
896
if (full_type.id ()==ID_struct ||
877
897
full_type.id ()==ID_union ||
@@ -909,26 +929,6 @@ exprt c_typecheck_baset::do_initializer_list(
909
929
}
910
930
result = *zero;
911
931
}
912
-
913
- // 6.7.9, 14: An array of character type may be initialized by a character
914
- // string literal or UTF-8 string literal, optionally enclosed in braces.
915
- if (
916
- value.operands ().size () >= 1 &&
917
- to_multi_ary_expr (value).op0 ().id () == ID_string_constant &&
918
- (full_type.subtype ().id () == ID_signedbv ||
919
- full_type.subtype ().id () == ID_unsignedbv) &&
920
- to_bitvector_type (full_type.subtype ()).get_width () ==
921
- char_type ().get_width ())
922
- {
923
- if (value.operands ().size ()>1 )
924
- {
925
- warning ().source_location =value.find_source_location ();
926
- warning () << " ignoring excess initializers" << eom;
927
- }
928
-
929
- return do_initializer_rec (
930
- to_multi_ary_expr (value).op0 (), type, force_constant);
931
- }
932
932
}
933
933
else
934
934
{
0 commit comments