| 1 |
/* PR c/88363 - alloc_align attribute doesn't accept enumerated arguments |
| 2 |
Verify that attribute positional arguments can refer to all C integer |
| 3 |
types except _Bool in both C and C++. |
| 4 |
{ dg-do compile } |
| 5 |
{ dg-options "-Wall" } |
| 6 |
{ dg-options "-Wall -Wno-c++-compat" { target c } } */ |
| 7 |
|
| 8 |
#define ATTR(...) __attribute__ ((__VA_ARGS__)) |
| 9 |
|
| 10 |
#if __cplusplus == 199711L |
| 11 |
typedef __CHAR16_TYPE__ char16_t; |
| 12 |
typedef __CHAR32_TYPE__ char32_t; |
| 13 |
#elif !__cplusplus |
| 14 |
typedef __CHAR16_TYPE__ char16_t; |
| 15 |
typedef __CHAR32_TYPE__ char32_t; |
| 16 |
typedef __WCHAR_TYPE__ wchar_t; |
| 17 |
#endif |
| 18 |
|
| 19 |
enum A { A0 }; |
| 20 |
|
| 21 |
ATTR (alloc_align (1)) void* falloc_align_char (char); |
| 22 |
ATTR (alloc_align (1)) void* falloc_align_char16 (char16_t); |
| 23 |
ATTR (alloc_align (1)) void* falloc_align_char32 (char32_t); |
| 24 |
ATTR (alloc_align (1)) void* falloc_align_wchar (wchar_t); |
| 25 |
/* Using an enum might make sense in an API that limits the alignments |
| 26 |
it accepts to just the set of the defined enumerators. */ |
| 27 |
ATTR (alloc_align (1)) void* falloc_align_enum (enum A); |
| 28 |
#ifdef __SIZEOF_INT128__ |
| 29 |
ATTR (alloc_align (1)) void* falloc_align_int128 (__int128_t); |
| 30 |
#endif |
| 31 |
|
| 32 |
|
| 33 |
ATTR (alloc_align (1)) void* falloc_size_char (char); |
| 34 |
ATTR (alloc_size (1)) void* falloc_size_char16 (char16_t); |
| 35 |
ATTR (alloc_size (1)) void* falloc_size_char32 (char32_t); |
| 36 |
ATTR (alloc_size (1)) void* falloc_size_wchar (wchar_t); |
| 37 |
ATTR (alloc_size (1)) void* falloc_size_enum (enum A); |
| 38 |
#ifdef __SIZEOF_INT128__ |
| 39 |
ATTR (alloc_align (1)) void* falloc_size_int128 (__int128_t); |
| 40 |
#endif |
| 41 |
|
| 42 |
|
| 43 |
typedef struct { int i; } S; |
| 44 |
|
| 45 |
/* Using bool is most likely a bug and so diagnosed even though |
| 46 |
it could be accepted. None of the other types makes sense. */ |
| 47 |
ATTR (alloc_align (1)) void* falloc_align_bool (bool); /* { dg-warning "attribute argument value .1. refers to parameter type .\(_Bool|bool\)" } */ |
| 48 |
ATTR (alloc_align (1)) void* falloc_align_float (float); /* { dg-warning "attribute argument value .1. refers to parameter type .float" } */ |
| 49 |
ATTR (alloc_align (1)) void* falloc_align_voidp (void*); /* { dg-warning "attribute argument value .1. refers to parameter type .void ?\\\*" } */ |
| 50 |
ATTR (alloc_align (1)) void* falloc_align_struct (S); /* { dg-warning "attribute argument value .1. refers to parameter type .S" } */ |