brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 9a41eb4 Raw
54 lines · c
1// RUN: %clang_cc1 -verify -fsyntax-only -triple x86_64-apple-darwin9 %s2 3int x __attribute__((section(4   42)));  // expected-error {{expected string literal as argument of 'section' attribute}}5 6int y __attribute__((section(7   "sadf"))); // expected-error {{mach-o section specifier requires a segment and section separated by a comma}}8 9// PR600710void test(void) {11  __attribute__((section("NEAR,x"))) int n1; // expected-error {{'section' attribute only applies to functions, global variables, Objective-C methods, and Objective-C properties}}12  __attribute__((section("NEAR,x"))) static int n2; // ok.13}14 15// pr935616void __attribute__((section("foo,zed"))) test2(void); // expected-note {{previous attribute is here}}17void __attribute__((section("bar,zed"))) test2(void) {} // expected-warning {{section does not match previous declaration}}18 19enum __attribute__((section("NEAR,x"))) e { one }; // expected-error {{'section' attribute only applies to}}20 21extern int a; // expected-note {{previous declaration is here}}22int *b = &a;23extern int a __attribute__((section("foo,zed"))); // expected-warning {{section attribute is specified on redeclared variable}}24 25// Not a warning.26int c;27int c __attribute__((section("seg1,sec1")));28 29const int with_init __attribute__((section("init_mix,x"))) = 1;30const int no_init __attribute__((section("init_mix,x")));31 32// Also OK.33struct r_debug {};34extern struct r_debug _r_debug;35struct r_debug _r_debug __attribute__((nocommon, section(".r_debug,bar")));36 37// Section type conflicts between functions and variables38void test3(void) __attribute__((section("seg3,sec3"))); // expected-note {{declared here}}39void test3(void) {}40const int const_global_var __attribute__((section("seg3,sec3"))) = 10; // expected-error {{'const_global_var' causes a section type conflict with 'test3'}}41 42void test4(void) __attribute__((section("seg4,sec4"))); // expected-note {{declared here}}43void test4(void) {}44int mut_global_var __attribute__((section("seg4,sec4"))) = 10; // expected-error {{'mut_global_var' causes a section type conflict with 'test4'}}45 46const int global_seg5sec5 __attribute__((section("seg5,sec5"))) = 10; // expected-note {{declared here}}47void test5(void) __attribute__((section("seg5,sec5")));               // expected-error {{'test5' causes a section type conflict with 'global_seg5sec5'}}48void test5(void) {}49 50void test6(void);51const int global_seg6sec6 __attribute__((section("seg6,sec6"))) = 10; // expected-note {{declared here}}52void test6(void) __attribute__((section("seg6,sec6")));               // expected-error {{'test6' causes a section type conflict with 'global_seg6sec6'}}53void test6(void) {}54