[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / pragma-vtordisp.cpp
blob1421c33db5d36b001529b376ec7fcf1f6810bb83
1 // RUN: %clang_cc1 -std=c++11 -fms-extensions -fms-compatibility -fsyntax-only -triple=i386-pc-win32 -verify %s
3 struct A { int a; };
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}}
15 #pragma vtordisp(push, 3) // expected-warning {{expected integer between 0 and 2 inclusive in '#pragma vtordisp' - ignored}}
16 #pragma vtordisp()
18 #define ONE 1
19 #pragma vtordisp(push, ONE)
20 #define TWO 1
21 #pragma vtordisp(push, TWO)
23 // Test a reset.
24 #pragma vtordisp()
25 #pragma vtordisp(pop) // stack should NOT be affected by reset.
26 // Now stack contains '1'.
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}}
35 struct C {
36 #pragma vtordisp()
37 struct D : virtual A {
41 struct E {
42 virtual ~E();
43 virtual void f();
46 #pragma vtordisp(pop) // After this stack should be empty.
47 #pragma vtordisp(pop) // expected-warning {{#pragma vtordisp(pop, ...) failed: stack empty}}
49 void g() {
50 #pragma vtordisp(push, 2)
51 struct F : virtual E {
52 virtual ~F();
53 virtual void f();
57 #pragma vtordisp(pop) // OK because of local vtordisp(2) in g().
59 struct G {
60 void f() {
61 #pragma vtordisp(push, 2) // Method-local pragma - stack will be restored on exit.
65 // Stack is restored on exit from G::f(), nothing to pop.
66 #pragma vtordisp(pop) // expected-warning {{#pragma vtordisp(pop, ...) failed: stack empty}}
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()
73 return 0;