| 1 |
// RUN: %clang_cc1 -x c -triple x86_64-pc-linux-gnu -dwarf-version=4 -fsyntax-only -verify %s |
| 2 |
|
| 3 |
#define __tag1 __attribute__((btf_decl_tag("tag1"))) |
| 4 |
#define __tag2 __attribute__((btf_decl_tag("tag2"))) |
| 5 |
#define __tag3 __attribute__((btf_decl_tag("tag3"))) |
| 6 |
|
| 7 |
#define __tag_no_arg __attribute__((btf_decl_tag())) |
| 8 |
#define __tag_2_arg __attribute__((btf_decl_tag("tag1", "tag2"))) |
| 9 |
#define __invalid __attribute__((btf_decl_tag(1))) |
| 10 |
|
| 11 |
struct __tag1 __tag2 t1; |
| 12 |
struct t1 { |
| 13 |
int a __tag1; |
| 14 |
} __tag3; |
| 15 |
|
| 16 |
struct __tag1 t2; |
| 17 |
struct __tag2 __tag3 t2 { |
| 18 |
int a __tag1; |
| 19 |
}; |
| 20 |
|
| 21 |
int g1 __tag1; |
| 22 |
int g2 __tag_no_arg; // expected-error {{'btf_decl_tag' attribute takes one argument}} |
| 23 |
int g3 __tag_2_arg; // expected-error {{'btf_decl_tag' attribute takes one argument}} |
| 24 |
int i1 __invalid; // expected-error {{expected string literal as argument of 'btf_decl_tag' attribute}} |
| 25 |
|
| 26 |
enum e1 { |
| 27 |
E1 |
| 28 |
} __tag1; // expected-error {{'btf_decl_tag' attribute only applies to variables, functions, structs, unions, classes, non-static data members, and typedefs}} |
| 29 |
|
| 30 |
enum e2 { |
| 31 |
E2 |
| 32 |
} __tag_no_arg; // expected-error {{'btf_decl_tag' attribute only applies to variables, functions, structs, unions, classes, non-static data members, and typedefs}} |
| 33 |
|
| 34 |
enum e3 { |
| 35 |
E3 |
| 36 |
} __tag_2_arg; // expected-error {{'btf_decl_tag' attribute only applies to variables, functions, structs, unions, classes, non-static data members, and typedefs}} |
| 37 |
|
| 38 |
int __tag1 __tag2 foo(struct t1 *arg, struct t2 *arg2); |
| 39 |
int __tag2 __tag3 foo(struct t1 *arg, struct t2 *arg2); |
| 40 |
int __tag1 foo(struct t1 *arg __tag1, struct t2 *arg2) { |
| 41 |
return arg->a + arg2->a; |
| 42 |
} |
| 43 |
|
| 44 |
typedef unsigned * __u1 __tag1 __tag2; |
| 45 |
typedef struct { |
| 46 |
int a; |
| 47 |
} __t2 __tag1 __tag2; |
| 48 |
int convert2(__t2 *arg) { |
| 49 |
return arg->a; |
| 50 |
} |