xref: /aosp_15_r20/external/clang/test/Sema/attr-section.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -verify -fsyntax-only -triple x86_64-apple-darwin9 %s
2*67e74705SXin Li 
3*67e74705SXin Li int x __attribute__((section(
4*67e74705SXin Li    42)));  // expected-error {{'section' attribute requires a string}}
5*67e74705SXin Li 
6*67e74705SXin Li 
7*67e74705SXin Li // rdar://4341926
8*67e74705SXin Li int y __attribute__((section(
9*67e74705SXin Li    "sadf"))); // expected-error {{mach-o section specifier requires a segment and section separated by a comma}}
10*67e74705SXin Li 
11*67e74705SXin Li // PR6007
test()12*67e74705SXin Li void test() {
13*67e74705SXin Li   __attribute__((section("NEAR,x"))) int n1; // expected-error {{'section' attribute only applies to functions and global variables}}
14*67e74705SXin Li   __attribute__((section("NEAR,x"))) static int n2; // ok.
15*67e74705SXin Li }
16*67e74705SXin Li 
17*67e74705SXin Li // pr9356
18*67e74705SXin Li void __attribute__((section("foo,zed"))) test2(void); // expected-note {{previous attribute is here}}
test2(void)19*67e74705SXin Li void __attribute__((section("bar,zed"))) test2(void) {} // expected-warning {{section does not match previous declaration}}
20*67e74705SXin Li 
21*67e74705SXin Li enum __attribute__((section("NEAR,x"))) e { one }; // expected-error {{'section' attribute only applies to functions and global variables}}
22