@@ -495,18 +495,7 @@ std::string expr2ct::convert_rec(
495495 }
496496 else if (src.id ()==ID_array)
497497 {
498- // The [...] gets attached to the declarator.
499- std::string array_suffix;
500-
501- if (to_array_type (src).size ().is_nil ())
502- array_suffix=" []" ;
503- else
504- array_suffix=" [" +convert (to_array_type (src).size ())+" ]" ;
505-
506- // This won't really parse without declarator.
507- // Note that qualifiers are passed down.
508- return convert_rec (
509- src.subtype (), qualifiers, declarator+array_suffix);
498+ return convert_array_type (src, qualifiers, declarator);
510499 }
511500 else if (src.id ()==ID_incomplete_array)
512501 {
@@ -777,6 +766,68 @@ std::string expr2ct::convert_struct_type(
777766
778767/* ******************************************************************\
779768
769+ Function: expr2ct::convert_array_type
770+
771+ Inputs:
772+ src - The array type to convert
773+ qualifier
774+ declarator_str
775+
776+ Outputs: A C-like type declaration of an array
777+
778+ Purpose: To generate a C-like type declaration of an array. Includes
779+ the size of the array in the []
780+
781+ \*******************************************************************/
782+
783+ std::string expr2ct::convert_array_type (
784+ const typet &src,
785+ const c_qualifierst &qualifiers,
786+ const std::string &declarator_str)
787+ {
788+ return convert_array_type (src, qualifiers, declarator_str, true );
789+ }
790+
791+ /* ******************************************************************\
792+
793+ Function: expr2ct::convert_array_type
794+
795+ Inputs:
796+ src - The array type to convert
797+ qualifier
798+ declarator_str
799+ inc_size_if_possible - Should the generated string include
800+ the size of the array (if it is known).
801+
802+ Outputs: A C-like type declaration of an array
803+
804+ Purpose: To generate a C-like type declaration of an array. Optionally
805+ can include or exclude the size of the array in the []
806+
807+ \*******************************************************************/
808+
809+ std::string expr2ct::convert_array_type (
810+ const typet &src,
811+ const c_qualifierst &qualifiers,
812+ const std::string &declarator_str,
813+ bool inc_size_if_possible)
814+ {
815+ // The [...] gets attached to the declarator.
816+ std::string array_suffix;
817+
818+ if (to_array_type (src).size ().is_nil () || !inc_size_if_possible)
819+ array_suffix=" []" ;
820+ else
821+ array_suffix=" [" +convert (to_array_type (src).size ())+" ]" ;
822+
823+ // This won't really parse without declarator.
824+ // Note that qualifiers are passed down.
825+ return convert_rec (
826+ src.subtype (), qualifiers, declarator_str+array_suffix);
827+ }
828+
829+ /* ******************************************************************\
830+
780831Function: expr2ct::convert_typecast
781832
782833 Inputs:
0 commit comments