xref: /llvm-project/clang/test/Sema/attr-model.cpp (revision 4df566290751403f470fea3b27aa148ab1ddf144)
1 // RUN: %clang_cc1 -triple aarch64 -verify=expected,aarch64 -fsyntax-only %s
2 // RUN: %clang_cc1 -triple loongarch64 -verify=expected,loongarch64 -fsyntax-only %s
3 // RUN: %clang_cc1 -triple mips64 -verify=expected,mips64 -fsyntax-only %s
4 // RUN: %clang_cc1 -triple powerpc64 -verify=expected,powerpc64 -fsyntax-only %s
5 // RUN: %clang_cc1 -triple riscv64 -verify=expected,riscv64 -fsyntax-only %s
6 // RUN: %clang_cc1 -triple x86_64 -verify=expected,x86_64 -fsyntax-only %s
7 
8 #if defined(__loongarch__) && !__has_attribute(model)
9 #error "Should support model attribute"
10 #endif
11 
12 int a __attribute((model("tiny")));    // aarch64-warning {{unknown attribute 'model' ignored}} \
13                                        // loongarch64-error {{code model 'tiny' is not supported on this target}} \
14                                        // mips64-warning {{unknown attribute 'model' ignored}} \
15                                        // powerpc64-warning {{unknown attribute 'model' ignored}} \
16                                        // riscv64-warning {{unknown attribute 'model' ignored}} \
17                                        // x86_64-warning {{unknown attribute 'model' ignored}}
18 int b __attribute((model("small")));   // aarch64-warning {{unknown attribute 'model' ignored}} \
19                                        // loongarch64-error {{code model 'small' is not supported on this target}} \
20                                        // mips64-warning {{unknown attribute 'model' ignored}} \
21                                        // powerpc64-warning {{unknown attribute 'model' ignored}} \
22                                        // riscv64-warning {{unknown attribute 'model' ignored}} \
23                                        // x86_64-warning {{unknown attribute 'model' ignored}}
24 int c __attribute((model("normal")));  // aarch64-warning {{unknown attribute 'model' ignored}} \
25                                        // mips64-warning {{unknown attribute 'model' ignored}} \
26                                        // powerpc64-warning {{unknown attribute 'model' ignored}} \
27                                        // riscv64-warning {{unknown attribute 'model' ignored}} \
28                                        // x86_64-warning {{unknown attribute 'model' ignored}}
29 int d __attribute((model("kernel")));  // aarch64-warning {{unknown attribute 'model' ignored}} \
30                                        // loongarch64-error {{code model 'kernel' is not supported on this target}} \
31                                        // mips64-warning {{unknown attribute 'model' ignored}} \
32                                        // powerpc64-warning {{unknown attribute 'model' ignored}} \
33                                        // riscv64-warning {{unknown attribute 'model' ignored}} \
34                                        // x86_64-warning {{unknown attribute 'model' ignored}}
35 int e __attribute((model("medium")));  // aarch64-warning {{unknown attribute 'model' ignored}} \
36                                        // mips64-warning {{unknown attribute 'model' ignored}} \
37                                        // powerpc64-warning {{unknown attribute 'model' ignored}} \
38                                        // riscv64-warning {{unknown attribute 'model' ignored}} \
39                                        // x86_64-warning {{unknown attribute 'model' ignored}}
40 int f __attribute((model("large")));   // aarch64-warning {{unknown attribute 'model' ignored}} \
41                                        // loongarch64-error {{code model 'large' is not supported on this target}} \
42                                        // mips64-warning {{unknown attribute 'model' ignored}} \
43                                        // powerpc64-warning {{unknown attribute 'model' ignored}} \
44                                        // riscv64-warning {{unknown attribute 'model' ignored}} \
45                                        // x86_64-warning {{unknown attribute 'model' ignored}}
46 int g __attribute((model("extreme"))); // aarch64-warning {{unknown attribute 'model' ignored}} \
47                                        // mips64-warning {{unknown attribute 'model' ignored}} \
48                                        // powerpc64-warning {{unknown attribute 'model' ignored}} \
49                                        // riscv64-warning {{unknown attribute 'model' ignored}} \
50                                        // x86_64-warning {{unknown attribute 'model' ignored}}
51 
h()52 void __attribute((model("extreme"))) h() {} // aarch64-warning {{unknown attribute 'model' ignored}} \
53                                             // loongarch64-error {{'model' attribute only applies to non-TLS global variables}} \
54                                             // mips64-warning {{unknown attribute 'model' ignored}} \
55                                             // powerpc64-warning {{unknown attribute 'model' ignored}} \
56                                             // riscv64-warning {{unknown attribute 'model' ignored}} \
57                                             // x86_64-warning {{unknown attribute 'model' ignored}}
58 
59 thread_local int i __attribute((model("extreme"))); // aarch64-warning {{unknown attribute 'model' ignored}} \
60                                                     // loongarch64-error {{'model' attribute only applies to non-TLS global variables}} \
61                                                     // mips64-warning {{unknown attribute 'model' ignored}} \
62                                                     // powerpc64-warning {{unknown attribute 'model' ignored}} \
63                                                     // riscv64-warning {{unknown attribute 'model' ignored}} \
64                                                     // x86_64-warning {{unknown attribute 'model' ignored}}
65