| 1 |
/* |
| 2 |
REQUIRED_ARGS: -HC -c -o- |
| 3 |
PERMUTE_ARGS: |
| 4 |
TEST_OUTPUT: |
| 5 |
--- |
| 6 |
// Automatically generated by Digital Mars D Compiler |
| 7 |
|
| 8 |
#pragma once |
| 9 |
|
| 10 |
#include <assert.h> |
| 11 |
#include <math.h> |
| 12 |
#include <stddef.h> |
| 13 |
#include <stdint.h> |
| 14 |
|
| 15 |
struct Outer final |
| 16 |
{ |
| 17 |
int32_t a; |
| 18 |
struct Member final |
| 19 |
{ |
| 20 |
typedef int32_t Nested; |
| 21 |
Member() |
| 22 |
{ |
| 23 |
} |
| 24 |
}; |
| 25 |
|
| 26 |
Outer() : |
| 27 |
a() |
| 28 |
{ |
| 29 |
} |
| 30 |
Outer(int32_t a) : |
| 31 |
a(a) |
| 32 |
{} |
| 33 |
}; |
| 34 |
|
| 35 |
enum : int32_t { SomeOtherLength = 1 }; |
| 36 |
|
| 37 |
struct ActualBuffer final |
| 38 |
{ |
| 39 |
ActualBuffer() |
| 40 |
{ |
| 41 |
} |
| 42 |
}; |
| 43 |
|
| 44 |
template <typename T> |
| 45 |
struct A final |
| 46 |
{ |
| 47 |
T x; |
| 48 |
enum : int32_t { Enum = 42 }; |
| 49 |
|
| 50 |
static int32_t GsharedNum; |
| 51 |
const int32_t MemNum; |
| 52 |
void foo(); |
| 53 |
A() |
| 54 |
{ |
| 55 |
} |
| 56 |
}; |
| 57 |
|
| 58 |
template <typename T> |
| 59 |
struct NotInstantiated final |
| 60 |
{ |
| 61 |
NotInstantiated() |
| 62 |
{ |
| 63 |
} |
| 64 |
}; |
| 65 |
|
| 66 |
struct B final |
| 67 |
{ |
| 68 |
A<int32_t > x; |
| 69 |
B() : |
| 70 |
x() |
| 71 |
{ |
| 72 |
} |
| 73 |
B(A<int32_t > x) : |
| 74 |
x(x) |
| 75 |
{} |
| 76 |
}; |
| 77 |
|
| 78 |
template <typename T> |
| 79 |
struct Foo final |
| 80 |
{ |
| 81 |
T val; |
| 82 |
Foo() |
| 83 |
{ |
| 84 |
} |
| 85 |
}; |
| 86 |
|
| 87 |
template <typename T> |
| 88 |
struct Bar final |
| 89 |
{ |
| 90 |
Foo<T > v; |
| 91 |
Bar() |
| 92 |
{ |
| 93 |
} |
| 94 |
}; |
| 95 |
|
| 96 |
template <typename T> |
| 97 |
struct Array final |
| 98 |
{ |
| 99 |
typedef Array This; |
| 100 |
typedef typeof(1 + 2) Int; |
| 101 |
typedef typeof(T::a) IC; |
| 102 |
Array(size_t dim); |
| 103 |
~Array(); |
| 104 |
void get() const; |
| 105 |
template <typename T> |
| 106 |
bool opCast() const; |
| 107 |
typename T::Member i; |
| 108 |
typename Outer::Member::Nested j; |
| 109 |
void visit(typename T::Member::Nested i); |
| 110 |
Array() |
| 111 |
{ |
| 112 |
} |
| 113 |
}; |
| 114 |
|
| 115 |
template <typename T, typename U> |
| 116 |
extern T foo(U u); |
| 117 |
|
| 118 |
extern A<A<int32_t > > aaint; |
| 119 |
|
| 120 |
template <typename T> |
| 121 |
class Parent |
| 122 |
{ |
| 123 |
public: |
| 124 |
T parentMember; |
| 125 |
void parentFinal(); |
| 126 |
virtual void parentVirtual(); |
| 127 |
}; |
| 128 |
|
| 129 |
template <typename T> |
| 130 |
class Child final : public Parent<T > |
| 131 |
{ |
| 132 |
public: |
| 133 |
T childMember; |
| 134 |
void parentVirtual() override; |
| 135 |
T childFinal(); |
| 136 |
}; |
| 137 |
|
| 138 |
extern void withDefTempl(A<int32_t > a = A<int32_t >(2, 13)); |
| 139 |
|
| 140 |
template <typename T> |
| 141 |
extern void withDefTempl2(A<T > a = static_cast<A<T >>(A<T >(2))); |
| 142 |
|
| 143 |
class ChildInt : public Parent<int32_t > |
| 144 |
{ |
| 145 |
}; |
| 146 |
|
| 147 |
struct HasMixins final |
| 148 |
{ |
| 149 |
void foo(int32_t t); |
| 150 |
HasMixins() |
| 151 |
{ |
| 152 |
} |
| 153 |
}; |
| 154 |
|
| 155 |
template <typename T> |
| 156 |
struct HasMixinsTemplate final |
| 157 |
{ |
| 158 |
void foo(T t); |
| 159 |
HasMixinsTemplate() |
| 160 |
{ |
| 161 |
} |
| 162 |
}; |
| 163 |
|
| 164 |
extern HasMixinsTemplate<bool > hmti; |
| 165 |
|
| 166 |
template <typename T> |
| 167 |
struct NotAA final |
| 168 |
{ |
| 169 |
enum : int32_t { length = 12 }; |
| 170 |
|
| 171 |
T buffer[length]; |
| 172 |
T otherBuffer[SomeOtherLength]; |
| 173 |
T calcBuffer[foo(1)]; |
| 174 |
NotAA() |
| 175 |
{ |
| 176 |
} |
| 177 |
}; |
| 178 |
|
| 179 |
template <typename Buffer> |
| 180 |
struct BufferTmpl final |
| 181 |
{ |
| 182 |
Buffer buffer; |
| 183 |
Buffer buffer2; |
| 184 |
BufferTmpl() |
| 185 |
{ |
| 186 |
} |
| 187 |
}; |
| 188 |
|
| 189 |
struct ImportedBuffer final |
| 190 |
{ |
| 191 |
typedef ActualBuffer Buffer; |
| 192 |
ActualBuffer buffer2; |
| 193 |
ImportedBuffer() : |
| 194 |
buffer2() |
| 195 |
{ |
| 196 |
} |
| 197 |
ImportedBuffer(ActualBuffer buffer2) : |
| 198 |
buffer2(buffer2) |
| 199 |
{} |
| 200 |
}; |
| 201 |
--- |
| 202 |
*/ |
| 203 |
|
| 204 |
extern (C++) struct A(T) |
| 205 |
{ |
| 206 |
T x; |
| 207 |
enum Enum = 42; |
| 208 |
__gshared GsharedNum = 43; |
| 209 |
immutable MemNum = 13; |
| 210 |
void foo() {} |
| 211 |
} |
| 212 |
|
| 213 |
// Invalid declarations accepted because it's not instantiated |
| 214 |
extern (C++) struct NotInstantiated(T) |
| 215 |
{ |
| 216 |
enum T noInit; |
| 217 |
enum missingSem = T.init; |
| 218 |
} |
| 219 |
|
| 220 |
extern (C++) struct B |
| 221 |
{ |
| 222 |
A!int x; |
| 223 |
} |
| 224 |
|
| 225 |
// https://issues.dlang.org/show_bug.cgi?id=20604 |
| 226 |
extern(C++) |
| 227 |
{ |
| 228 |
struct Foo (T) |
| 229 |
{ |
| 230 |
T val; |
| 231 |
} |
| 232 |
|
| 233 |
struct Bar (T) |
| 234 |
{ |
| 235 |
Foo!T v; |
| 236 |
} |
| 237 |
} |
| 238 |
|
| 239 |
extern (C++) struct Array(T) |
| 240 |
{ |
| 241 |
alias This = typeof(this); |
| 242 |
alias Int = typeof(1 + 2); |
| 243 |
alias IC = typeof(T.a); |
| 244 |
|
| 245 |
this(size_t dim) pure nothrow {} |
| 246 |
@disable this(this); |
| 247 |
~this() {} |
| 248 |
void get() const {} |
| 249 |
|
| 250 |
bool opCast(T)() const pure nothrow @nogc @safe |
| 251 |
if (is(T == bool)) |
| 252 |
{ |
| 253 |
return str.ptr !is null; |
| 254 |
} |
| 255 |
|
| 256 |
T.Member i; |
| 257 |
Outer.Member.Nested j; |
| 258 |
void visit(T.Member.Nested i) {} |
| 259 |
} |
| 260 |
|
| 261 |
struct Outer |
| 262 |
{ |
| 263 |
int a; |
| 264 |
static struct Member |
| 265 |
{ |
| 266 |
alias Nested = int; |
| 267 |
} |
| 268 |
} |
| 269 |
|
| 270 |
// alias AO = Array!Outer; |
| 271 |
|
| 272 |
extern(C++) T foo(T, U)(U u) { return T.init; } |
| 273 |
|
| 274 |
extern(C++) __gshared A!(A!int) aaint; |
| 275 |
|
| 276 |
extern(C++) class Parent(T) |
| 277 |
{ |
| 278 |
T parentMember; |
| 279 |
final void parentFinal() {} |
| 280 |
void parentVirtual() {} |
| 281 |
} |
| 282 |
|
| 283 |
extern(C++) final class Child(T) : Parent!T |
| 284 |
{ |
| 285 |
T childMember; |
| 286 |
override void parentVirtual() {} |
| 287 |
T childFinal() { return T.init; } |
| 288 |
} |
| 289 |
|
| 290 |
extern(C++) void withDefTempl(A!int a = A!int(2)) {} |
| 291 |
|
| 292 |
extern(C++) void withDefTempl2(T)(A!T a = A!T(2)) {} |
| 293 |
|
| 294 |
extern(C++) alias withDefTempl2Inst = withDefTempl2!int; |
| 295 |
|
| 296 |
extern(C++) class ChildInt : Parent!int {} |
| 297 |
|
| 298 |
/****************************************************** |
| 299 |
* Mixins |
| 300 |
*/ |
| 301 |
|
| 302 |
extern (C++): |
| 303 |
|
| 304 |
mixin template MixinA(T) |
| 305 |
{ |
| 306 |
void foo(T t) {} |
| 307 |
} |
| 308 |
|
| 309 |
mixin template MixinB() {} |
| 310 |
|
| 311 |
struct HasMixins |
| 312 |
{ |
| 313 |
mixin MixinA!int; |
| 314 |
mixin MixinB; |
| 315 |
} |
| 316 |
|
| 317 |
struct HasMixinsTemplate(T) |
| 318 |
{ |
| 319 |
mixin MixinA!T; |
| 320 |
mixin MixinB; |
| 321 |
} |
| 322 |
|
| 323 |
__gshared HasMixinsTemplate!bool hmti; |
| 324 |
|
| 325 |
/// Declarations that look like associative arrays |
| 326 |
|
| 327 |
extern(D) enum SomeOtherLength = 1; |
| 328 |
|
| 329 |
struct NotAA(T) |
| 330 |
{ |
| 331 |
private: |
| 332 |
enum length = 12; |
| 333 |
public: |
| 334 |
T[length] buffer; |
| 335 |
T[SomeOtherLength] otherBuffer; |
| 336 |
T[foo(1)] calcBuffer; |
| 337 |
} |
| 338 |
|
| 339 |
// Same name but hidden by the template paramter |
| 340 |
extern (D) struct Buffer {} |
| 341 |
extern (D) struct ActualBuffer {} |
| 342 |
|
| 343 |
struct BufferTmpl(Buffer) |
| 344 |
{ |
| 345 |
Buffer buffer; |
| 346 |
mixin BufferMixin!(); |
| 347 |
} |
| 348 |
|
| 349 |
struct ImportedBuffer |
| 350 |
{ |
| 351 |
alias Buffer = ActualBuffer; |
| 352 |
mixin BufferMixin!(); |
| 353 |
} |
| 354 |
|
| 355 |
mixin template BufferMixin() |
| 356 |
{ |
| 357 |
Buffer buffer2; |
| 358 |
} |