[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Sema / attr-btf_tag.c
blobcbb21a5a88bb68b90db61803503dfb317838d417
1 // RUN: %clang_cc1 -x c -triple x86_64-pc-linux-gnu -dwarf-version=4 -fsyntax-only -verify %s
3 #define __tag1 __attribute__((btf_decl_tag("tag1")))
4 #define __tag2 __attribute__((btf_decl_tag("tag2")))
5 #define __tag3 __attribute__((btf_decl_tag("tag3")))
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)))
11 struct __tag1 __tag2 t1;
12 struct t1 {
13 int a __tag1;
14 } __tag3;
16 struct __tag1 t2;
17 struct __tag2 __tag3 t2 {
18 int a __tag1;
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}}
26 enum e1 {
28 } __tag1; // expected-error {{'btf_decl_tag' attribute only applies to variables, functions, structs, unions, classes, non-static data members, and typedefs}}
30 enum 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}}
34 enum 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}}
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;
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;