annotate clang/test/Sema/pragma-section.c @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple x86_64-pc-win32
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 #pragma const_seg(".my_const") // expected-note 2 {{#pragma entered here}}
anatofuz
parents:
diff changeset
4 extern const int a;
anatofuz
parents:
diff changeset
5 const int a = 1; // expected-note 2 {{declared here}}
anatofuz
parents:
diff changeset
6 #pragma data_seg(".my_const") // expected-note {{#pragma entered here}}
anatofuz
parents:
diff changeset
7 int b = 1; // expected-error {{'b' causes a section type conflict with 'a'}}
anatofuz
parents:
diff changeset
8 #pragma data_seg()
anatofuz
parents:
diff changeset
9 int c = 1;
anatofuz
parents:
diff changeset
10 __declspec(allocate(".my_const")) int d = 1; // expected-error {{'d' causes a section type conflict with 'a'}}
anatofuz
parents:
diff changeset
11 #pragma data_seg("\u") // expected-error {{\u used with no following hex digits}}
anatofuz
parents:
diff changeset
12 #pragma data_seg("a" L"b") // expected-warning {{expected non-wide string literal in '#pragma data_seg'}}
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 #pragma section(".my_seg", execute) // expected-note 2 {{#pragma entered her}}
anatofuz
parents:
diff changeset
15 __declspec(allocate(".my_seg")) int int_my_seg;
anatofuz
parents:
diff changeset
16 #pragma code_seg(".my_seg")
anatofuz
parents:
diff changeset
17 void fn_my_seg(void){}
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 __declspec(allocate(".bad_seg")) int int_bad_seg = 1; // expected-note {{declared here}}
anatofuz
parents:
diff changeset
20 #pragma code_seg(".bad_seg") // expected-note {{#pragma entered here}}
anatofuz
parents:
diff changeset
21 void fn_bad_seg(void){} // expected-error {{'fn_bad_seg' causes a section type conflict with 'int_bad_seg'}}
anatofuz
parents:
diff changeset
22
anatofuz
parents:
diff changeset
23 #pragma bss_seg // expected-warning {{missing '(' after '#pragma bss_seg' - ignoring}}
anatofuz
parents:
diff changeset
24 #pragma bss_seg(L".my_seg") // expected-warning {{expected push, pop or a string literal for the section name in '#pragma bss_seg' - ignored}}
anatofuz
parents:
diff changeset
25 #pragma bss_seg(1) // expected-warning {{expected push, pop or a string literal for the section name in '#pragma bss_seg' - ignored}}
anatofuz
parents:
diff changeset
26 #pragma bss_seg(push)
anatofuz
parents:
diff changeset
27 #pragma bss_seg(push, ".my_seg")
anatofuz
parents:
diff changeset
28 #pragma bss_seg(push, 1) // expected-warning {{expected a stack label or a string literal for the section name in '#pragma bss_seg'}}
anatofuz
parents:
diff changeset
29 #pragma bss_seg ".my_seg" // expected-warning {{missing '(' after '#pragma bss_seg' - ignoring}}
anatofuz
parents:
diff changeset
30 #pragma bss_seg(push, my_label, 1) // expected-warning {{expected a string literal for the section name in '#pragma bss_seg' - ignored}}
anatofuz
parents:
diff changeset
31 #pragma bss_seg(".my_seg", 1) // expected-warning {{missing ')' after '#pragma bss_seg' - ignoring}}
anatofuz
parents:
diff changeset
32 #pragma bss_seg(".my_seg" // expected-warning {{missing ')' after '#pragma bss_seg' - ignoring}}
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 #pragma section // expected-warning {{missing '(' after '#pragma section' - ignoring}}
anatofuz
parents:
diff changeset
35 #pragma section( // expected-warning {{expected a string literal for the section name in '#pragma section' - ignored}}
anatofuz
parents:
diff changeset
36 #pragma section(L".my_seg") // expected-warning {{expected a string literal for the section name in '#pragma section' - ignored}}
anatofuz
parents:
diff changeset
37 #pragma section(".my_seg" // expected-warning {{missing ')' after '#pragma section' - ignoring}}
anatofuz
parents:
diff changeset
38 #pragma section(".my_seg" 1 // expected-warning {{missing ')' after '#pragma section' - ignoring}}
anatofuz
parents:
diff changeset
39 #pragma section(".my_seg", // expected-warning {{expected action or ')' in '#pragma section' - ignored}}
anatofuz
parents:
diff changeset
40 #pragma section(".my_seg", read) // expected-error {{this causes a section type conflict with a prior #pragma section}}
anatofuz
parents:
diff changeset
41 #pragma section(".my_seg", bogus) // expected-warning {{unknown action 'bogus' for '#pragma section' - ignored}}
anatofuz
parents:
diff changeset
42 #pragma section(".my_seg", nopage) // expected-warning {{known but unsupported action 'nopage' for '#pragma section' - ignored}}
anatofuz
parents:
diff changeset
43 #pragma section(".my_seg", read, write) // expected-error {{this causes a section type conflict with a prior #pragma section}}
anatofuz
parents:
diff changeset
44 #pragma section(".my_seg", read, write, 1) // expected-warning {{expected action or ')' in '#pragma section' - ignored}}
anatofuz
parents:
diff changeset
45
anatofuz
parents:
diff changeset
46 #pragma bss_seg(".drectve") // expected-warning{{#pragma bss_seg(".drectve") has undefined behavior, use #pragma comment(linker, ...) instead}}
anatofuz
parents:
diff changeset
47 #pragma code_seg(".drectve") // expected-warning{{#pragma code_seg(".drectve") has undefined behavior, use #pragma comment(linker, ...) instead}}
anatofuz
parents:
diff changeset
48 #pragma const_seg(".drectve") // expected-warning{{#pragma const_seg(".drectve") has undefined behavior, use #pragma comment(linker, ...) instead}}
anatofuz
parents:
diff changeset
49 #pragma data_seg(".drectve") // expected-warning{{#pragma data_seg(".drectve") has undefined behavior, use #pragma comment(linker, ...) instead}}
anatofuz
parents:
diff changeset
50 #pragma code_seg(".my_seg")
anatofuz
parents:
diff changeset
51
anatofuz
parents:
diff changeset
52 // cl.exe doesn't warn on this, so match that.
anatofuz
parents:
diff changeset
53 // (Technically it ICEs on this particular example, but if it's on a class then
anatofuz
parents:
diff changeset
54 // it just doesn't warn.)
anatofuz
parents:
diff changeset
55 __declspec(code_seg(".drectve")) void drectve_fn(void) {}
anatofuz
parents:
diff changeset
56
anatofuz
parents:
diff changeset
57 // This shouldn't warn; mingw users likely want to use
anatofuz
parents:
diff changeset
58 // __attribute__((section(".drective")))
anatofuz
parents:
diff changeset
59 // const char LinkerFlags[] = "-export:foo -export:bar";
anatofuz
parents:
diff changeset
60 // for interop with gcc.
anatofuz
parents:
diff changeset
61 __attribute__((section(".drectve"))) int drectve_int;