1b147717bSStephen Long // RUN: %clang_cc1 -fms-extensions -fsyntax-only -verify %s
2b147717bSStephen Long
3b147717bSStephen Long #pragma alloc_text() // expected-warning {{expected a string literal for the section name in '#pragma alloc_text'}}
4b147717bSStephen Long #pragma alloc_text(a // expected-warning {{expected ',' in '#pragma alloc_text'}}
5b147717bSStephen Long #pragma alloc_text(a, a // expected-warning {{missing ')' after '#pragma alloc_text'}}
6b147717bSStephen Long #pragma alloc_text(a, a) // expected-error {{use of undeclared a}}
7b147717bSStephen Long #pragma alloc_text(L"a", a) // expected-warning {{expected a string literal for the section name}}
8b147717bSStephen Long
9b147717bSStephen Long void foo();
10b147717bSStephen Long #pragma alloc_text(a, foo) // expected-error {{'#pragma alloc_text' is applicable only to functions with C linkage}}
11b147717bSStephen Long
12b147717bSStephen Long extern "C" void foo1();
13b147717bSStephen Long #pragma alloc_text(a, foo1) // no-warning
14b147717bSStephen Long #pragma alloc_text(a, foo1) asdf // expected-warning {{extra tokens at end of '#pragma alloc_text'}}
15b147717bSStephen Long #pragma alloc_text(a, foo1 // expected-warning {{missing ')' after '#pragma alloc_text'}}
16b147717bSStephen Long
17b147717bSStephen Long namespace N {
18b147717bSStephen Long #pragma alloc_text(b, foo1) // no-warning
19b147717bSStephen Long }
20b147717bSStephen Long
21b147717bSStephen Long extern "C" {
22b147717bSStephen Long void foo2();
23b147717bSStephen Long #pragma alloc_text(a, foo2) // no-warning
24b147717bSStephen Long }
25b147717bSStephen Long
foo3()26b147717bSStephen Long void foo3() {
27b147717bSStephen Long #pragma alloc_text(a, foo1) // expected-error {{'#pragma alloc_text' can only appear at file scope}}
28b147717bSStephen Long }
29b147717bSStephen Long
30b147717bSStephen Long extern "C" void foo4();
31b147717bSStephen Long #pragma alloc_text(c, foo4) // no-warning
foo4()32b147717bSStephen Long void foo4() {}
33b147717bSStephen Long
34b147717bSStephen Long void foo5(); // expected-note {{previous declaration is here}}
35b147717bSStephen Long #pragma alloc_text(c, foo5) // expected-error {{'#pragma alloc_text' is applicable only to functions with C linkage}}
foo5()36b147717bSStephen Long extern "C" void foo5() {} // expected-error {{declaration of 'foo5' has a different language linkage}}
37a5b056feSStephen Long
38a5b056feSStephen Long extern "C" {
39a5b056feSStephen Long static void foo6();
40a5b056feSStephen Long #pragma alloc_text(c, foo6) // no-warning
foo6()41a5b056feSStephen Long void foo6() {}
42a5b056feSStephen Long }
43*f382545bSStephen Long
44*f382545bSStephen Long extern "C" {
45*f382545bSStephen Long static void foo7();
46*f382545bSStephen Long }
47*f382545bSStephen Long static void foo7();
48*f382545bSStephen Long #pragma alloc_text(c, foo7) // no-warning
foo7()49*f382545bSStephen Long void foo7() {}
50*f382545bSStephen Long
51*f382545bSStephen Long static void foo8();
52*f382545bSStephen Long extern "C" {
53*f382545bSStephen Long static void foo8();
54*f382545bSStephen Long }
55*f382545bSStephen Long #pragma alloc_text(c, foo8) // expected-error {{'#pragma alloc_text' is applicable only to functions with C linkage}}
foo8()56*f382545bSStephen Long void foo8() {}
57*f382545bSStephen Long
58*f382545bSStephen Long enum foo9 { A, B, C };
59*f382545bSStephen Long #pragma alloc_text(c, foo9) // expected-error {{'#pragma alloc_text' is applicable only to functions}}
60