[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Sema / pragma-ms-alloc-text.cpp
bloba150cb2d815af7e1b0013e4a183cdf0ebc3a9ff0
1 // RUN: %clang_cc1 -fms-extensions -fsyntax-only -verify %s
3 #pragma alloc_text() // expected-warning {{expected a string literal for the section name in '#pragma alloc_text'}}
4 #pragma alloc_text(a // expected-warning {{expected ',' in '#pragma alloc_text'}}
5 #pragma alloc_text(a, a // expected-warning {{missing ')' after '#pragma alloc_text'}}
6 #pragma alloc_text(a, a) // expected-error {{use of undeclared a}}
7 #pragma alloc_text(L"a", a) // expected-warning {{expected a string literal for the section name}}
9 void foo();
10 #pragma alloc_text(a, foo) // expected-error {{'#pragma alloc_text' is applicable only to functions with C linkage}}
12 extern "C" void foo1();
13 #pragma alloc_text(a, foo1) // no-warning
14 #pragma alloc_text(a, foo1) asdf // expected-warning {{extra tokens at end of '#pragma alloc_text'}}
15 #pragma alloc_text(a, foo1 // expected-warning {{missing ')' after '#pragma alloc_text'}}
17 namespace N {
18 #pragma alloc_text(b, foo1) // no-warning
21 extern "C" {
22 void foo2();
23 #pragma alloc_text(a, foo2) // no-warning
26 void foo3() {
27 #pragma alloc_text(a, foo1) // expected-error {{'#pragma alloc_text' can only appear at file scope}}
30 extern "C" void foo4();
31 #pragma alloc_text(c, foo4) // no-warning
32 void foo4() {}
34 void foo5(); // expected-note {{previous declaration is here}}
35 #pragma alloc_text(c, foo5) // expected-error {{'#pragma alloc_text' is applicable only to functions with C linkage}}
36 extern "C" void foo5() {} // expected-error {{declaration of 'foo5' has a different language linkage}}
38 extern "C" {
39 static void foo6();
40 #pragma alloc_text(c, foo6) // no-warning
41 void foo6() {}
44 extern "C" {
45 static void foo7();
47 static void foo7();
48 #pragma alloc_text(c, foo7) // no-warning
49 void foo7() {}
51 static void foo8();
52 extern "C" {
53 static void foo8();
55 #pragma alloc_text(c, foo8) // expected-error {{'#pragma alloc_text' is applicable only to functions with C linkage}}
56 void foo8() {}
58 enum foo9 { A, B, C };
59 #pragma alloc_text(c, foo9) // expected-error {{'#pragma alloc_text' is applicable only to functions}}