Debian Codegraph @

gcc/testsuite/gdc.test/compilable/dtoh_cpp98_compat.d

raw
1 /*
2 REQUIRED_ARGS: -extern-std=c++98 -HC -c -o- -Icompilable/extra-files
3 PERMUTE_ARGS:
4 EXTRA_FILES: extra-files/dtoh_imports.d extra-files/dtoh_imports2.d
5
6 TEST_OUTPUT:
7 ---
8 // Automatically generated by Digital Mars D Compiler
9
10 #pragma once
11
12 #include <assert.h>
13 #include <math.h>
14 #include <stddef.h>
15 #include <stdint.h>
16
17 #ifdef CUSTOM_D_ARRAY_TYPE
18 #define _d_dynamicArray CUSTOM_D_ARRAY_TYPE
19 #else
20 /// Represents a D [] array
21 template<typename T>
22 struct _d_dynamicArray final
23 {
24 size_t length;
25 T *ptr;
26
27 _d_dynamicArray() : length(0), ptr(NULL) { }
28
29 _d_dynamicArray(size_t length_in, T *ptr_in)
30 : length(length_in), ptr(ptr_in) { }
31
32 T& operator[](const size_t idx) {
33 assert(idx < length);
34 return ptr[idx];
35 }
36
37 const T& operator[](const size_t idx) const {
38 assert(idx < length);
39 return ptr[idx];
40 }
41 };
42 #endif
43
44 class ImportsC
45 {
46 };
47
48 struct Null final
49 {
50 void* field;
51 _d_dynamicArray< const char > null_;
52 private:
53 Null(int32_t );
54 public:
55 Null() :
56 field(NULL),
57 null_()
58 {
59 }
60 Null(void* field, _d_dynamicArray< const char > null_ = _d_dynamicArray< const char >()) :
61 field(field),
62 null_(null_)
63 {}
64 };
65
66 extern void* typeof_null;
67
68 extern void* inferred_null;
69
70 struct MyString final
71 {
72 _d_dynamicArray< const char > str;
73 MyString() :
74 str()
75 {
76 }
77 MyString(_d_dynamicArray< const char > str) :
78 str(str)
79 {}
80 };
81
82 struct Wrapper final
83 {
84 MyString s1;
85 MyString s2;
86 Wrapper() :
87 s1(MyString(_d_dynamicArray< const char >( 5, "Hello" ))),
88 s2(MyString(_d_dynamicArray< const char >()))
89 {
90 }
91 Wrapper(MyString s1, MyString s2 = MyString(_d_dynamicArray< const char >())) :
92 s1(s1),
93 s2(s2)
94 {}
95 };
96
97 class UsingBase
98 {
99 public:
100 virtual void foo();
101 };
102
103 class UsingChild : public UsingBase
104 {
105 public:
106 };
107 ---
108 */
109
110 extern (C++) struct Null
111 {
112 void* field = null;
113 string null_ = null;
114
115 @disable this(int);
116 }
117
118 extern (C++) __gshared typeof(null) typeof_null = null;
119 extern (C++) __gshared inferred_null = null;
120
121 extern (C++) struct MyString
122 {
123 string str;
124 }
125
126 extern (C++) struct Wrapper
127 {
128 MyString s1 = MyString("Hello");
129 MyString s2 = MyString(null);
130 }
131
132 extern (C++) class UsingBase
133 {
134 void foo() {}
135 }
136
137 extern (C++) class UsingChild : UsingBase
138 {
139 alias foo = UsingBase.foo;
140 }
141
142 public import dtoh_imports : aliasName = ImportsC;