1 // RUN: %clang_cc1 -std=c++11 -fms-extensions -fms-compatibility -fsyntax-only -triple=i386-pc-win32 -verify %s
2
3 struct A { int a; };
4
5 #pragma vtordisp(pop) // expected-warning {{#pragma vtordisp(pop, ...) failed: stack empty}}
6 #pragma vtordisp(push, 0)
7 #pragma vtordisp(push, 1)
8 #pragma vtordisp(push, 2)
9 struct B : virtual A { int b; };
10 #pragma vtordisp(pop)
11 #pragma vtordisp(pop)
12 #pragma vtordisp(pop)
13 #pragma vtordisp(pop) // expected-warning {{#pragma vtordisp(pop, ...) failed: stack empty}}
14
15 #pragma vtordisp(push, 3) // expected-warning {{expected integer between 0 and 2 inclusive in '#pragma vtordisp' - ignored}}
16 #pragma vtordisp()
17
18 #define ONE 1
19 #pragma vtordisp(push, ONE)
20 #define TWO 1
21 #pragma vtordisp(push, TWO)
22
23 // Test a reset.
24 #pragma vtordisp()
25 #pragma vtordisp(pop) // stack should NOT be affected by reset.
26 // Now stack contains '1'.
27
28 #pragma vtordisp( // expected-warning {{unknown action for '#pragma vtordisp' - ignored}}
29 #pragma vtordisp(asdf) // expected-warning {{unknown action for '#pragma vtordisp' - ignored}}
30 #pragma vtordisp(,) // expected-warning {{unknown action for '#pragma vtordisp' - ignored}}
31 #pragma vtordisp // expected-warning {{missing '(' after '#pragma vtordisp' - ignoring}}
32 #pragma vtordisp(3) // expected-warning {{expected integer between 0 and 2 inclusive in '#pragma vtordisp' - ignored}}
33 #pragma vtordisp(), stuff // expected-warning {{extra tokens}}
34
35 struct C {
36 #pragma vtordisp()
37 struct D : virtual A {
38 };
39 };
40
41 struct E {
42 virtual ~E();
43 virtual void f();
44 };
45
46 #pragma vtordisp(pop) // After this stack should be empty.
47 #pragma vtordisp(pop) // expected-warning {{#pragma vtordisp(pop, ...) failed: stack empty}}
48
g()49 void g() {
50 #pragma vtordisp(push, 2)
51 struct F : virtual E {
52 virtual ~F();
53 virtual void f();
54 };
55 }
56
57 #pragma vtordisp(pop) // OK because of local vtordisp(2) in g().
58
59 struct G {
fG60 void f() {
61 #pragma vtordisp(push, 2) // Method-local pragma - stack will be restored on exit.
62 }
63 };
64
65 // Stack is restored on exit from G::f(), nothing to pop.
66 #pragma vtordisp(pop) // expected-warning {{#pragma vtordisp(pop, ...) failed: stack empty}}
67
g2()68 int g2()
69 // FIXME: Our implementation based on token insertion makes it impossible for
70 // the pragma to appear everywhere we should support it.
71 // #pragma vtordisp()
72 {
73 return 0;
74 }
75