diff options
author | Jakub Jelinek <jakub@redhat.com> | 2005-11-21 09:40:08 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2005-11-21 09:40:08 +0000 |
commit | 92b30144414b7257e951689355dc9793ffcc4bc4 (patch) | |
tree | b987fe50a4bb162d0f3dc389ef0e88c51a4351e4 | |
parent | dc459c365f811143b33a6f1fec314962f2245cd5 (diff) |
* g++.dg/compat/struct-layout-1_generate.c: In arrays avoid types
where sizeof (type) < __alignof__ (type).
* g++.dg/compat/struct-layout-1.h: Likewise.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-4_0-rhl-branch@107288 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/compat/struct-layout-1.h | 155 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/compat/struct-layout-1_generate.c | 109 |
3 files changed, 265 insertions, 5 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 094706b9409..40fa069d396 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2005-04-12 Jakub Jelinek <jakub@redhat.com> + + * g++.dg/compat/struct-layout-1_generate.c: In arrays avoid types + where sizeof (type) < __alignof__ (type). + * g++.dg/compat/struct-layout-1.h: Likewise. + 2005-04-06 Jakub Jelinek <jakub@redhat.com> * g++.dg/compat/struct-layout-1.exp: New file. diff --git a/gcc/testsuite/g++.dg/compat/struct-layout-1.h b/gcc/testsuite/g++.dg/compat/struct-layout-1.h index b579653dff5..328c83b91f3 100644 --- a/gcc/testsuite/g++.dg/compat/struct-layout-1.h +++ b/gcc/testsuite/g++.dg/compat/struct-layout-1.h @@ -101,6 +101,64 @@ extern int fn5 (void), fn6 (void), fn7 (void), fn8 (void), fn9 (void); #define atpaal8 __attribute__((packed, aligned (8))) #define atpaal16 __attribute__((packed, aligned (16))) +#if UCHAR_MAX == 255 && USHORT_MAX == 65535 && UINT_MAX == 4294967295U \ + && ULLONG_MAX == 18446744073709551615ULL +/* For ILP32 and LP64 targets, assume float is at least 32-bit + and double plus long double at least 64-bit. */ +# define atalx1 atal1 +# define atalx2 atal2 +# define atalx4 atal4 +# define atalx8 atal8 +# define atalx16 atal16 +# define atalx1pa atal1pa +# define atalx2pa atal2pa +# define atalx4pa atal4pa +# define atalx8pa atal8pa +# define atalx16pa atal16pa +# define atpaalx1 atpaal1 +# define atpaalx2 atpaal2 +# define atpaalx4 atpaal4 +# define atpaalx8 atpaal8 +# define atpaalx16 atpaal16 +# if ULONG_MAX > 4294967295UL +# define ataly8 atal8 +# define ataly8pa atal8pa +# define atpaaly8 atpaal8 +# define ataly16 atal16 +# define ataly16pa atal16pa +# define atpaaly16 atpaal16 +# else +# define ataly8 +# define ataly8pa +# define atpaaly8 +# define ataly16 +# define ataly16pa +# define atpaaly16 +# endif +#else +# define atalx1 +# define atalx2 +# define atalx4 +# define atalx8 +# define atalx16 +# define atalx1pa +# define atalx2pa +# define atalx4pa +# define atalx8pa +# define atalx16pa +# define atpaalx1 +# define atpaalx2 +# define atpaalx4 +# define atpaalx8 +# define atpaalx16 +# define ataly8 +# define ataly8pa +# define atpaaly8 +# define ataly16 +# define ataly16pa +# define atpaaly16 +#endif + #define atQI __attribute__((mode (QI))) #define atHI __attribute__((mode (HI))) #define atSI __attribute__((mode (SI))) @@ -336,6 +394,103 @@ typedef enum E9 Tal16E9 atal16; typedef void *Tal16ptr atal16; typedef char *Tal16cptr atal16; typedef int *Tal16iptr atal16; +typedef char Talx1char atalx1; +typedef signed char Talx1schar atalx1; +typedef unsigned char Talx1uchar atalx1; +typedef short int Talx1short atalx1; +typedef unsigned short int Talx1ushort atalx1; +typedef int Talx1int atalx1; +typedef unsigned int Talx1uint atalx1; +typedef long int Talx1long atalx1; +typedef unsigned long int Talx1ulong atalx1; +typedef long long int Talx1llong atalx1; +typedef unsigned long long int Talx1ullong atalx1; +typedef float Talx1float atalx1; +typedef double Talx1double atalx1; +typedef long double Talx1ldouble atalx1; +typedef _Complex float Talx1cfloat atalx1; +typedef _Complex double Talx1cdouble atalx1; +typedef _Complex long double Talx1cldouble atalx1; +typedef bool Talx1bool atalx1; +typedef enum E0 Talx1E0 atalx1; +typedef enum E1 Talx1E1 atalx1; +typedef enum E2 Talx1E2 atalx1; +typedef enum E3 Talx1E3 atalx1; +typedef enum E4 Talx1E4 atalx1; +typedef enum E5 Talx1E5 atalx1; +typedef enum E6 Talx1E6 atalx1; +typedef enum E7 Talx1E7 atalx1; +typedef enum E8 Talx1E8 atalx1; +typedef enum E9 Talx1E9 atalx1; +typedef void *Talx1ptr atalx1; +typedef char *Talx1cptr atalx1; +typedef int *Talx1iptr atalx1; +typedef short int Talx2short atalx2; +typedef unsigned short int Talx2ushort atalx2; +typedef int Talx2int atalx2; +typedef unsigned int Talx2uint atalx2; +typedef long int Talx2long atalx2; +typedef unsigned long int Talx2ulong atalx2; +typedef long long int Talx2llong atalx2; +typedef unsigned long long int Talx2ullong atalx2; +typedef float Talx2float atalx2; +typedef double Talx2double atalx2; +typedef long double Talx2ldouble atalx2; +typedef _Complex float Talx2cfloat atalx2; +typedef _Complex double Talx2cdouble atalx2; +typedef _Complex long double Talx2cldouble atalx2; +typedef enum E0 Talx2E0 atalx2; +typedef enum E1 Talx2E1 atalx2; +typedef enum E2 Talx2E2 atalx2; +typedef enum E3 Talx2E3 atalx2; +typedef enum E4 Talx2E4 atalx2; +typedef enum E5 Talx2E5 atalx2; +typedef enum E6 Talx2E6 atalx2; +typedef enum E7 Talx2E7 atalx2; +typedef enum E8 Talx2E8 atalx2; +typedef enum E9 Talx2E9 atalx2; +typedef void *Talx2ptr atalx2; +typedef char *Talx2cptr atalx2; +typedef int *Talx2iptr atalx2; +typedef int Talx4int atalx4; +typedef unsigned int Talx4uint atalx4; +typedef long int Talx4long atalx4; +typedef unsigned long int Talx4ulong atalx4; +typedef long long int Talx4llong atalx4; +typedef unsigned long long int Talx4ullong atalx4; +typedef float Talx4float atalx4; +typedef double Talx4double atalx4; +typedef long double Talx4ldouble atalx4; +typedef _Complex float Talx4cfloat atalx4; +typedef _Complex double Talx4cdouble atalx4; +typedef _Complex long double Talx4cldouble atalx4; +typedef enum E0 Talx4E0 atalx4; +typedef enum E1 Talx4E1 atalx4; +typedef enum E2 Talx4E2 atalx4; +typedef enum E3 Talx4E3 atalx4; +typedef enum E4 Talx4E4 atalx4; +typedef enum E5 Talx4E5 atalx4; +typedef enum E6 Talx4E6 atalx4; +typedef enum E7 Talx4E7 atalx4; +typedef enum E8 Talx4E8 atalx4; +typedef enum E9 Talx4E9 atalx4; +typedef void *Talx4ptr atalx4; +typedef char *Talx4cptr atalx4; +typedef int *Talx4iptr atalx4; +typedef long int Taly8long ataly8; +typedef unsigned long int Taly8ulong ataly8; +typedef long long int Talx8llong atalx8; +typedef unsigned long long int Talx8ullong atalx8; +typedef double Talx8double atalx8; +typedef long double Talx8ldouble atalx8; +typedef _Complex float Talx8cfloat atalx8; +typedef _Complex double Talx8cdouble atalx8; +typedef _Complex long double Talx8cldouble atalx8; +typedef void *Taly8ptr ataly8; +typedef char *Taly8cptr ataly8; +typedef int *Taly8iptr ataly8; +typedef _Complex double Talx16cdouble atalx16; +typedef _Complex long double Talx16cldouble atalx16; typedef int (*Tfnptr) (void); #define T(n, fields, ops) TX(n, struct, , fields, ({ ops });) diff --git a/gcc/testsuite/g++.dg/compat/struct-layout-1_generate.c b/gcc/testsuite/g++.dg/compat/struct-layout-1_generate.c index 5d796f45e51..d14885c987d 100644 --- a/gcc/testsuite/g++.dg/compat/struct-layout-1_generate.c +++ b/gcc/testsuite/g++.dg/compat/struct-layout-1_generate.c @@ -391,6 +391,92 @@ struct entry struct types *type; const char *attrib; }; +struct types attrib_array_types[] = { +{ "Talx1char", TYPE_UINT, 127, 'C' }, +{ "Talx1schar", TYPE_INT, 127, 'C' }, +{ "Talx1uchar", TYPE_UINT, 255, 'C' }, +{ "Talx1short", TYPE_INT, 32767, 'S' }, +{ "Talx1ushort", TYPE_UINT, 65535, 'S' }, +{ "Talx1int", TYPE_INT, 2147483647, 'I' }, +{ "Talx1uint", TYPE_UINT, 4294967295U, 'I' }, +{ "Talx1long", TYPE_INT, 9223372036854775807LL, 'L' }, +{ "Talx1ulong", TYPE_UINT, 18446744073709551615ULL, 'L' }, +{ "Talx1llong", TYPE_INT, 9223372036854775807LL, 'Q' }, +{ "Talx1ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' }, +{ "Talx1bool", TYPE_UINT, 1, 'B' }, +{ "Talx1ptr", TYPE_PTR, 0, 0 }, +{ "Talx1cptr", TYPE_PTR, 0, 0 }, +{ "Talx1iptr", TYPE_PTR, 0, 0 }, +{ "Talx1float", TYPE_FLOAT, 0, 0 }, +{ "Talx1double", TYPE_FLOAT, 0, 0 }, +{ "Talx1ldouble", TYPE_FLOAT, 0, 0 }, +{ "Talx1E0", TYPE_UENUM, 0, ' ' }, +{ "Talx1E1", TYPE_UENUM, 1, ' ' }, +{ "Talx1E2", TYPE_SENUM, 3, ' ' }, +{ "Talx1E3", TYPE_SENUM, 127, ' ' }, +{ "Talx1E4", TYPE_UENUM, 255, ' ' }, +{ "Talx1E5", TYPE_SENUM, 32767, ' ' }, +{ "Talx1E6", TYPE_UENUM, 65535, ' ' }, +{ "Talx1E7", TYPE_SENUM, 2147483647, ' ' }, +{ "Talx1E8", TYPE_UENUM, 4294967295U, ' ' }, +{ "Talx1E9", TYPE_SENUM, 1099511627775LL, ' ' }, +{ "Talx2short", TYPE_INT, 32767, 'S' }, +{ "Talx2ushort", TYPE_UINT, 65535, 'S' }, +{ "Talx2int", TYPE_INT, 2147483647, 'I' }, +{ "Talx2uint", TYPE_UINT, 4294967295U, 'I' }, +{ "Talx2long", TYPE_INT, 9223372036854775807LL, 'L' }, +{ "Talx2ulong", TYPE_UINT, 18446744073709551615ULL, 'L' }, +{ "Talx2llong", TYPE_INT, 9223372036854775807LL, 'Q' }, +{ "Talx2ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' }, +{ "Talx2ptr", TYPE_PTR, 0, 0 }, +{ "Talx2cptr", TYPE_PTR, 0, 0 }, +{ "Talx2iptr", TYPE_PTR, 0, 0 }, +{ "Talx2float", TYPE_FLOAT, 0, 0 }, +{ "Talx2double", TYPE_FLOAT, 0, 0 }, +{ "Talx2ldouble", TYPE_FLOAT, 0, 0 }, +{ "Talx2E0", TYPE_UENUM, 0, ' ' }, +{ "Talx2E1", TYPE_UENUM, 1, ' ' }, +{ "Talx2E2", TYPE_SENUM, 3, ' ' }, +{ "Talx2E3", TYPE_SENUM, 127, ' ' }, +{ "Talx2E4", TYPE_UENUM, 255, ' ' }, +{ "Talx2E5", TYPE_SENUM, 32767, ' ' }, +{ "Talx2E6", TYPE_UENUM, 65535, ' ' }, +{ "Talx2E7", TYPE_SENUM, 2147483647, ' ' }, +{ "Talx2E8", TYPE_UENUM, 4294967295U, ' ' }, +{ "Talx2E9", TYPE_SENUM, 1099511627775LL, ' ' }, +{ "Talx4int", TYPE_INT, 2147483647, 'I' }, +{ "Talx4uint", TYPE_UINT, 4294967295U, 'I' }, +{ "Talx4long", TYPE_INT, 9223372036854775807LL, 'L' }, +{ "Talx4ulong", TYPE_UINT, 18446744073709551615ULL, 'L' }, +{ "Talx4llong", TYPE_INT, 9223372036854775807LL, 'Q' }, +{ "Talx4ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' }, +{ "Talx4ptr", TYPE_PTR, 0, 0 }, +{ "Talx4cptr", TYPE_PTR, 0, 0 }, +{ "Talx4iptr", TYPE_PTR, 0, 0 }, +{ "Talx4float", TYPE_FLOAT, 0, 0 }, +{ "Talx4double", TYPE_FLOAT, 0, 0 }, +{ "Talx4ldouble", TYPE_FLOAT, 0, 0 }, +{ "Talx4E0", TYPE_UENUM, 0, ' ' }, +{ "Talx4E1", TYPE_UENUM, 1, ' ' }, +{ "Talx4E2", TYPE_SENUM, 3, ' ' }, +{ "Talx4E3", TYPE_SENUM, 127, ' ' }, +{ "Talx4E4", TYPE_UENUM, 255, ' ' }, +{ "Talx4E5", TYPE_SENUM, 32767, ' ' }, +{ "Talx4E6", TYPE_UENUM, 65535, ' ' }, +{ "Talx4E7", TYPE_SENUM, 2147483647, ' ' }, +{ "Talx4E8", TYPE_UENUM, 4294967295U, ' ' }, +{ "Talx4E9", TYPE_SENUM, 1099511627775LL, ' ' }, +{ "Taly8long", TYPE_INT, 9223372036854775807LL, 'L' }, +{ "Taly8ulong", TYPE_UINT, 18446744073709551615ULL, 'L' }, +{ "Talx8llong", TYPE_INT, 9223372036854775807LL, 'Q' }, +{ "Talx8ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' }, +{ "Taly8ptr", TYPE_PTR, 0, 0 }, +{ "Taly8cptr", TYPE_PTR, 0, 0 }, +{ "Taly8iptr", TYPE_PTR, 0, 0 }, +{ "Talx8double", TYPE_FLOAT, 0, 0 }, +{ "Talx8ldouble", TYPE_FLOAT, 0, 0 } +#define NAATYPES2 (sizeof (attrib_array_types) / sizeof (attrib_array_types[0])) +}; static int idx, limidx, output_one; static const char *destdir; @@ -937,7 +1023,7 @@ singles (enum FEATURE features) } void -choose_type (enum FEATURE features, struct entry *e, int r) +choose_type (enum FEATURE features, struct entry *e, int r, int in_array) { int i; @@ -945,7 +1031,12 @@ choose_type (enum FEATURE features, struct entry *e, int r) if (features & FEATURE_VECTOR) i += NVTYPES2; if ((r & 3) == 0) - i += NATYPES2; + { + if (in_array) + i += NAATYPES2; + else + i += NATYPES2; + } r >>= 2; r %= i; if (r < NTYPES2 - NTYPES1) @@ -957,12 +1048,18 @@ choose_type (enum FEATURE features, struct entry *e, int r) e->type = &vector_types[r]; r -= NVTYPES2; } - if (e->type == NULL) + if (e->type == NULL && !in_array) { if (r < NATYPES2) e->type = &attrib_types[r]; r -= NATYPES2; } + if (e->type == NULL && in_array) + { + if (r < NAATYPES2) + e->type = &attrib_array_types[r]; + r -= NAATYPES2; + } if (e->type == NULL) abort (); } @@ -1009,7 +1106,7 @@ generate_fields (enum FEATURE features, struct entry *e, struct entry *parent, break; case 4: e[n].etype = ETYPE_TYPE; - choose_type (features, &e[n], r); + choose_type (features, &e[n], r, 0); break; case 5: e[n].etype = ETYPE_ARRAY; @@ -1018,7 +1115,7 @@ generate_fields (enum FEATURE features, struct entry *e, struct entry *parent, if (i) e[n].type = &base_types[r % NTYPES1]; else - choose_type (features, &e[n], r); + choose_type (features, &e[n], r, 1); r = generate_random (); if ((features & FEATURE_ZEROARRAY) && (r & 3) == 0) { @@ -1192,6 +1289,8 @@ generate_fields (enum FEATURE features, struct entry *e, struct entry *parent, && strcmp (e[n].attrib, "atpa") == 0 && ((e[n].type >= &attrib_types[0] && e[n].type < &attrib_types[NATYPES2]) + || (e[n].type >= &attrib_array_types[0] + && e[n].type < &attrib_array_types[NAATYPES2]) || (e[n].type >= &aligned_bitfld_types[0] && e[n].type < &aligned_bitfld_types[n_aligned_bitfld_types]))) e[n].attrib = NULL; |