[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / dllimport-memptr-global.cpp
blob951f933e10aafe94e49e8dd5f92ee617fe85ce56
1 // Also check that -Wglobal-constructors does the right thing. Strictly
2 // speaking, this is a Sema test, but this avoids test case duplication.
3 // RUN: %clang_cc1 -Wglobal-constructors %s -verify -triple i686-windows-msvc -fms-extensions -std=c++11
4 //
5 // RUN: %clang_cc1 %s -emit-llvm -o - -triple i686-windows-msvc -fms-extensions -std=c++11 | FileCheck %s
7 struct __declspec(dllimport) Single {
8 void nonvirt();
9 virtual void virt();
12 struct A { int a; };
13 struct B { int b; };
14 struct __declspec(dllimport) Multi : A, B {
15 void nonvirt();
16 virtual void virt();
19 struct __declspec(dllimport) Virtual : virtual A {
20 void nonvirt();
21 virtual void virt();
24 struct General;
25 static_assert(sizeof(void (General::*)()) == 16, "force general memptr model");
26 struct __declspec(dllimport) General {
27 void nonvirt();
28 virtual void virt();
31 auto mp_single_nv = &Single::nonvirt; // expected-warning {{global constructor}}
32 auto mp_multi_nv = &Multi::nonvirt; // expected-warning {{global constructor}}
33 auto mp_virtual_nv = &Virtual::nonvirt; // expected-warning {{global constructor}}
34 auto mp_general_nv = &General::nonvirt; // expected-warning {{global constructor}}
36 auto mp_single_v = &Single::virt;
37 auto mp_multi_v = &Multi::virt;
38 auto mp_virtual_v = &Virtual::virt;
39 auto mp_general_v = &General::virt;
41 // All of the non-virtual globals need dynamic initializers.
43 // CHECK: @"?mp_single_nv@@3P8Single@@AEXXZQ1@" = dso_local global ptr null, align 4
44 // CHECK: @"?mp_multi_nv@@3P8Multi@@AEXXZQ1@" = dso_local global { ptr, i32 } zeroinitializer, align 4
45 // CHECK: @"?mp_virtual_nv@@3P8Virtual@@AEXXZQ1@" = dso_local global { ptr, i32, i32 } zeroinitializer, align 4
46 // CHECK: @"?mp_general_nv@@3P8General@@AEXXZQ1@" = dso_local global { ptr, i32, i32, i32 } zeroinitializer, align 4
48 // CHECK: @"?mp_single_v@@3P8Single@@AEXXZQ1@" = dso_local global ptr @"??_9Single@@$BA@AE", align 4
49 // CHECK: @"?mp_multi_v@@3P8Multi@@AEXXZQ1@" = dso_local global { ptr, i32 } { ptr @"??_9Multi@@$BA@AE", i32 0 }, align 4
50 // CHECK: @"?mp_virtual_v@@3P8Virtual@@AEXXZQ1@" = dso_local global { ptr, i32, i32 } { ptr @"??_9Virtual@@$BA@AE", i32 0, i32 0 }, align 4
51 // CHECK: @"?mp_general_v@@3P8General@@AEXXZQ1@" = dso_local global { ptr, i32, i32, i32 } { ptr @"??_9General@@$BA@AE", i32 0, i32 0, i32 0 }, align 4
53 // CHECK: define internal void @_GLOBAL__sub_I{{.*}}() {{.*}} {
54 // CHECK: call void @"??__Emp_single_nv@@YAXXZ"()
55 // CHECK: call void @"??__Emp_multi_nv@@YAXXZ"()
56 // CHECK: call void @"??__Emp_virtual_nv@@YAXXZ"()
57 // CHECK: call void @"??__Emp_general_nv@@YAXXZ"()
58 // CHECK: }