From: Dominik Vogt Date: Tue, 28 Oct 2014 17:29:40 +0000 (+0000) Subject: godump.c (precision_to_units): New helper function. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4bbed9ce68818456826d1d25441ef7c1e0d2d85b;p=gcc.git godump.c (precision_to_units): New helper function. gcc/: * godump.c (precision_to_units): New helper function. (go_append_artificial_name): Ditto. (go_append_decl_name): Ditto. (go_append_bitfield): Ditto. (go_get_uinttype_for_precision): Ditto. (go_append_padding): Ditto. (go_force_record_alignment): Ditto. (go_format_type): Represent unions with an array of uints of the size of the alignment in go. This fixes the 'random' size of the union's representation using just the first field. (go_format_type): Add argument that indicates whether a record is nested (used for generation of artificial go names). (go_output_fndecl): Adapt to new go_format_type signature. (go_output_typedef): Ditto. (go_output_var): Ditto. (go_output_var): Prefer to output type as alias (typedef). (go_format_type): Bitfields in records are simulated as arrays of bytes in go. * godump.c (go_format_type): Fix handling of arrays with zero elements. gcc/testsuite/: * gcc.misc-tests/godump.exp: New. * gcc.misc-tests/godump-1.c: New. From-SVN: r216806 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4de57e05a54..a2f87f76557 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,26 @@ +2014-10-28 Dominik Vogt + + * godump.c (precision_to_units): New helper function. + (go_append_artificial_name): Ditto. + (go_append_decl_name): Ditto. + (go_append_bitfield): Ditto. + (go_get_uinttype_for_precision): Ditto. + (go_append_padding): Ditto. + (go_force_record_alignment): Ditto. + (go_format_type): Represent unions with an array of uints of the size + of the alignment in go. This fixes the 'random' size of the union's + representation using just the first field. + (go_format_type): Add argument that indicates whether a record is + nested (used for generation of artificial go names). + (go_output_fndecl): Adapt to new go_format_type signature. + (go_output_typedef): Ditto. + (go_output_var): Ditto. + (go_output_var): Prefer to output type as alias (typedef). + (go_format_type): Bitfields in records are simulated as arrays of bytes + in go. + + * godump.c (go_format_type): Fix handling of arrays with zero elements. + 2014-10-28 Andrew MacLeod * cgraph.h: Flatten. Remove all include files. diff --git a/gcc/godump.c b/gcc/godump.c index 5e4b7fcb0e7..7a0566485f6 100644 --- a/gcc/godump.c +++ b/gcc/godump.c @@ -37,6 +37,8 @@ along with GCC; see the file COPYING3. If not see #include "obstack.h" #include "debug.h" #include "wide-int-print.h" +#include "stor-layout.h" +#include "defaults.h" /* We dump this information from the debug hooks. This gives us a stable and maintainable API to hook into. In order to work @@ -73,6 +75,15 @@ struct macro_hash_value char *value; }; +/* Returns the number of units necessary to represent an integer with the given + PRECISION (in bits). */ + +static inline unsigned int +precision_to_units (unsigned int precision) +{ + return (precision + BITS_PER_UNIT - 1) / BITS_PER_UNIT; +} + /* Calculate the hash value for an entry in the macro hash table. */ static hashval_t @@ -552,19 +563,132 @@ go_append_string (struct obstack *ob, tree id) obstack_grow (ob, IDENTIFIER_POINTER (id), IDENTIFIER_LENGTH (id)); } +/* Given an integer PRECISION in bits, returns a constant string that is the + matching go int or uint type (depending on the IS_UNSIGNED flag). Returns a + NULL pointer if there is no matching go type. */ + +static const char * +go_get_uinttype_for_precision (unsigned int precision, bool is_unsigned) +{ + switch (precision) + { + case 8: + return is_unsigned ? "uint8" : "int8"; + case 16: + return is_unsigned ? "uint16" : "int16"; + case 32: + return is_unsigned ? "uint32" : "int32"; + case 64: + return is_unsigned ? "uint64" : "int64"; + default: + return NULL; + } +} + +/* Append an artificial variable name with the suffix _INDEX to OB. Returns + INDEX + 1. */ + +static unsigned int +go_append_artificial_name (struct obstack *ob, unsigned int index) +{ + char buf[100]; + + /* FIXME: identifier may not be unique. */ + obstack_grow (ob, "Godump_", 7); + snprintf (buf, sizeof buf, "%u", index); + obstack_grow (ob, buf, strlen (buf)); + + return index + 1; +} + +/* Append the variable name from DECL to OB. If the name is in the + KEYWORD_HASH, prepend an '_'. */ + +static void +go_append_decl_name (struct obstack *ob, tree decl, htab_t keyword_hash) +{ + const char *var_name; + void **slot; + + /* Start variable name with an underscore if a keyword. */ + var_name = IDENTIFIER_POINTER (DECL_NAME (decl)); + slot = htab_find_slot (keyword_hash, var_name, NO_INSERT); + if (slot != NULL) + obstack_1grow (ob, '_'); + go_append_string (ob, DECL_NAME (decl)); +} + +/* Appends a byte array with the necessary number of elements and the name + "Godump_INDEX_pad" to pad from FROM_OFFSET to TO_OFFSET to OB assuming that + the next field is automatically aligned to ALIGN_UNITS. Returns INDEX + 1, + or INDEX if no padding had to be appended. The resulting offset where the + next field is allocated is returned through RET_OFFSET. */ + +static unsigned int +go_append_padding (struct obstack *ob, unsigned int from_offset, + unsigned int to_offset, unsigned int align_units, + unsigned int index, unsigned int *ret_offset) +{ + if (from_offset % align_units > 0) + from_offset += align_units - (from_offset % align_units); + gcc_assert (to_offset >= from_offset); + if (to_offset > from_offset) + { + char buf[100]; + + index = go_append_artificial_name (ob, index); + snprintf (buf, sizeof buf, "_pad [%u]byte; ", to_offset - from_offset); + obstack_grow (ob, buf, strlen (buf)); + } + *ret_offset = to_offset; + + return index; +} + +/* Appends an array of type TYPE_STRING with zero elements and the name + "Godump_INDEX_align" to OB. If TYPE_STRING is a null pointer, ERROR_STRING + is appended instead of the type. Returns INDEX + 1. */ + +static unsigned int +go_force_record_alignment (struct obstack *ob, const char *type_string, + unsigned int index, const char *error_string) +{ + index = go_append_artificial_name (ob, index); + obstack_grow (ob, "_align ", 7); + if (type_string == NULL) + obstack_grow (ob, error_string, strlen (error_string)); + else + { + obstack_grow (ob, "[0]", 3); + obstack_grow (ob, type_string, strlen (type_string)); + } + obstack_grow (ob, "; ", 2); + + return index; +} + /* Write the Go version of TYPE to CONTAINER->TYPE_OBSTACK. USE_TYPE_NAME is true if we can simply use a type name here without needing to define it. IS_FUNC_OK is true if we can output a func - type here; the "func" keyword will already have been added. Return - true if the type can be represented in Go, false otherwise. */ + type here; the "func" keyword will already have been added. + Return true if the type can be represented in Go, false otherwise. + P_ART_I is used for indexing artificial elements in nested structures and + should always be a NULL pointer when called, except by certain recursive + calls from go_format_type() itself. */ static bool go_format_type (struct godump_container *container, tree type, - bool use_type_name, bool is_func_ok) + bool use_type_name, bool is_func_ok, unsigned int *p_art_i) { bool ret; struct obstack *ob; + unsigned int art_i_dummy; + if (p_art_i == NULL) + { + art_i_dummy = 0; + p_art_i = &art_i_dummy; + } ret = true; ob = &container->type_obstack; @@ -618,27 +742,15 @@ go_format_type (struct godump_container *container, tree type, const char *s; char buf[100]; - switch (TYPE_PRECISION (type)) + s = go_get_uinttype_for_precision (TYPE_PRECISION (type), + TYPE_UNSIGNED (type)); + if (s == NULL) { - case 8: - s = TYPE_UNSIGNED (type) ? "uint8" : "int8"; - break; - case 16: - s = TYPE_UNSIGNED (type) ? "uint16" : "int16"; - break; - case 32: - s = TYPE_UNSIGNED (type) ? "uint32" : "int32"; - break; - case 64: - s = TYPE_UNSIGNED (type) ? "uint64" : "int64"; - break; - default: snprintf (buf, sizeof buf, "INVALID-int-%u%s", TYPE_PRECISION (type), TYPE_UNSIGNED (type) ? "u" : ""); s = buf; ret = false; - break; } obstack_grow (ob, s, strlen (s)); } @@ -710,7 +822,7 @@ go_format_type (struct godump_container *container, tree type, else { if (!go_format_type (container, TREE_TYPE (type), use_type_name, - true)) + true, NULL)) ret = false; } break; @@ -732,64 +844,64 @@ go_format_type (struct godump_container *container, tree type, tree_to_shwi (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))); obstack_grow (ob, buf, strlen (buf)); } + else + obstack_1grow (ob, '0'); obstack_1grow (ob, ']'); - if (!go_format_type (container, TREE_TYPE (type), use_type_name, false)) + if (!go_format_type (container, TREE_TYPE (type), use_type_name, false, + NULL)) ret = false; break; - case UNION_TYPE: case RECORD_TYPE: { + unsigned int prev_field_end; + unsigned int most_strict_known_alignment; tree field; - int i; + /* FIXME: Why is this necessary? Without it we can get a core + dump on the s390x headers, or from a file containing simply + "typedef struct S T;". */ + layout_type (type); + + prev_field_end = 0; + most_strict_known_alignment = 1; obstack_grow (ob, "struct { ", 9); - i = 0; for (field = TYPE_FIELDS (type); field != NULL_TREE; field = TREE_CHAIN (field)) { - struct obstack hold_type_obstack; bool field_ok; - if (TREE_CODE (type) == UNION_TYPE) - { - hold_type_obstack = container->type_obstack; - obstack_init (&container->type_obstack); - } - + if (TREE_CODE (field) != FIELD_DECL) + continue; field_ok = true; - - if (DECL_NAME (field) == NULL) - { - char buf[100]; - - obstack_grow (ob, "Godump_", 7); - snprintf (buf, sizeof buf, "%d", i); - obstack_grow (ob, buf, strlen (buf)); - i++; - } - else - { - const char *var_name; - void **slot; - - /* Start variable name with an underscore if a keyword. */ - var_name = IDENTIFIER_POINTER (DECL_NAME (field)); - slot = htab_find_slot (container->keyword_hash, var_name, - NO_INSERT); - if (slot != NULL) - obstack_1grow (ob, '_'); - go_append_string (ob, DECL_NAME (field)); - } - obstack_1grow (ob, ' '); if (DECL_BIT_FIELD (field)) - { - obstack_grow (ob, "INVALID-bit-field", 17); - field_ok = false; - } + continue; else { + { + unsigned int decl_align_unit; + unsigned int decl_offset; + + decl_align_unit = DECL_ALIGN_UNIT (field); + decl_offset = + TREE_INT_CST_LOW (DECL_FIELD_OFFSET (field)) + + precision_to_units + (TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (field))); + if (decl_align_unit > most_strict_known_alignment) + most_strict_known_alignment = decl_align_unit; + *p_art_i = go_append_padding + (ob, prev_field_end, decl_offset, decl_align_unit, *p_art_i, + &prev_field_end); + if (DECL_SIZE_UNIT (field)) + prev_field_end += TREE_INT_CST_LOW (DECL_SIZE_UNIT (field)); + } + if (DECL_NAME (field) == NULL) + *p_art_i = go_append_artificial_name (ob, *p_art_i); + else + go_append_decl_name (ob, field, container->keyword_hash); + obstack_1grow (ob, ' '); + /* Do not expand type if a record or union type or a function pointer. */ if (TYPE_NAME (TREE_TYPE (field)) != NULL_TREE @@ -815,40 +927,76 @@ go_format_type (struct godump_container *container, tree type, else { if (!go_format_type (container, TREE_TYPE (field), true, - false)) + false, p_art_i)) field_ok = false; } + obstack_grow (ob, "; ", 2); } - obstack_grow (ob, "; ", 2); + if (!field_ok) + ret = false; + } + /* Alignment and padding as necessary. */ + { + unsigned int type_align_unit; + + type_align_unit = TYPE_ALIGN_UNIT (type); + /* Padding. */ + *p_art_i = go_append_padding + (ob, prev_field_end, TREE_INT_CST_LOW (TYPE_SIZE_UNIT (type)), + type_align_unit, *p_art_i, &prev_field_end); + if (most_strict_known_alignment < type_align_unit) + { + const char *s; + char buf[100]; - /* Only output the first successful field of a union, and - hope for the best. */ - if (TREE_CODE (type) == UNION_TYPE) + /* Enforce proper record alignment. */ + s = go_get_uinttype_for_precision + (TYPE_ALIGN (type), TYPE_UNSIGNED (type)); + if (s == NULL) { - if (!field_ok && TREE_CHAIN (field) == NULL_TREE) - { - field_ok = true; - ret = false; - } - if (field_ok) - { - unsigned int sz; - - sz = obstack_object_size (&container->type_obstack); - obstack_grow (&hold_type_obstack, - obstack_base (&container->type_obstack), - sz); - } - obstack_free (&container->type_obstack, NULL); - container->type_obstack = hold_type_obstack; - if (field_ok) - break; + snprintf (buf, sizeof buf, "INVALID-int-%u%s", + TYPE_ALIGN (type), TYPE_UNSIGNED (type) ? "u" : ""); + s = buf; + ret = false; } + *p_art_i = go_force_record_alignment (ob, s, *p_art_i, buf); + } + } + obstack_1grow (ob, '}'); + } + break; + + case UNION_TYPE: + { + const char *s; + unsigned int sz_units; + + layout_type (type); + sz_units = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (type)); + s = go_get_uinttype_for_precision (TYPE_ALIGN (type), true); + obstack_grow (ob, "struct { ", 9); + if (s == NULL) + { + ret = false; + s = "INVALID-union-alignment"; + obstack_grow (ob, s, strlen (s)); + } + else + { + char buf[100]; + tree field; + + field = TYPE_FIELDS (type); + /* Use the same index as the byte field's artificial name for + padding. */ + if (field != NULL_TREE && DECL_NAME (field) != NULL) + go_append_decl_name (ob, field, container->keyword_hash); else - { - if (!field_ok) - ret = false; - } + *p_art_i = go_append_artificial_name (ob, *p_art_i); + snprintf (buf, sizeof buf, " [%u]byte; ", sz_units); + obstack_grow (ob, buf, strlen (buf)); + if (TYPE_ALIGN_UNIT (type) > 1) + *p_art_i = go_force_record_alignment (ob, s, *p_art_i, NULL); } obstack_1grow (ob, '}'); } @@ -879,7 +1027,7 @@ go_format_type (struct godump_container *container, tree type, break; if (seen_arg) obstack_grow (ob, ", ", 2); - if (!go_format_type (container, arg_type, true, false)) + if (!go_format_type (container, arg_type, true, false, NULL)) ret = false; seen_arg = true; } @@ -895,7 +1043,7 @@ go_format_type (struct godump_container *container, tree type, if (!VOID_TYPE_P (result)) { obstack_1grow (ob, ' '); - if (!go_format_type (container, result, use_type_name, false)) + if (!go_format_type (container, result, use_type_name, false, NULL)) ret = false; } } @@ -929,7 +1077,7 @@ go_output_type (struct godump_container *container) static void go_output_fndecl (struct godump_container *container, tree decl) { - if (!go_format_type (container, TREE_TYPE (decl), false, true)) + if (!go_format_type (container, TREE_TYPE (decl), false, true, NULL)) fprintf (go_dump_file, "// "); fprintf (go_dump_file, "func _%s ", IDENTIFIER_POINTER (DECL_NAME (decl))); @@ -1004,7 +1152,7 @@ go_output_typedef (struct godump_container *container, tree decl) return; *slot = CONST_CAST (void *, (const void *) type); - if (!go_format_type (container, TREE_TYPE (decl), false, false)) + if (!go_format_type (container, TREE_TYPE (decl), false, false, NULL)) { fprintf (go_dump_file, "// "); slot = htab_find_slot (container->invalid_hash, type, INSERT); @@ -1040,7 +1188,7 @@ go_output_typedef (struct godump_container *container, tree decl) return; *slot = CONST_CAST (void *, (const void *) type); - if (!go_format_type (container, TREE_TYPE (decl), false, false)) + if (!go_format_type (container, TREE_TYPE (decl), false, false, NULL)) { fprintf (go_dump_file, "// "); slot = htab_find_slot (container->invalid_hash, type, INSERT); @@ -1069,6 +1217,8 @@ static void go_output_var (struct godump_container *container, tree decl) { bool is_valid; + tree type_name; + tree id; if (container->decls_seen.contains (decl) || container->decls_seen.contains (DECL_NAME (decl))) @@ -1076,7 +1226,32 @@ go_output_var (struct godump_container *container, tree decl) container->decls_seen.add (decl); container->decls_seen.add (DECL_NAME (decl)); - is_valid = go_format_type (container, TREE_TYPE (decl), true, false); + type_name = TYPE_NAME (TREE_TYPE (decl)); + id = NULL_TREE; + if (type_name != NULL_TREE && TREE_CODE (type_name) == IDENTIFIER_NODE) + id = type_name; + else if (type_name != NULL_TREE && TREE_CODE (type_name) == TYPE_DECL + && DECL_SOURCE_LOCATION (type_name) != BUILTINS_LOCATION + && DECL_NAME (type_name)) + id = DECL_NAME (type_name); + if (id != NULL_TREE + && (!htab_find_slot (container->type_hash, IDENTIFIER_POINTER (id), + NO_INSERT) + || htab_find_slot (container->invalid_hash, IDENTIFIER_POINTER (id), + NO_INSERT))) + id = NULL_TREE; + if (id != NULL_TREE) + { + struct obstack *ob; + + ob = &container->type_obstack; + obstack_1grow (ob, '_'); + go_append_string (ob, id); + is_valid = htab_find_slot (container->type_hash, IDENTIFIER_POINTER (id), + NO_INSERT) != NULL; + } + else + is_valid = go_format_type (container, TREE_TYPE (decl), true, false, NULL); if (is_valid && htab_find_slot (container->type_hash, IDENTIFIER_POINTER (DECL_NAME (decl)), @@ -1096,10 +1271,8 @@ go_output_var (struct godump_container *container, tree decl) /* Sometimes an extern variable is declared with an unknown struct type. */ - if (TYPE_NAME (TREE_TYPE (decl)) != NULL_TREE - && RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl))) + if (type_name != NULL_TREE && RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl))) { - tree type_name = TYPE_NAME (TREE_TYPE (decl)); if (TREE_CODE (type_name) == IDENTIFIER_NODE) container->pot_dummy_types.add (IDENTIFIER_POINTER (type_name)); else if (TREE_CODE (type_name) == TYPE_DECL) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 920df042015..20efac7344a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-10-28 Dominik Vogt + + * gcc.misc-tests/godump.exp: New. + * gcc.misc-tests/godump-1.c: New. + 2014-10-28 Max Ostapenko * c-c++-common/asan/no-redundant-instrumentation-1.c: Updated test. diff --git a/gcc/testsuite/gcc.misc-tests/godump-1.c b/gcc/testsuite/gcc.misc-tests/godump-1.c new file mode 100644 index 00000000000..876cf28c26d --- /dev/null +++ b/gcc/testsuite/gcc.misc-tests/godump-1.c @@ -0,0 +1,482 @@ +/* Test -fdump-go-specs option. */ + +/* { dg-options "-c -fdump-go-spec=godump-1.out" } */ +/* { dg-do compile } */ + +#include + +/* integer based types */ +typedef char c_t; +char c_v1; +c_t c_v2; +typedef short s_t; +short s_v1; +s_t s_v2; +typedef int i_t; +int i_v1; +i_t i_v2; +typedef long l_t; +long l_v1; +l_t l_v2; +typedef long long ll_t; +long long ll_v1; +ll_t ll_v2; +typedef unsigned char uc_t; +unsigned char uc_v1; +uc_t uc_v2; +typedef unsigned short us_t; +unsigned short us_v1; +us_t us_v2; +typedef unsigned int ui_t; +unsigned int ui_v1; +ui_t ui_v2; +typedef unsigned long ul_t; +unsigned long ul_v1; +ul_t ul_v2; +typedef unsigned long long ull_t; +unsigned long long ull_v1; +ull_t ull_v2; +typedef signed char sc_t; +signed char sc_v1; +sc_t sc_v2; +typedef signed short ss_t; +signed short ss_v1; +ss_t ss_v2; +typedef signed int si_t; +signed int si_v1; +si_t si_v2; +typedef signed long sl_t; +signed long sl_v1; +sl_t sl_v2; +typedef signed long long sll_t; +signed long long sll_v1; +sll_t sll_v2; +typedef int8_t i8_t; +int8_t i8_v1; +i8_t i8_v2; +typedef int16_t i16_t; +int16_t i16_v1; +i16_t i16_v2; +typedef int32_t i32_t; +int32_t i32_v1; +i32_t i32_v2; +typedef int64_t i64_t; +int64_t i64_v1; +i64_t i64_v2; +typedef uint8_t ui8_t; +uint8_t ui8_v1; +ui8_t ui8_v2; +typedef uint16_t iu16_t; +uint16_t iu16_v1; +iu16_t iu16_v2; +typedef uint32_t iu32_t; +uint32_t iu32_v1; +iu32_t iu32_v2; +typedef uint64_t iu64_t; +uint64_t iu64_v1; +iu64_t iu64_v2; +typedef const char cc_t; +const char cc_v1; +cc_t cc_v2; + +/* pointer and array types */ +typedef void *vp_t; +void *vp_v1; +vp_t vp_v2; +typedef int **ipp_t; +int **ipp_v1; +ipp_t ipp_v2; +typedef char ca_t[]; +char ca_v1[]; /* { dg-warning "array 'ca_v1' assumed to have one element" } */ +char ca_v1b[2]; +ca_t ca_v2; /* { dg-warning "array 'ca_v2' assumed to have one element" } */ +typedef short sa2_t[2]; +short sa2_v1[2]; +sa2_t sa2_v2; + +/* floating point types */ +typedef float f_t; +float f_v1; +f_t f_v2; +typedef double d_t; +double d_v1; +d_t d_v2; +typedef long double ld_t; +long double ld_v1; +ld_t ld_v2; + +/* nested typedefs */ +typedef int ni_t; +typedef ni_t ni2_t; +ni2_t ni2_v2; +typedef ni2_t ni3_t; +ni3_t ni3_v2; + +/* enums */ +enum { E11 }; +enum { EV11 } e1_v1; +enum { E21, E22 }; +enum { EV21, EV22 } e2_v1; +enum { EN1 = 3, EN2 = 77, EN3 = -1, EN4 }; +typedef enum { ET1, ET2 } et_t; +enum { ETV1, ETV2 } et_v1; +et_t et_v2; + +/* simple structs */ +typedef struct { } ts0e; +struct { } s0e; +typedef struct { int8_t e1; } ts1e; +struct { int8_t e1; } s1e; +typedef struct { int8_t e1; void *e2; } ts2el; +struct { int8_t e1; void *e2; } s2el; +typedef struct { void *e1; int8_t e2; } ts2eg; +struct { void *e1; int8_t e2; } s2eg; +typedef struct { int64_t l; int8_t c; int32_t i; int16_t s; } tsme; +struct { int64_t l; int8_t c; int32_t i; int16_t s; } sme; +typedef struct { int16_t sa[3]; int8_t ca[3]; } tsae; +struct { int16_t sa[3]; int8_t ca[3]; } sae; +typedef struct { float f; } tsf_equiv; +struct { float f; } sf_equiv; +typedef struct { float f; uint8_t : 0; } tsf_not_equiv; +struct { float f; uint8_t : 0; } sf_not_equiv; +typedef struct { double d; } tsd_equiv; +struct { double d; } sd_equiv; +typedef struct { double d; uint8_t : 0; } tsd_not_equiv; +struct { double d; uint8_t : 0; } sd_not_equiv; +typedef struct s_undef_t s_undef_t2; + +/* nested structs */ +typedef struct { struct { uint8_t ca[3]; } s; uint32_t i; } tsn; +struct { struct { uint8_t ca[3]; } s; uint32_t i; } sn; +typedef struct { struct { uint8_t a; uint16_t s; }; uint8_t b; } tsn_anon; +struct { struct { uint8_t a; uint16_t s; }; uint8_t b; } sn_anon; + +/* structs with bitfields */ +typedef struct { uint8_t : 0; uint8_t c; } tsbf_anon_pad1; +struct { uint8_t : 0; uint8_t c; } sbf_anon_pad1; +typedef struct { uint8_t : 1; uint8_t c; } tsbf_anon_pad2; +struct { uint8_t : 1; uint8_t c; } sbf_anon_pad2; +typedef struct { uint8_t : 7; uint8_t c; } tsbf_anon_pad3; +struct { uint8_t : 7; uint8_t c; } sbf_anon_pad3; +typedef struct { uint8_t : 8; uint8_t c; } tsbf_anon_pad4; +struct { uint8_t : 8; uint8_t c; } sbf_anon_pad4; +typedef struct { uint64_t : 0; uint8_t c; } tsbf_anon_pad5; +struct { uint64_t : 0; uint8_t c; } sbf_anon_pad5; +typedef struct { uint64_t : 1; uint8_t c; } tsbf_anon_pad6; +struct { uint64_t : 1; uint8_t c; } sbf_anon_pad6; +typedef struct { uint64_t : 63; uint8_t c; } tsbf_anon_pad7; +struct { uint64_t : 63; uint8_t c; } sbf_anon_pad7; +typedef struct { uint64_t : 64; uint8_t c; } tsbf_anon_pad8; +struct { uint64_t : 64; uint8_t c; } sbf_anon_pad8; +typedef struct { uint8_t bf : 1; uint8_t c; } tsbf_pad8_1; +struct { uint8_t bf : 1; uint8_t c; } sbf_pad8_1; +typedef struct { uint8_t bf : 7; uint8_t c; } tsbf_pad8_2; +struct { uint8_t bf : 7; uint8_t c; } sbf_pad8_2; +typedef struct { uint8_t bf : 8; uint8_t c; } tsbf_pad8_3; +struct { uint8_t bf : 8; uint8_t c; } sbf_pad8_3; +typedef struct { uint16_t bf : 1; uint8_t c; } tsbf_pad16_1; +struct { uint16_t bf : 1; uint8_t c; } sbf_pad16_1; +typedef struct { uint16_t bf : 15; uint8_t c; } tsbf_pad16_2; +struct { uint16_t bf : 15; uint8_t c; } sbf_pad16_2; +typedef struct { uint16_t bf : 16; uint8_t c; } tsbf_pad16_3; +struct { uint16_t bf : 16; uint8_t c; } sbf_pad16_3; +typedef struct { uint32_t bf : 1; uint8_t c; } tsbf_pad32_1; +struct { uint32_t bf : 1; uint8_t c; } sbf_pad32_1; +typedef struct { uint32_t bf : 31; uint8_t c; } tsbf_pad32_2; +struct { uint32_t bf : 31; uint8_t c; } sbf_pad32_2; +typedef struct { uint32_t bf : 32; uint8_t c; } tsbf_pad32_3; +struct { uint32_t bf : 32; uint8_t c; } sbf_pad32_3; +typedef struct { uint64_t bf : 1; uint8_t c; } tsbf_pad64_1; +struct { uint64_t bf : 1; uint8_t c; } sbf_pad64_1; +typedef struct { uint64_t bf : 63; uint8_t c; } tsbf_pad64_2; +struct { uint64_t bf : 63; uint8_t c; } sbf_pad64_2; +typedef struct { uint64_t bf : 64; uint8_t c; } tsbf_pad64_3; +struct { uint64_t bf : 64; uint8_t c; } sbf_pad64_3; +typedef struct { uint8_t b1 : 1; } tsbf_1b; +struct { uint8_t b1 : 1; } sbf_1b; +typedef struct +{ + uint8_t b1 : 1; uint8_t b2 : 1; uint8_t b3 : 1; uint8_t b4 : 1; + uint8_t b5 : 1; uint8_t b6 : 1; uint8_t b7 : 1; uint8_t b8 : 1; +} tsbf_8b; +struct +{ + uint8_t b1 : 1; uint8_t b2 : 1; uint8_t b3 : 1; uint8_t b4 : 1; + uint8_t b5 : 1; uint8_t b6 : 1; uint8_t b7 : 1; uint8_t b8 : 1; +} sbf_8b; +typedef struct { + uint8_t b1 : 1; uint8_t b2 : 1; uint8_t b3 : 1; uint8_t b4 : 1; + uint8_t b5 : 1; uint8_t b6 : 1; uint8_t b7 : 1; uint8_t b8 : 1; + uint8_t b9 : 1; +} tsbf_9b; +struct { + uint8_t b1 : 1; uint8_t b2 : 1; uint8_t b3 : 1; uint8_t b4 : 1; + uint8_t b5 : 1; uint8_t b6 : 1; uint8_t b7 : 1; uint8_t b8 : 1; + uint8_t b9 : 1; +} sbf_9b; +typedef struct { + uint8_t b1 : 7; uint8_t b2 : 7; uint8_t b3 : 2; +} tsbf_18b; +struct { + uint8_t b1 : 7; uint8_t b2 : 7; uint8_t b3 : 2; +} sbf_18b; +struct +{ + uint16_t bf1 : 8; + uint8_t c; + uint16_t bf2 : 8; + uint32_t bf3 : 12; + uint16_t s; +} sbf_gaps; +typedef struct +{ + uint16_t bf1 : 8; + uint8_t c; + uint16_t bf2 : 8; + uint32_t bf3 : 12; + uint16_t s; +} tsbf_gaps; + +/* unions */ +typedef union { } tue; +union { } ue; +typedef union { uint8_t c; uint64_t l; } tu1; +union { uint8_t c; uint64_t l; } u1; +typedef union { uint64_t l; uint8_t c; } tu2; +union { uint64_t l; uint8_t c; } u2; +typedef union { uint64_t l[3]; uint8_t c; } tu3; +union { uint64_t l[3]; uint8_t c; } u3; +typedef struct { union { uint8_t c; uint64_t l; }; } tsu_anon; +struct { union { uint8_t c; uint64_t l; }; } su_anon; +typedef union { uint64_t bf : 1; uint8_t ca[5]; } tu_size; +union { uint64_t bf : 1; uint8_t ca[5]; } u_size; +typedef union { uint64_t : 1; uint8_t ca[5]; } tu2_size; +union { uint64_t : 1; uint8_t ca[5]; } u2_size; +typedef union u_undef_t u_undef_t2; +typedef union { uint64_t b : 1; uint8_t ca[5]; } tu3_size; +union { uint64_t b : 1; uint8_t ca[5]; } u3_size; + +/* functions */ +extern uint32_t func1(uint8_t c); +typedef int8_t (*func_t)(void *p); + +/* Necessary quoting in the regexp patters: + + (?n) at beginning of pattern to make ^ and $ work. + " -> \" + *, + -> "*", "+" + [, ] -> "\[", "\]" + (, ) -> "\[(\]", "\[)\]" + {, } -> "\{", "\}" +*/ + +/* { dg-final { scan-file godump-1.out "(?n)^type _c_t u?int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _s_t int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _i_t int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _l_t int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _ll_t int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _uc_t uint\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _us_t uint\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _ui_t uint\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _ul_t uint\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _ull_t uint\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _sc_t int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _ss_t int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _si_t int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _sl_t int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _sll_t int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _i8_t int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _i16_t int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _i32_t int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _i64_t int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _ui8_t uint\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _iu16_t uint\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _iu32_t uint\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _iu64_t uint\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _cc_t u?int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _vp_t \\*byte$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _ipp_t \\*\\*int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _ca_t \\\[0\\\]u?int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _sa2_t \\\[1\\+1\\\]int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _f_t float\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _d_t float\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^// type _ld_t INVALID-float-\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _ni_t int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _ni2_t int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _ni3_t int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _et_t int$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _ts0e struct \{ \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _ts1e struct \{ e1 int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _ts2el struct \{ e1 int\[0-9\]*; e2 \\*byte; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _ts2eg struct \{ e1 \\*byte; e2 int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsme struct \{ l int\[0-9\]*; c int\[0-9\]*; i int\[0-9\]*; s int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsae struct \{ sa \\\[2\\+1\\\]int\[0-9\]*; ca \\\[2\\+1\\\]int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsf_equiv struct \{ f float\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsf_not_equiv struct \{ f float\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsd_equiv struct \{ d float\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsd_not_equiv struct \{ d float\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsn struct \{ s struct \{ ca \\\[2\\+1\\\]uint\[0-9\]*; \}; i uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsn_anon struct \{ Godump_0 struct \{ a uint\[0-9\]*; s uint\[0-9\]*; \}; b uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_anon_pad1 struct \{ c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_anon_pad2 struct \{ Godump_0_pad \\\[1\\\]byte; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_anon_pad3 struct \{ Godump_0_pad \\\[1\\\]byte; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_anon_pad4 struct \{ Godump_0 uint\[0-9\]*; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_anon_pad5 struct \{ c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_anon_pad6 struct \{ Godump_0_pad \\\[1\\\]byte; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_anon_pad7 struct \{ Godump_0_pad \\\[8\\\]byte; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_anon_pad8 struct \{ Godump_0 uint\[0-9\]*; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_pad8_1 struct \{ Godump_0_pad \\\[1\\\]byte; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_pad8_2 struct \{ Godump_0_pad \\\[1\\\]byte; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_pad8_3 struct \{ bf uint\[0-9\]*; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_pad16_1 struct \{ Godump_0_pad \\\[1\\\]byte; c uint\[0-9\]*; Godump_1_align \\\[0\\\]int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_pad16_2 struct \{ Godump_0_pad \\\[2\\\]byte; c uint\[0-9\]*; Godump_1_align \\\[0\\\]int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_pad16_3 struct \{ bf uint\[0-9\]*; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_pad32_1 struct \{ Godump_0_pad \\\[1\\\]byte; c uint\[0-9\]*; Godump_1_align \\\[0\\\]int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_pad32_2 struct \{ Godump_0_pad \\\[4\\\]byte; c uint\[0-9\]*; Godump_1_align \\\[0\\\]int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_pad32_3 struct \{ bf uint\[0-9\]*; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_pad64_1 struct \{ Godump_0_pad \\\[1\\\]byte; c uint\[0-9\]*; Godump_1_align \\\[0\\\]int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_pad64_2 struct \{ Godump_0_pad \\\[8\\\]byte; c uint\[0-9\]*; Godump_1_align \\\[0\\\]int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_pad64_3 struct \{ bf uint\[0-9\]*; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_1b struct \{ Godump_0_pad \\\[1\\\]byte; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_8b struct \{ Godump_0_pad \\\[1\\\]byte; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_9b struct \{ Godump_0_pad \\\[2\\\]byte; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_18b struct \{ Godump_0_pad \\\[3\\\]byte; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsbf_gaps struct \{ bf1 uint\[0-9\]*; c uint\[0-9\]*; bf2 uint\[0-9\]*; Godump_0_pad \\\[2\\\]byte; s uint\[0-9\]*; Godump_1_align \\\[0\\\]int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tue struct \{ Godump_0 \\\[0\\\]byte; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tu1 struct \{ c \\\[8\\\]byte; Godump_0_align \\\[0\\\]uint64; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tu2 struct \{ l \\\[8\\\]byte; Godump_0_align \\\[0\\\]uint64; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tu3 struct \{ l \\\[24\\\]byte; Godump_0_align \\\[0\\\]uint64; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tsu_anon struct \{ Godump_0 struct \{ c \\\[8\\\]byte; Godump_1_align \\\[0\\\]uint64; \}; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tu_size struct \{ bf \\\[8\\\]byte; Godump_0_align \\\[0\\\]uint64; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tu2_size struct \{ Godump_0 \\\[5\\\]byte; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _tu3_size struct \{ b \\\[8\\\]byte; Godump_0_align \\\[0\\\]uint64; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^type _func_t func\[(\]\\*byte\[)\] int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _c_v1 u?int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _c_v2 _c_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _s_v1 int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _s_v2 _s_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _i_v1 int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _i_v2 _i_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _l_v1 int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _l_v2 _l_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _ll_v1 int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _ll_v2 _ll_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _uc_v1 uint\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _uc_v2 _uc_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _us_v1 uint\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _us_v2 _us_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _ui_v1 uint\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _ui_v2 _ui_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _ul_v1 uint\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _ul_v2 _ul_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _ull_v1 uint\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _ull_v2 _ull_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sc_v1 int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sc_v2 _sc_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _ss_v1 int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _ss_v2 _ss_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _si_v1 int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _si_v2 _si_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sl_v1 int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sl_v2 _sl_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sll_v1 int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sll_v2 _sll_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _i8_v1 _int8_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _i8_v2 _i8_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _i16_v1 _int16_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _i16_v2 _i16_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _i32_v1 _int32_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _i32_v2 _i32_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _i64_v1 _int64_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _i64_v2 _i64_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _ui8_v1 _uint8_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _ui8_v2 _ui8_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _iu16_v1 _uint16_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _iu16_v2 _iu16_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _iu32_v1 _uint32_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _iu32_v2 _iu32_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _iu64_v1 _uint64_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _iu64_v2 _iu64_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _cc_v1 u?int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _cc_v2 _cc_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _vp_v1 \\*byte$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _vp_v2 _vp_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _ipp_v1 \\*\\*int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _ipp_v2 _ipp_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _ca_v1 \\\[0\\+1\\\]u?int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _ca_v1b \\\[1\\+1\\\]u?int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _ca_v2 \\\[0\\+1\\\]u?int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sa2_v1 \\\[1\\+1\\\]int\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sa2_v2 _sa2_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _f_v1 float\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _f_v2 _f_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _d_v1 float\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _d_v2 _d_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^// var _ld_v1 INVALID-float-\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^// var _ld_v2 INVALID-float-\[0-9\]*$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _ni2_v2 _ni2_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _ni3_v2 _ni3_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _e1_v1 int$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _e2_v1 int$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _et_v1 int$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _et_v2 _et_t$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _s0e struct \{ \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _s1e struct \{ e1 int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _s2el struct \{ e1 int\[0-9\]*; e2 \\*byte; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _s2eg struct \{ e1 \\*byte; e2 int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sme struct \{ l int\[0-9\]*; c int\[0-9\]*; i int\[0-9\]*; s int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sae struct \{ sa \\\[2\\+1\\\]int\[0-9\]*; ca \\\[2\\+1\\\]int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sf_equiv struct \{ f float\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sf_not_equiv struct \{ f float\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sd_equiv struct \{ d float\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sd_not_equiv struct \{ d float\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sn struct \{ s struct \{ ca \\\[2\\+1\\\]uint\[0-9\]*; \}; i uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sn_anon struct \{ Godump_0 struct \{ a uint\[0-9\]*; s uint\[0-9\]*; \}; b uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_anon_pad1 struct \{ c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_anon_pad2 struct \{ Godump_0_pad \\\[1\\\]byte; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_anon_pad3 struct \{ Godump_0_pad \\\[1\\\]byte; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_anon_pad4 struct \{ Godump_0 uint\[0-9\]*; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_anon_pad5 struct \{ c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_anon_pad6 struct \{ Godump_0_pad \\\[1\\\]byte; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_anon_pad7 struct \{ Godump_0_pad \\\[8\\\]byte; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_anon_pad8 struct \{ Godump_0 uint\[0-9\]*; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_pad8_1 struct \{ Godump_0_pad \\\[1\\\]byte; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_pad8_2 struct \{ Godump_0_pad \\\[1\\\]byte; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_pad8_3 struct \{ bf uint\[0-9\]*; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_pad16_1 struct \{ Godump_0_pad \\\[1\\\]byte; c uint\[0-9\]*; Godump_1_align \\\[0\\\]int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_pad16_2 struct \{ Godump_0_pad \\\[2\\\]byte; c uint\[0-9\]*; Godump_1_align \\\[0\\\]int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_pad16_3 struct \{ bf uint\[0-9\]*; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_pad32_1 struct \{ Godump_0_pad \\\[1\\\]byte; c uint\[0-9\]*; Godump_1_align \\\[0\\\]int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_pad32_2 struct \{ Godump_0_pad \\\[4\\\]byte; c uint\[0-9\]*; Godump_1_align \\\[0\\\]int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_pad32_3 struct \{ bf uint\[0-9\]*; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_pad64_1 struct \{ Godump_0_pad \\\[1\\\]byte; c uint\[0-9\]*; Godump_1_align \\\[0\\\]int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_pad64_2 struct \{ Godump_0_pad \\\[8\\\]byte; c uint\[0-9\]*; Godump_1_align \\\[0\\\]int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_pad64_3 struct \{ bf uint\[0-9\]*; c uint\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_1b struct \{ Godump_0_pad \\\[1\\\]byte; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_8b struct \{ Godump_0_pad \\\[1\\\]byte; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_9b struct \{ Godump_0_pad \\\[2\\\]byte; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_18b struct \{ Godump_0_pad \\\[3\\\]byte; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _sbf_gaps struct \{ bf1 uint\[0-9\]*; c uint\[0-9\]*; bf2 uint\[0-9\]*; Godump_0_pad \\\[2\\\]byte; s uint\[0-9\]*; Godump_1_align \\\[0\\\]int\[0-9\]*; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _ue struct \{ Godump_0 \\\[0\\\]byte; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _u1 struct \{ c \\\[8\\\]byte; Godump_0_align \\\[0\\\]uint64; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _u2 struct \{ l \\\[8\\\]byte; Godump_0_align \\\[0\\\]uint64; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _u3 struct \{ l \\\[24\\\]byte; Godump_0_align \\\[0\\\]uint64; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _su_anon struct \{ Godump_0 struct \{ c \\\[8\\\]byte; Godump_1_align \\\[0\\\]uint64; \}; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _u_size struct \{ bf \\\[8\\\]byte; Godump_0_align \\\[0\\\]uint64; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _u2_size struct \{ Godump_0 \\\[5\\\]byte; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^var _u3_size struct \{ b \\\[8\\\]byte; Godump_0_align \\\[0\\\]uint64; \}$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^func _func1 \[(\]uint\[0-9\]*\[)\] uint\[0-9\]* __asm__\[(\]\"func1\"\[)\]$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^const _E11 = 0$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^const _E21 = 0$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^const _E22 = 1$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^const _EN1 = 3$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^const _EN2 = 77$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^const _EN3 = -1$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^const _EN4 = 0$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^const _ET1 = 0$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^const _ET2 = 1$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^const _ETV1 = 0$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^const _ETV2 = 1$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^const _EV11 = 0$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^const _EV21 = 0$" } } */ +/* { dg-final { scan-file godump-1.out "(?n)^const _EV22 = 1$" } } */ diff --git a/gcc/testsuite/gcc.misc-tests/godump.exp b/gcc/testsuite/gcc.misc-tests/godump.exp new file mode 100644 index 00000000000..96812c46f6b --- /dev/null +++ b/gcc/testsuite/gcc.misc-tests/godump.exp @@ -0,0 +1,36 @@ +# Copyright (C) 2014 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# GCC testsuite that uses the `dg.exp' driver. + +# Load support procs. +load_lib gcc-dg.exp + +# If a testcase doesn't have special options, use these. +global DEFAULT_CFLAGS +if ![info exists DEFAULT_CFLAGS] then { + set DEFAULT_CFLAGS " -ansi -pedantic-errors" +} + +# Initialize `dg'. +dg-init + +# Main loop. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/godump-*.c]] \ + "" $DEFAULT_CFLAGS + +# All done. +dg-finish