ldc-0.17.5-src/ 0000755 0001750 0001750 00000000000 13200164644 013341 5 ustar matthias matthias ldc-0.17.5-src/tests/ 0000755 0001750 0001750 00000000000 13156012230 014474 5 ustar matthias matthias ldc-0.17.5-src/tests/ir/ 0000755 0001750 0001750 00000000000 13200164641 015112 5 ustar matthias matthias ldc-0.17.5-src/tests/ir/attr_target_x86.d 0000644 0001750 0001750 00000003725 13200164641 020313 0 ustar matthias matthias // Tests @target attribute for x86
// REQUIRES: atleast_llvm307
// REQUIRES: target_X86
// RUN: %ldc -O -c -mcpu=i386 -mtriple=i386-linux-gnu -output-ll -of=%t.ll %s && FileCheck %s --check-prefix LLVM < %t.ll
// RUN: %ldc -O -c -mcpu=i386 -mtriple=i386-linux-gnu -output-s -of=%t.s %s && FileCheck %s --check-prefix ASM < %t.s
import ldc.attributes;
// LLVM-LABEL: define{{.*}} void @{{.*}}foo
// ASM-LABEL: _D15attr_target_x863fooFPfPffZv:
void foo(float *A, float* B, float K) {
for (int i = 0; i < 128; ++i)
A[i] *= B[i] + K;
// ASM-NOT: addps
}
// LLVM-LABEL: define{{.*}} void @{{.*}}foo_sse
// LLVM-SAME: #[[SSE:[0-9]+]]
// ASM-LABEL: _D15attr_target_x867foo_sseFPfPffZv:
@(target("sse"))
void foo_sse(float *A, float* B, float K) {
for (int i = 0; i < 128; ++i)
A[i] *= B[i] + K;
// ASM: addps
}
// Make sure that no-sse overrides sse (attribute sorting). Also tests multiple @target attribs.
// LLVM-LABEL: define{{.*}} void @{{.*}}foo_nosse
// LLVM-SAME: #[[NOSSE:[0-9]+]]
// ASM-LABEL: _D15attr_target_x869foo_nosseFPfPffZv:
@(target("no-sse\n , \tsse "))
void foo_nosse(float *A, float* B, float K) {
for (int i = 0; i < 128; ++i)
A[i] *= B[i] + K;
// ASM-NOT: addps
}
// LLVM-LABEL: define{{.*}} void @{{.*}}bar_nosse
// LLVM-SAME: #[[NOSSE]]
// ASM-LABEL: _D15attr_target_x869bar_nosseFPfPffZv:
@(target("sse"))
@(target(" no-sse"))
void bar_nosse(float *A, float* B, float K) {
for (int i = 0; i < 128; ++i)
A[i] *= B[i] + K;
// ASM-NOT: addps
}
// LLVM-LABEL: define{{.*}} void @{{.*}}haswell
// LLVM-SAME: #[[HSW:[0-9]+]]
// ASM-LABEL: _D15attr_target_x867haswellFPfPffZv:
@(target("arch=haswell "))
void haswell(float *A, float* B, float K) {
for (int i = 0; i < 128; ++i)
A[i] *= B[i] + K;
// ASM: vaddps
}
// LLVM-DAG: attributes #[[SSE]] = {{.*}} "target-features"="+sse"
// LLVM-DAG: attributes #[[NOSSE]] = {{.*}} "target-features"="+sse,-sse"
// LLVM-DAG: attributes #[[HSW]] = {{.*}} "target-cpu"="haswell"
ldc-0.17.5-src/tests/ir/lit.site.cfg.in 0000644 0001750 0001750 00000004707 13200164641 017743 0 ustar matthias matthias import lit.formats
import os
import sys
import platform
## Auto-initialized variables by cmake:
config.ldc2_bin = "@LDC2_BIN@"
config.ldc2_bin_dir = "@LDC2_BIN_DIR@"
config.test_source_root = "@TESTS_IR_DIR@"
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
config.llvm_version = @LDC_LLVM_VER@
config.llvm_targetsstr = "@LLVM_TARGETS_TO_BUILD@"
config.name = 'LLVM IR codegen'
# testFormat: The test format to use to interpret tests.
config.test_format = lit.formats.ShTest(execute_external=False)
# suffixes: A list of file extensions to treat as test files. This is overriden
# by individual lit.local.cfg files in the test subdirectories.
config.suffixes = ['.d',
]
# excludes: A list of directories to exclude from the testsuite. The 'inputs'
# subdirectories contain auxiliary inputs for various tests in their parent
# directories.
config.excludes = ['inputs']
# Define available features so that we can disable tests depending on LLVM version
config.available_features.add("llvm%d" % config.llvm_version)
for version in range(305, config.llvm_version+1):
config.available_features.add("atleast_llvm%d" % version)
# Define OS as available feature (Windows, Darwin, Linux)
config.available_features.add(platform.system())
# Define available features based on what LLVM can target
# Examples: 'target_X86', 'target_ARM', 'target_PowerPC', 'target_AArch64'
for t in config.llvm_targetsstr.split(';'):
config.available_features.add('target_' + t)
config.target_triple = '(unused)'
# test_exec_root: The root path where tests should be run.
config.test_exec_root = os.path.dirname(__file__)
# add LDC bin dir to the path
path = os.path.pathsep.join( (config.ldc2_bin_dir, config.environment['PATH']) )
config.environment['PATH'] = path
# add LLVM tools bin dir to the path
path = os.path.pathsep.join( (config.llvm_tools_dir, config.environment['PATH']) )
config.environment['PATH'] = path
# add test root dir to the path (FileCheck might sit there)
path = os.path.pathsep.join( (config.test_source_root, config.environment['PATH']) )
config.environment['PATH'] = path
# Add substitutions
config.substitutions.append( ('%ldc', config.ldc2_bin) )
# Add platform-dependent file extension substitutions
if (platform.system() == 'Windows'):
config.substitutions.append( ('%obj', '.obj') )
config.substitutions.append( ('%exe', '.exe') )
else:
config.substitutions.append( ('%obj', '.o') )
config.substitutions.append( ('%exe', '') )
ldc-0.17.5-src/tests/ir/runlit.py 0000755 0001750 0001750 00000000723 13200164641 017006 0 ustar matthias matthias #!/usr/bin/env python
# wrapper to run lit from commandline
if __name__=='__main__':
try:
import lit
except ImportError:
import sys
sys.exit('Package lit cannot be imported.\n' \
'Lit can be installed using: \'python -m pip install lit\'\n' \
'(Python versions older than 2.7.9 or 3.4 do not have pip installed, see:\n' \
'https://pip.pypa.io/en/latest/installing/)')
lit.main()
ldc-0.17.5-src/tests/ir/CMakeLists.txt 0000644 0001750 0001750 00000000637 13200164641 017660 0 ustar matthias matthias set( LDC2_BIN ${PROJECT_BINARY_DIR}/bin/${LDC_EXE} )
set( LLVM_TOOLS_DIR ${LLVM_ROOT_DIR}/bin )
set( LDC2_BIN_DIR ${PROJECT_BINARY_DIR}/bin )
set( TESTS_IR_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
configure_file(lit.site.cfg.in lit.site.cfg )
configure_file(runlit.py runlit.py COPYONLY)
add_test(NAME llvm-ir-testsuite
COMMAND python runlit.py -v .
)
ldc-0.17.5-src/tests/ir/atomicrmw.d 0000644 0001750 0001750 00000001460 13200164641 017262 0 ustar matthias matthias // RUN: %ldc -c -de -output-ll -of=%t.ll %s && FileCheck %s < %t.ll
import core.atomic;
void main() {
shared ubyte x = 3;
ubyte r;
r = atomicOp!"+="(x, uint(257));
assert(x == r);
// CHECK: = atomicrmw add i8*
r = atomicOp!"+="(x, int(-263));
assert(x == r);
// CHECK: = atomicrmw add i8*
r = atomicOp!"-="(x, ushort(257));
assert(x == r);
// CHECK: = atomicrmw sub i8*
r = atomicOp!"-="(x, short(-263));
assert(x == r);
// CHECK: = atomicrmw sub i8*
r = atomicOp!"&="(x, ubyte(255));
assert(x == r);
// CHECK: = atomicrmw and i8*
r = atomicOp!"|="(x, short(3));
assert(x == r);
// CHECK: = atomicrmw or i8*
r = atomicOp!"^="(x, int(3));
assert(x == r);
// CHECK: = atomicrmw xor i8*
r = atomicOp!"+="(x, 1.0f);
assert(x == r);
// CHECK: = cmpxchg i8*
}
ldc-0.17.5-src/tests/ir/attr_weak.d 0000644 0001750 0001750 00000000612 13200164641 017237 0 ustar matthias matthias // Test linking+running a program with @weak functions
// RUN: %ldc -O3 %S/inputs/attr_weak_input.d -c -of=%t%obj
// RUN: %ldc -O3 %t%obj -run %s
import ldc.attributes;
extern(C) int return_two() {
return 2;
}
// Should be overridden by attr_weak_input.d
extern(C) @weak int return_seven() {
return 1;
}
void main() {
assert( return_two() == 2 );
assert( return_seven() == 7 );
}
ldc-0.17.5-src/tests/ir/attributes.d 0000644 0001750 0001750 00000001713 13200164641 017447 0 ustar matthias matthias // Tests LDC-specific attributes
// RUN: %ldc -O -c -output-ll -of=%t.ll %s && FileCheck %s < %t.ll
import ldc.attributes;
//---- @(section) -----------------------------------------------------
// CHECK-DAG: @{{.*}}mySectionedGlobali ={{.*}} section ".mySection"
@(section(".mySection")) int mySectionedGlobal;
// CHECK-DAG: define void @{{.*}}sectionedfoo{{.*}} section "funcSection"
@(section("funcSection")) void sectionedfoo() {}
//---------------------------------------------------------------------
//---------------------------------------------------------------------
//---- @(weak) --------------------------------------------------------
// CHECK-DAG: @{{.*}}myWeakGlobali = weak
@(ldc.attributes.weak) int myWeakGlobal;
// CHECK-DAG: define{{.*}} weak {{.*}}void @{{.*}}weakFunc
@weak void weakFunc() {}
//---------------------------------------------------------------------
// CHECK-LABEL: define i32 @_Dmain
void main() {
sectionedfoo();
}
ldc-0.17.5-src/tests/ir/inputs/ 0000755 0001750 0001750 00000000000 13200164641 016434 5 ustar matthias matthias ldc-0.17.5-src/tests/ir/inputs/attr_weak_input.d 0000644 0001750 0001750 00000000167 13200164641 022005 0 ustar matthias matthias import ldc.attributes;
extern(C) @weak int return_two() {
return 1;
}
extern(C) int return_seven() {
return 7;
}
ldc-0.17.5-src/tests/ir/asm_output.d 0000644 0001750 0001750 00000000473 13200164641 017463 0 ustar matthias matthias // RUN: %ldc -c -output-ll -of=%t.ll %s && FileCheck %s --check-prefix LLVM < %t.ll
// RUN: %ldc -c -output-s -of=%t.s %s && FileCheck %s --check-prefix ASM < %t.s
int main() {
return 42;
// Try to keep these very simple checks independent of architecture:
// LLVM: ret i32 42
// ASM: {{(\$|#|.long )}}42
}
ldc-0.17.5-src/tests/ir/align.d 0000644 0001750 0001750 00000004327 13200164641 016357 0 ustar matthias matthias // RUN: %ldc -c -output-ll -of=%t.ll %s && FileCheck %s < %t.ll
align(32) struct Outer { int a; }
struct Inner { align(32) int a; }
static Outer globalOuter;
// CHECK: constant %align.Outer_init zeroinitializer{{(, comdat)?}}, align 32
static Inner globalInner;
// CHECK: constant %align.Inner_init zeroinitializer{{(, comdat)?}}, align 32
Outer passAndReturnOuterByVal(Outer arg) { return arg; }
// CHECK: define void @_D5align23passAndReturnOuterByValFS5align5OuterZS5align5Outer
/* no sret align attributes for MSVC targets at the moment */
// C HECK-SAME: %align.Outer* noalias sret align 32 %.sret_arg
/* how the arg is passed by value is ABI-specific, but the pointer must be aligned */
// CHECK-SAME: align 32 %
Inner passAndReturnInnerByVal(Inner arg) { return arg; }
// CHECK: define void @_D5align23passAndReturnInnerByValFS5align5InnerZS5align5Inner
// C HECK-SAME: %align.Inner* noalias sret align 32 %.sret_arg
// CHECK-SAME: align 32 %
void main() {
Outer outer;
// CHECK: %outer = alloca %align.Outer, align 32
Inner inner;
// CHECK: %inner = alloca %align.Inner, align 32
align(16) byte byte16;
// CHECK: %byte16 = alloca i8, align 16
align(64) Outer outer64;
// CHECK: %outer64 = alloca %align.Outer, align 64
align(128) Inner inner128;
// CHECK: %inner128 = alloca %align.Inner, align 128
alias Byte8 = align(8) byte;
Byte8 byte8;
// Can aliases contain align(x) ?
// C HECK: %byte8 = alloca i8, align 8
// C HECK: %byte8 = alloca i8, align 1
align(16) Outer outeroverride;
// Yet undecided if align() should override type alignment:
// C HECK: %outeroverride = alloca %align.Outer, align 16
// C HECK: %outeroverride = alloca %align.Outer, align 32
// CHECK: %.rettmp = alloca %align.Outer, align 32
// CHECK: %.rettmp1 = alloca %align.Inner, align 32
outer = passAndReturnOuterByVal(outer);
// CHECK: call void @_D5align23passAndReturnOuterByValFS5align5OuterZS5align5Outer
// C HECK-SAME: %align.Outer* noalias sret align 32 %.rettmp
// CHECK-SAME: align 32 %
inner = passAndReturnInnerByVal(inner);
// CHECK: call void @_D5align23passAndReturnInnerByValFS5align5InnerZS5align5Inner
// C HECK-SAME: %align.Inner* noalias sret align 32 %.rettmp1
// CHECK-SAME: align 32 %
}
ldc-0.17.5-src/tests/d2/ 0000755 0001750 0001750 00000000000 13200164643 015007 5 ustar matthias matthias ldc-0.17.5-src/tests/d2/src/ 0000755 0001750 0001750 00000000000 13200164641 015574 5 ustar matthias matthias ldc-0.17.5-src/tests/d2/src/osmodel.mak 0000644 0001750 0001750 00000002101 13200164641 017722 0 ustar matthias matthias # This Makefile snippet detects the OS and the architecture MODEL
# Keep this file in sync between druntime, phobos, and dmd repositories!
ifeq (,$(OS))
uname_S:=$(shell uname -s)
ifeq (Darwin,$(uname_S))
OS:=osx
endif
ifeq (Linux,$(uname_S))
OS:=linux
endif
ifeq (FreeBSD,$(uname_S))
OS:=freebsd
endif
ifeq (OpenBSD,$(uname_S))
OS:=openbsd
endif
ifeq (Solaris,$(uname_S))
OS:=solaris
endif
ifeq (SunOS,$(uname_S))
OS:=solaris
endif
ifeq (,$(OS))
$(error Unrecognized or unsupported OS for uname: $(uname_S))
endif
endif
# When running make from XCode it may set environment var OS=MACOS.
# Adjust it here:
ifeq (MACOS,$(OS))
OS:=osx
endif
ifeq (,$(MODEL))
ifeq ($(OS), solaris)
uname_M:=$(shell isainfo -n)
else
uname_M:=$(shell uname -m)
endif
ifneq (,$(findstring $(uname_M),x86_64 amd64))
MODEL:=64
endif
ifneq (,$(findstring $(uname_M),i386 i586 i686))
MODEL:=32
endif
ifeq (,$(MODEL))
$(error Cannot figure 32/64 model from uname -m: $(uname_M))
endif
endif
MODEL_FLAG:=-m$(MODEL)
ldc-0.17.5-src/tests/d2/dmd-testsuite/ 0000755 0001750 0001750 00000000000 13200164643 017602 5 ustar matthias matthias ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ 0000755 0001750 0001750 00000000000 13200164642 021710 5 ustar matthias matthias ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test12567b.d 0000644 0001750 0001750 00000000167 13200164641 023606 0 ustar matthias matthias // REQUIRED_ARGS:
// PERMUTE_ARGS:
/*
TEST_OUTPUT:
---
---
*/
deprecated("message")
module test12567b;
void main() {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test62.d 0000644 0001750 0001750 00000000111 13200164641 023174 0 ustar matthias matthias // PERMUTE_ARGS:
import imports.test62a;
struct S { }
void main() { }
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice13071.d 0000644 0001750 0001750 00000000211 13200164641 023202 0 ustar matthias matthias // REQUIRED_ARGS: -o-
// PERMUTE_ARGS:
T foo(T)()
{
__gshared int[] bar = [];
return T.init;
}
void main()
{
foo!char();
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/protattr.d 0000644 0001750 0001750 00000000207 13200164641 023732 0 ustar matthias matthias // REQUIRED_ARGS: -o-
// PERMUTE_ARGS:
import protection.basic.tests;
import protection.subpkg.tests;
import protection.subpkg2.tests;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testheader2.d 0000644 0001750 0001750 00000000316 13200164641 024266 0 ustar matthias matthias // EXTRA_SOURCES: extra-files/header2.d
// REQUIRED_ARGS: -o- -H -Hf${RESULTS_DIR}/compilable/header2.di
// PERMUTE_ARGS:
// POST_SCRIPT: compilable/extra-files/header-postscript.sh header2
void main() {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test10073.d 0000644 0001750 0001750 00000000466 13200164641 023434 0 ustar matthias matthias struct Arr(T)
{
T[] dArr;
alias dArr this;
bool opEquals(Arr!T d)
{
foreach (idx, it; d)
{
if (this[idx] != it)
{
return false;
}
}
return true;
}
}
class Bar
{
Arr!Foo fooQ;
}
class Foo {} // NG
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice11054.d 0000644 0001750 0001750 00000000164 13200164641 023210 0 ustar matthias matthias import imports.ice11054a;
static assert(!__traits(compiles, tuple()));
E[] appender(A : E, E)()
{
return E;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/compile1.d 0000644 0001750 0001750 00000047040 13200164641 023572 0 ustar matthias matthias // PERMUTE_ARGS:
/**************************************************
1748 class template with stringof
**************************************************/
struct S1748(T) {}
static assert(S1748!int.stringof == "S1748!int");
class C1748(T) {}
static assert(C1748!int.stringof == "C1748!int");
/**************************************************
2438
**************************************************/
alias void delegate() Dg2438;
alias typeof(Dg2438.ptr) CP2438a;
alias typeof(Dg2438.funcptr) FP2438a;
static assert(is(CP2438a == void*));
static assert(is(FP2438a == void function()));
alias typeof(Dg2438.init.ptr) CP2438b;
alias typeof(Dg2438.init.funcptr) FP2438b;
static assert(is(CP2438b == void*));
static assert(is(FP2438b == void function()));
/**************************************************
4225
**************************************************/
struct Foo4225
{
enum x = Foo4225();
static Foo4225 opCall()
{
return Foo4225.init;
}
}
/**************************************************
5996 ICE(expression.c)
**************************************************/
template T5996(T)
{
auto bug5996() {
if (anyOldGarbage) {}
return 2;
}
}
static assert(!is(typeof(T5996!(int).bug5996())));
/**************************************************
8532 segfault(mtype.c) - type inference + pure
**************************************************/
auto segfault8532(Y, R ...)(R r, Y val) pure
{ return segfault8532(r, val); }
static assert(!is(typeof( segfault8532(1,2,3))));
/**************************************************
8982 ICE(ctfeexpr.c) __parameters with error in default value
**************************************************/
template ice8982(T)
{
void bug8982(ref const int v = 7){}
static if (is(typeof(bug8982) P == __parameters)) {
pragma(msg, ((P[0..1] g) => g[0])());
}
}
static assert(!is(ice8982!(int)));
/**************************************************
8801 ICE assigning to __ctfe
**************************************************/
static assert(!is(typeof( { bool __ctfe= true; })));
static assert(!is(typeof( { __ctfe |= true; })));
/**************************************************
5932 ICE(s2ir.c)
6675 ICE(glue.c)
**************************************************/
void bug3932(T)() {
static assert( 0 );
func5932( 7 );
}
void func5932(T)( T val ) {
void onStandardMsg() {
foreach( t; T ) { }
}
}
static assert(!is(typeof(
{
bug3932!(int)();
}()
)));
/**************************************************
6650 ICE(glue.c) or wrong-code
**************************************************/
auto bug6650(X)(X y)
{
X q;
q = "abc";
return y;
}
static assert(!is(typeof(bug6650!(int)(6))));
static assert(!is(typeof(bug6650!(int)(18))));
/**************************************************
6661 Templates instantiated only through is(typeof()) shouldn't cause errors
**************************************************/
template bug6661(Q)
{
int qutz(Q y)
{
Q q = "abc";
return 67;
}
static assert(qutz(13).sizeof!=299);
const Q blaz = 6;
}
static assert(!is(typeof(bug6661!(int).blaz)));
template bug6661x(Q)
{
int qutz(Q y)
{
Q q = "abc";
return 67;
}
}
// should pass, but doesn't in current
//static assert(!is(typeof(bug6661x!(int))));
/**************************************************
6599 ICE(constfold.c) or segfault
**************************************************/
string bug6599extraTest(string x) { return x ~ "abc"; }
template Bug6599(X)
{
class Orbit
{
Repository repository = Repository();
}
struct Repository
{
string fileProtocol = "file://";
string blah = bug6599extraTest("abc");
string source = fileProtocol ~ "/usr/local/orbit/repository";
}
}
static assert(!is(typeof(Bug6599!int)));
/**************************************************
8422 TypeTuple of tuples can't be read at compile time
**************************************************/
template TypeTuple8422(TList...)
{
alias TList TypeTuple8422;
}
struct S8422 { int x; }
void test8422()
{
enum a = S8422(1);
enum b = S8422(2);
enum c = [1,2,3];
foreach(t; TypeTuple8422!(b, a)) {
enum u = t;
}
foreach(t; TypeTuple8422!(c)) {
enum v = t;
}
}
/**************************************************
6096 ICE(el.c) with -O
**************************************************/
cdouble c6096;
int bug6096()
{
if (c6096) return 0;
return 1;
}
/**************************************************
7681 Segfault
**************************************************/
static assert( !is(typeof( (){
undefined ~= delegate(){}; return 7;
}())));
/**************************************************
8639 Buffer overflow
**************************************************/
void t8639(alias a)() {}
void bug8639() {
t8639!({auto r = -real.max;})();
}
/**************************************************
7751 Segfault
**************************************************/
static assert( !is(typeof( (){
bar[]r; r ~= [];
return 7;
}())));
/**************************************************
7639 Segfault
**************************************************/
static assert( !is(typeof( (){
enum foo =
[
str : "functions",
];
})));
/**************************************************
11991
**************************************************/
void main()
{
int Throwable;
int object;
try
{
}
catch
{
}
}
/**************************************************
11939
**************************************************/
void test11939()
{
scope(failure)
{
import object : Object;
}
throw new Exception("");
}
/**************************************************
5796
**************************************************/
template A(B) {
pragma(msg, "missing ;")
enum X = 0;
}
static assert(!is(typeof(A!(int))));
/**************************************************
6720
**************************************************/
void bug6720() { }
static assert(!is(typeof(
cast(bool)bug6720()
)));
/**************************************************
1099
**************************************************/
template Mix1099(int a) {
alias typeof(this) ThisType;
static assert (ThisType.init.tupleof.length == 2);
}
struct Foo1099 {
mixin Mix1099!(0);
int foo;
mixin Mix1099!(1);
int bar;
mixin Mix1099!(2);
}
/**************************************************
8788 - super() and return
**************************************************/
class B8788 {
this ( ) { }
}
class C8788(int test) : B8788
{
this ( int y )
{ // TESTS WHICH SHOULD PASS
static if (test == 1) {
if (y == 3) {
super();
return;
}
super();
return;
} else static if (test == 2) {
if (y == 3) {
super();
return;
}
super();
} else static if (test == 3) {
if (y > 3) {
if (y == 7) {
super();
return;
}
super();
return;
}
super();
} else static if (test == 4) {
if (y > 3) {
if (y == 7) {
super();
return;
}
else if (y> 5)
super();
else super();
return;
}
super();
}
// TESTS WHICH SHOULD FAIL
else static if (test == 5) {
if (y == 3) {
super();
return;
}
return; // no super
} else static if (test == 6) {
if (y > 3) {
if (y == 7) {
super();
return;
}
super();
}
super(); // two calls
} else static if (test == 7) {
if (y == 3) {
return; // no super
}
super();
} else static if (test == 8) {
if (y > 3) {
if (y == 7) {
return; // no super
}
super();
return;
}
super();
} else static if (test == 9) {
if (y > 3) {
if (y == 7) {
super();
return;
}
else if (y> 5)
super();
else return; // no super
return;
}
super();
}
}
}
static assert( is(typeof( { new C8788!(1)(0); } )));
static assert( is(typeof( { new C8788!(2)(0); } )));
static assert( is(typeof( { new C8788!(3)(0); } )));
static assert( is(typeof( { new C8788!(4)(0); } )));
static assert(!is(typeof( { new C8788!(5)(0); } )));
static assert(!is(typeof( { new C8788!(6)(0); } )));
static assert(!is(typeof( { new C8788!(7)(0); } )));
static assert(!is(typeof( { new C8788!(8)(0); } )));
static assert(!is(typeof( { new C8788!(9)(0); } )));
/**************************************************
4967, 7058
**************************************************/
enum Bug7058 bug7058 = { 1.5f, 2};
static assert(bug7058.z == 99);
struct Bug7058
{
float x = 0;
float y = 0;
float z = 99;
}
/***************************************************/
void test12094()
{
auto n = null;
int *a;
int[int] b;
int[] c;
auto u = true ? null : a;
auto v = true ? null : b;
auto w = true ? null : c;
auto x = true ? n : a;
auto y = true ? n : b;
auto z = true ? n : c;
a = n;
b = n;
c = n;
}
/***************************************************/
template test8163(T...)
{
struct Point
{
T fields;
}
enum N = 2; // N>=2 triggers the bug
extern Point[N] bar();
void foo()
{
Point[N] _ = bar();
}
}
alias test8163!(long) _l;
alias test8163!(double) _d;
alias test8163!(float, float) _ff;
alias test8163!(int, int) _ii;
alias test8163!(int, float) _if;
alias test8163!(ushort, ushort, ushort, ushort) _SSSS;
alias test8163!(ubyte, ubyte, ubyte, ubyte, ubyte, ubyte, ubyte, ubyte) _BBBBBBBB;
alias test8163!(ubyte, ubyte, ushort, float) _BBSf;
/***************************************************/
// 4757
auto foo4757(T)(T)
{
static struct Bar(T)
{
void spam()
{
foo4757(1);
}
}
return Bar!T();
}
void test4757()
{
foo4757(1);
}
/***************************************************/
// 9348
void test9348()
{
@property Object F(int E)() { return null; }
assert(F!0 !is null);
assert(F!0 !in [new Object():1]);
}
/***************************************************/
// 9690
@disable
{
void dep9690() {}
void test9690()
{
dep9690(); // OK
void inner()
{
dep9690(); // OK <- NG
}
}
}
/+ LDC_FIXME: See discussion at D-Programming-Language/dmd#2175.
/***************************************************/
// 9987
static if (is(object.ModuleInfo == struct))
{
struct ModuleInfo {}
static assert(!is(object.ModuleInfo == ModuleInfo));
static assert(object.ModuleInfo.sizeof != ModuleInfo.sizeof);
}
static if (is(object.ModuleInfo == class))
{
class ModuleInfo {}
static assert(!is(object.ModuleInfo == ModuleInfo));
static assert(__traits(classInstanceSize, object.ModuleInfo) !=
__traits(classInstanceSize, ModuleInfo));
}
+/
/***************************************************/
// 10158
class Outer10158
{
static struct Inner
{
int f;
}
void test()
{
static assert( Inner.f .offsetof == 0); // OK <- NG
static assert((Inner.f).offsetof == 0); // OK
}
}
void test10158()
{
static assert(Outer10158.Inner.f.offsetof == 0); // OK
}
/***************************************************/
// 10326
class C10326
{
int val;
invariant { assert(val == 0); }
invariant() { assert(val == 0); }
}
/***************************************************/
// 11042
static if ((true || error) == true ) {} else { static assert(0); }
static if ((false && error) == false) {} else { static assert(0); }
static assert ((true || error) == true );
static assert ((false && error) == false);
int f11042a1()() if ((true || error) == true ) { return 0; } enum x11042a1 = f11042a1();
int f11042b1()() if ((false && error) == false) { return 0; } enum x11042b1 = f11042b1();
static if (is(typeof(true || error)) == false) {} else { static assert(0); }
static if (is(typeof(false && error)) == false) {} else { static assert(0); }
static assert (is(typeof(true || error)) == false);
static assert (is(typeof(false && error)) == false);
int f11042a2()() if (is(typeof(true || error)) == false) { return 0; } enum x11042a2 = f11042a2();
int f11042b2()() if (is(typeof(false && error)) == false) { return 0; } enum x11042b2 = f11042b2();
static if (__traits(compiles, true || error) == false) {} else { static assert(0); }
static if (__traits(compiles, false && error) == false) {} else { static assert(0); }
static assert (__traits(compiles, true || error) == false);
static assert (__traits(compiles, false && error) == false);
int f11042a3()() if (__traits(compiles, true || error) == false) { return 0; } enum x11042a3 = f11042a3();
int f11042b3()() if (__traits(compiles, false && error) == false) { return 0; } enum x11042b3 = f11042b3();
/***************************************************/
// 11554
enum E11554;
static assert(is(E11554 == enum));
struct Bro11554(N...) {}
static assert(!is(E11554 unused : Bro11554!M, M...));
/***************************************************/
// 12302
template isCallable12302(T...)
if (T.length == 1)
{
static if (is(typeof(& T[0].opCall) == delegate))
enum bool isCallable12302 = true;
else
static if (is(typeof(& T[0].opCall) V : V*) && is(V == function))
enum bool isCallable12302 = true;
else
enum bool isCallable12302 = true;
}
class A12302
{
struct X {}
X x;
auto opDispatch(string s, TArgs...)(TArgs args)
{
mixin("return x."~s~"(args);");
}
}
A12302 func12302() { return null; }
enum b12302 = isCallable12302!func12302;
/***************************************************/
// 12476
template A12476(T) { }
struct S12476(T)
{
alias B = A12476!T;
}
class C12476(T)
{
alias B = A12476!T;
}
struct Bar12476(alias Foo)
{
Foo!int baz;
alias baz this;
}
alias Identity12476(alias A) = A;
alias sb12476 = Identity12476!(Bar12476!S12476.B);
alias cb12476 = Identity12476!(Bar12476!C12476.B);
static assert(__traits(isSame, sb12476, A12476!int));
static assert(__traits(isSame, cb12476, A12476!int));
/***************************************************/
// 12506
import imports.a12506;
private bool[9] r12506a = f12506!(i => true)(); // OK
private immutable bool[9] r12506b = f12506!(i => true)(); // OK <- error
/***************************************************/
// 12555
class A12555(T)
{
Undef12555 error;
}
static assert(!__traits(compiles, {
class C : A12555!C { }
}));
/***************************************************/
// 11622
class A11622(T)
{
B11622!T foo()
{
return new B11622!T;
}
}
class B11622(T) : T
{
}
static assert(!__traits(compiles, {
class C : A11622!C { }
}));
/***************************************************/
// 12688
void writeln12688(A...)(A) {}
struct S12688
{
int foo() @property { return 1; }
}
void test12688()
{
S12688 s;
s.foo.writeln12688; // ok
(s.foo).writeln12688; // ok <- ng
}
/***************************************************/
// 12703
struct S12703
{
this(int) {}
}
final class C12703
{
S12703 s = S12703(1);
}
/***************************************************/
// 12799
struct A12799
{
int a;
enum C = A12799.sizeof;
enum D = C; // OK <- Error
}
/***************************************************/
// 13236
pragma(msg, is(typeof({ struct S { S x; } })));
/***************************************************/
// 13280
struct S13280
{
alias U = ubyte;
alias T1 = ubyte[this.sizeof]; // ok
alias T2 = const U[this.sizeof]; // ok
alias T3 = const ubyte[this.sizeof]; // ok <- error
}
/***************************************************/
// 13481
mixin template Mix13481(void function() callback)
{
static this()
{
callback();
}
}
void sort13481() { int[] arr; arr.sort; }
mixin Mix13481!(&sort13481);
mixin Mix13481!({ int[] arr; arr.sort; });
/***************************************************/
// 13564
class E13564(T)
{
int pos;
}
class C13564(T)
{
struct S
{
~this()
{
C13564!int c;
c.element.pos = 0;
}
}
E13564!T element;
}
void test13564()
{
auto c = new C13564!int();
}
/***************************************************/
// 14166
struct Proxy14166(T)
{
T* ptr;
ref deref() { return *ptr; }
alias deref this;
}
struct Test14166
{
auto opIndex() { return this; }
auto opIndex(int) { return 1; }
}
template Elem14166a(R) { alias Elem14166a = typeof(R.init[][0]); }
template Elem14166b(R) { alias Elem14166b = typeof(R.init[0]); }
void test14166()
{
alias T = Proxy14166!Test14166;
static assert(is(Elem14166a!T == int)); // rejects-valid case
static assert(is(Elem14166b!T == int)); // regression case
}
// other related cases
struct S14166
{
int x;
double y;
int[] a;
S14166 opUnary(string op : "++")() { return this; }
}
S14166 s14166;
struct X14166 { this(int) { } X14166 opAssign(int) { return this; } }
X14166[int] aa14166;
X14166[int] makeAA14166() { return aa14166; }
struct Tup14166(T...) { T field; alias field this; }
Tup14166!(int, int) tup14166;
Tup14166!(int, int) makeTup14166() { return tup14166; }
pragma(msg, typeof((s14166.x += 1) = 2)); // ok <- error
pragma(msg, typeof(s14166.a.length += 2)); // ok <- error
pragma(msg, typeof(s14166++)); // ok <- error
pragma(msg, typeof(s14166.x ^^ 2)); // ok <- error
pragma(msg, typeof(s14166.y ^^= 2.5)); // ok <- error
pragma(msg, typeof(makeAA14166()[0] = 1)); // ok <- error
pragma(msg, typeof(tup14166.field = makeTup14166())); // ok <- error
/***************************************************/
// 14388
@property immutable(T)[] idup14388(T)(T[] a)
{
alias U = immutable(T);
U[] res;
foreach (ref e; a)
res ~= e;
return res;
}
struct Data14388(A14388 a)
{
auto foo()
{
return Data14388!a.init; // [B]
}
}
struct A14388
{
struct Item {}
immutable(Item)[] items;
this(int dummy)
{
items = [Item()].idup14388;
}
}
void test14388()
{
auto test = Data14388!(A14388(42)).init.foo(); // [A]
/*
* A(42) is interpreter to a struct literal A([immutable(Item)()]).
* The internal VarDeclaration with STCmanifest for the Data's template parameteter 'a'
* calls syntaxCopy() on its ((ExpInitializer *)init)->exp in VarDeclaration::semantic(),
* and 'immutable(Item)()'->syntaxCopy() had incorrectly removed the qualifier.
* Then, the arguments of two Data template instances at [A] and [B] had become unmatch,
* and the second instantiation had created the AST duplication.
*/
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test11563.d 0000644 0001750 0001750 00000000234 13200164641 023432 0 ustar matthias matthias import imports.test11563std_traits;
interface J : I {} // comment out to let compilation succeed
struct A { }
pragma(msg, moduleName!A);
interface I {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test8038.d 0000644 0001750 0001750 00000000164 13200164641 023357 0 ustar matthias matthias template t(T){alias T t;}
t!(#line 10
t!(
int,
)
) i;
t!(
t!(#line 10
int,
)
) j;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/vgc3.d 0000644 0001750 0001750 00000002227 13200164641 022721 0 ustar matthias matthias // REQUIRED_ARGS: -vgc -o-
// PERMUTE_ARGS:
/***************** AssignExp *******************/
/*
TEST_OUTPUT:
---
compilable/vgc3.d(16): vgc: setting 'length' may cause GC allocation
compilable/vgc3.d(17): vgc: setting 'length' may cause GC allocation
compilable/vgc3.d(18): vgc: setting 'length' may cause GC allocation
---
*/
void testArrayLength(int[] a)
{
a.length = 3;
a.length += 1;
a.length -= 1;
}
/***************** CallExp *******************/
void barCall();
/*
TEST_OUTPUT:
---
---
*/
void testCall()
{
auto fp = &barCall;
(*fp)();
barCall();
}
/****************** Closure ***********************/
@nogc void takeDelegate2(scope int delegate() dg) {}
@nogc void takeDelegate3( int delegate() dg) {}
/*
TEST_OUTPUT:
---
compilable/vgc3.d(51): vgc: using closure causes GC allocation
compilable/vgc3.d(63): vgc: using closure causes GC allocation
---
*/
auto testClosure1()
{
int x;
int bar() { return x; }
return &bar;
}
void testClosure2()
{
int x;
int bar() { return x; }
takeDelegate2(&bar); // no error
}
void testClosure3()
{
int x;
int bar() { return x; }
takeDelegate3(&bar);
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test12567d.d 0000644 0001750 0001750 00000000160 13200164641 023601 0 ustar matthias matthias // REQUIRED_ARGS: -d
// PERMUTE_ARGS:
/*
TEST_OUTPUT:
---
---
*/
import imports.a12567;
void main() { foo(); }
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test9278b.d 0000644 0001750 0001750 00000000332 13200164641 023525 0 ustar matthias matthias // PREMUTE_ARGS:
// Works fine here
//struct datum { float num = 0.0; }
datum emitOne()
{
datum t;
return t;
}
const dataArr = [emitOne()];
// A very bad day
struct datum { float num = 0.0; }
void main(){}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test3673.d 0000644 0001750 0001750 00000001437 13200164641 023363 0 ustar matthias matthias class Base {}
class Foo(T)
if (is(T == int)) : Base { }
class Bar(T) : Base
if (is(T == bool))
{ }
interface OutputRange(T...)
if (T.length == 1)
{
void put(T[0] value);
}
interface OutputRange(T...) : OutputRange!(T[0]), OutputRange!(T[1 .. $])
if (T.length > 1)
{
}
alias OutputRange!(int, float) OR;
class COR : OR
{
void put(int) { }
void put(float) { }
}
class A {};
class B(T) : A if (true) {}
class C(T) if (false) : A {}
alias Foo!int FooInt;
alias Bar!bool BarBool;
static assert(!__traits(compiles, Foo!bool));
static assert(!__traits(compiles, Bar!int));
void main()
{
auto fi = new FooInt;
auto bb = new BarBool;
auto cor = new COR;
auto a = new A();
auto b = new B!int();
static assert(!__traits(compiles, new C!int()));
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc2.d 0000644 0001750 0001750 00000001377 13200164641 023057 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 2
/**
* Summary
*
* Description1
*
* Description2
*
* Description3
*
* Macros:
* WIKI = StdStream
* meemie
* See_Also:
* Things to see also.
*
* And more things.
*/
/*
*/
module std.test;
/// A base class for stream exceptions.
class StreamException: Exception {
/** Construct a StreamException with given error message msg.
* Params:
* msg = the $(RED red) $(BLUE blue) $(GREEN green) $(YELLOW yellow).
* foo = next parameter which is a much longer
* message spanning multiple
* lines.
*/
this(string msg, int foo) { super(msg); }
/********** stars ***************/
int stars;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test66.d 0000644 0001750 0001750 00000000245 13200164641 023210 0 ustar matthias matthias // PERMUTE_ARGS:
import imports.test66a;
alias int TOK;
enum
{
TOKmax
};
struct Token
{
static char[] tochars[TOKmax];
}
class Lexer
{
Token token;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/protection/ 0000755 0001750 0001750 00000000000 13156012230 024071 5 ustar matthias matthias ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/protection/subpkg2/ 0000755 0001750 0001750 00000000000 13200164641 025452 5 ustar matthias matthias ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/protection/subpkg2/tests.d 0000644 0001750 0001750 00000000201 13200164641 026752 0 ustar matthias matthias module protection.subpkg2.tests;
import pkg = protection.subpkg.explicit;
static assert (is(typeof(pkg.commonAncestorFoo())));
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/protection/basic/ 0000755 0001750 0001750 00000000000 13200164641 025156 5 ustar matthias matthias ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/protection/basic/tests.d 0000644 0001750 0001750 00000001252 13200164641 026465 0 ustar matthias matthias module protection.basic.tests;
import protection.basic.mod1;
static assert ( is(typeof(publicFoo())));
static assert ( is(typeof(packageFoo())));
static assert (!is(typeof(privateFoo())));
static assert ( is(typeof(Test.init.publicFoo())));
static assert (!is(typeof(Test.init.protectedFoo())));
static assert ( is(typeof(Test.init.packageFoo())));
static assert (!is(typeof(Test.init.privateFoo())));
class Deriv : Test
{
void stub()
{
static assert ( is(typeof(this.publicFoo())));
static assert ( is(typeof(this.protectedFoo())));
static assert ( is(typeof(this.packageFoo())));
static assert (!is(typeof(this.privateFoo())));
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/protection/basic/mod1.d 0000644 0001750 0001750 00000000402 13200164641 026157 0 ustar matthias matthias module protection.basic.mod1;
public void publicFoo() {}
package void packageFoo() {}
private void privateFoo() {}
class Test
{
public void publicFoo();
protected void protectedFoo();
package void packageFoo();
private void privateFoo();
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/protection/subpkg/ 0000755 0001750 0001750 00000000000 13200164641 025370 5 ustar matthias matthias ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/protection/subpkg/explicit.d 0000644 0001750 0001750 00000000200 13200164641 027346 0 ustar matthias matthias module protection.subpkg.explicit;
package(protection) void commonAncestorFoo();
package(protection.subpkg) void samePkgFoo();
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/protection/subpkg/tests.d 0000644 0001750 0001750 00000000602 13200164641 026675 0 ustar matthias matthias module protection.subpkg.tests;
import crosspkg = protection.basic.mod1;
static assert ( is(typeof(crosspkg.publicFoo())));
static assert (!is(typeof(crosspkg.packageFoo())));
static assert (!is(typeof(crosspkg.privateFoo())));
import samepkg = protection.subpkg.explicit;
static assert ( is(typeof(samepkg.commonAncestorFoo())));
static assert ( is(typeof(samepkg.samePkgFoo())));
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/protection/bug/ 0000755 0001750 0001750 00000000000 13200164641 024652 5 ustar matthias matthias ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/protection/bug/bug14275.d 0000644 0001750 0001750 00000000331 13200164641 026174 0 ustar matthias matthias module protection.bug.bug14275;
import protection.aggregate.mod14275;
// https://issues.dlang.org/show_bug.cgi?id=14275
void main() {
Foo f;
f.foo();
static assert (!is(typeof(f.foo2())));
bar();
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/protection/aggregate/ 0000755 0001750 0001750 00000000000 13200164641 026023 5 ustar matthias matthias ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/protection/aggregate/mod14275.d 0000644 0001750 0001750 00000000242 13200164641 027350 0 ustar matthias matthias module protection.aggregate.mod14275;
public struct Foo
{
package(protection) void foo() {}
package void foo2() {}
}
package(protection) void bar()
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test9436.d 0000644 0001750 0001750 00000000144 13200164641 023360 0 ustar matthias matthias // REQUIRED_ARGS: -c compilable/imports/test9436interp.d
// this is a dummy module for test 9436.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ldc_github_355.d 0000644 0001750 0001750 00000000254 13200164641 024555 0 ustar matthias matthias struct S { uint x; }
template MakeS(uint x) { const MakeS = S(x); }
struct S2 { alias .MakeS MakeS; }
void f() {
S2 s2;
auto n = s2.MakeS!(0); //////////// XXX
} ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test8543.d 0000644 0001750 0001750 00000001326 13200164641 023361 0 ustar matthias matthias
version (D_SIMD)
{
struct vfloat
{
public:
__vector(float[4]) f32;
this(float X) nothrow
{
f32.ptr[0] = X;
f32.ptr[1] = X;
f32.ptr[2] = X;
f32.ptr[3] = X;
}
this(float X, float Y, float Z, float W) nothrow
{
f32.array[0] = X;
f32.array[1] = Y;
f32.array[2] = Z;
f32.array[3] = W;
}
this(float[4] values) nothrow
{
f32.array = values;
}
}
immutable GvfGlobal_ThreeA = vfloat(3.0f);
immutable GvfGlobal_ThreeB = vfloat(3.0f, 3.0f, 3.0f, 3.0f);
immutable GvfGlobal_ThreeC = vfloat([3.0f, 3.0f, 3.0f, 3.0f]);
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice11596.d 0000644 0001750 0001750 00000000422 13200164641 023220 0 ustar matthias matthias // PERMUTE_ARGS: -inline -release -g -O -version=X
version(X)
alias M = real;
else
alias M = int[2]; /* or other T[n] with n != 1 */
struct S { M m; }
S f() { assert(false); }
class C
{
S[1] ss; /* Here, size doesn't matter. */
this() { ss[] = f(); }
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice12956.d 0000644 0001750 0001750 00000001155 13200164641 023225 0 ustar matthias matthias // REQUIRED_ARGS: -o-
// PERMUTE_ARGS:
template isCallable(T...)
{
static if (is(typeof(& T[0].opCall) == delegate))
{
enum bool isCallable = true;
}
else static if (is(typeof(& T[0].opCall) V : V*) && is(V == function))
{
enum bool isCallable = true;
}
else
enum bool isCallable = false;
}
@property auto injectChain(Injectors...)()
{
return &ChainTemplates!(Injectors);
}
template ChainTemplates(Templates...)
{
alias Head = Templates[0];
alias Tail = Templates[1..$];
alias Head!(Tail) ChainTemplates;
}
static assert(!isCallable!(injectChain));
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test50.d 0000644 0001750 0001750 00000000215 13200164641 023176 0 ustar matthias matthias // EXTRA_SOURCES: imports/test50a.d
// PERMUTE_ARGS:
import imports.test50a;
class Bar : Foo {
alias typeof(Foo.tupleof) Bleh;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test11980.d 0000644 0001750 0001750 00000000055 13200164641 023436 0 ustar matthias matthias void start() {}
pragma(startaddress, start);
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddocbackticks.d 0000644 0001750 0001750 00000001417 13200164641 024647 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh backticks
/++
Closely related to std.datetime is `core.time`,
and some of the time types used in std.datetime come from there - such as
$(CXREF time, Duration), $(CXREF time, TickDuration), and
$(CXREF time, FracSec).
core.time is publically imported into std.datetime, it isn't necessary
to import it separately.
+/
module ddocbackticks;
/// This should produce `inline code`.
void test() {}
/// But `this should NOT be inline'
///
/// However, restarting on a new line should be `inline again`.
void test2() {}
/// This `int foo;` should show highlight on foo, but not int.
void foo() {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc10236.d 0000644 0001750 0001750 00000002320 13200164641 023356 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -w -o-
/*
TEST_OUTPUT:
---
compilable/ddoc10236.d(33): Warning: Ddoc: parameter count mismatch
compilable/ddoc10236.d(45): Warning: Ddoc: function declaration has no parameter 'y'
compilable/ddoc10236.d(57): Warning: Ddoc: function declaration has no parameter 'y'
compilable/ddoc10236.d(57): Warning: Ddoc: parameter count mismatch
---
*/
/***********************************
* foo_good does this.
* Params:
* x = is for this
* and not for that
* y = is for that
*/
void foo_good(int x, int y)
{
}
/***********************************
* foo_count_mismatch does this.
* Params:
* x = is for this
* and not for that
*/
void foo_count_mismatch(int x, int y) // Warning: Ddoc: parameter count mismatch
{
}
/***********************************
* foo_no_param_y does this.
* Params:
* x = is for this
* and not for that
* y = is for that
*/
void foo_no_param_y(int x, int z) // Warning: Ddoc: function declaration has no parameter 'y'
{
}
/***********************************
* foo_count_mismatch_no_param_y does this.
* Params:
* x = is for this
* and not for that
* y = is for that
*/
void foo_count_mismatch_no_param_y(int x)
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/diag10768.d 0000644 0001750 0001750 00000001173 13200164641 023370 0 ustar matthias matthias // PERMUTE_ARGS:
/*
TEST_OUTPUT:
---
compilable/diag10768.d(36): Deprecation: implicitly overriding base class method diag10768.Frop.frop with diag10768.Foo.frop deprecated; add 'override' attribute
---
*/
struct CirBuff(T)
{
import std.traits: isArray;
CirBuff!T opAssign(R)(R) if (isArray!R)
{}
T[] toArray()
{
T[] ret; // = new T[this.length];
return ret;
}
alias toArray this;
}
class Bar(T=int)
{
CirBuff!T _bar;
}
class Once
{
Bar!Foo _foobar;
}
class Foo : Frop
{
// override
public int frop() { return 1; }
}
class Frop
{
public int frop() { return 0; }
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test4090.d 0000644 0001750 0001750 00000024537 13200164641 023363 0 ustar matthias matthias void test4090a()
{
// for the mutable elements
{
int[] arr = [1,2,3];
// inference + qualifier
foreach ( x; arr) static assert(is(typeof(x) == int));
foreach ( const x; arr) static assert(is(typeof(x) == const int));
foreach (immutable x; arr) static assert(is(typeof(x) == immutable int));
// inference + qualifier + ref
foreach ( ref x; arr) static assert(is(typeof(x) == int));
foreach ( const ref x; arr) static assert(is(typeof(x) == const int));
static assert(!__traits(compiles, {
foreach (immutable ref x; arr) {}
}));
// with exact type + qualifier
foreach ( int x; arr) static assert(is(typeof(x) == int));
foreach ( const int x; arr) static assert(is(typeof(x) == const int));
foreach (immutable int x; arr) static assert(is(typeof(x) == immutable int));
// with exact type + qualifier + ref
foreach ( ref int x; arr) static assert(is(typeof(x) == int));
foreach ( const ref int x; arr) static assert(is(typeof(x) == const int));
static assert(!__traits(compiles, {
foreach (immutable ref int x; arr) {}
}));
// convertible type + qualifier
foreach ( double x; arr) static assert(is(typeof(x) == double));
foreach ( const double x; arr) static assert(is(typeof(x) == const double));
foreach (immutable double x; arr) static assert(is(typeof(x) == immutable double));
// convertible type + qualifier + ref
static assert(!__traits(compiles, {
foreach ( ref double x; arr) {}
}));
static assert(!__traits(compiles, {
foreach ( const ref double x; arr) {}
}));
static assert(!__traits(compiles, {
foreach (immutable ref double x; arr) {}
}));
}
// for the immutable elements
{
immutable(int)[] iarr = [1,2,3];
// inference + qualifier
foreach ( x; iarr) static assert(is(typeof(x) == immutable int)); // same as variable declaration
foreach ( const x; iarr) static assert(is(typeof(x) == immutable int)); // same as variable declaration
foreach (immutable x; iarr) static assert(is(typeof(x) == immutable int));
// inference + qualifier + ref
foreach ( ref x; iarr) static assert(is(typeof(x) == immutable int)); // same as variable declaration
foreach ( const ref x; iarr) static assert(is(typeof(x) == immutable int)); // same as variable declaration
foreach (immutable ref x; iarr) static assert(is(typeof(x) == immutable int));
// with exact type + qualifier
foreach ( int x; iarr) static assert(is(typeof(x) == int));
foreach ( const int x; iarr) static assert(is(typeof(x) == const int));
foreach (immutable int x; iarr) static assert(is(typeof(x) == immutable int));
// with exact type + qualifier + ref
static assert(!__traits(compiles, {
foreach ( ref int x; iarr) {}
}));
foreach ( const ref int x; iarr) static assert(is(typeof(x) == const int));
foreach (immutable ref int x; iarr) static assert(is(typeof(x) == immutable int));
// convertible type + qualifier
foreach ( double x; iarr) static assert(is(typeof(x) == double));
foreach ( const double x; iarr) static assert(is(typeof(x) == const double));
foreach (immutable double x; iarr) static assert(is(typeof(x) == immutable double));
// convertible type + qualifier + ref
static assert(!__traits(compiles, {
foreach (ref double x; iarr) {}
}));
static assert(!__traits(compiles, {
foreach (const ref double x; iarr) {}
}));
static assert(!__traits(compiles, {
foreach (immutable ref double x; iarr) {}
}));
}
}
void test4090b()
{
// for the key
{
int[] arr = [1,2,3];
// inference + qualifier
foreach ( i, x; arr) static assert(is(typeof(i) == size_t));
foreach ( const i, x; arr) static assert(is(typeof(i) == const size_t));
foreach (immutable i, x; arr) static assert(is(typeof(i) == immutable size_t));
// inference + qualifier + ref
foreach ( ref i, x; arr) static assert(is(typeof(i) == size_t));
foreach ( const ref i, x; arr) static assert(is(typeof(i) == const size_t));
static assert(!__traits(compiles, {
foreach (immutable ref i, x; arr) {}
}));
// with exact type + qualifier
foreach ( size_t i, x; arr) static assert(is(typeof(i) == size_t));
foreach ( const size_t i, x; arr) static assert(is(typeof(i) == const size_t));
foreach (immutable size_t i, x; arr) static assert(is(typeof(i) == immutable size_t));
// with exact type + qualifier + ref
foreach ( ref size_t i, x; arr) static assert(is(typeof(i) == size_t));
foreach ( const ref size_t i, x; arr) static assert(is(typeof(i) == const size_t));
static assert(!__traits(compiles, {
foreach (immutable ref size_t i, x; arr) {}
}));
}
// for the mutable elements
{
int[] arr = [1,2,3];
// inference + qualifier
foreach (i, x; arr) static assert(is(typeof(x) == int));
foreach (i, const x; arr) static assert(is(typeof(x) == const int));
foreach (i, immutable x; arr) static assert(is(typeof(x) == immutable int));
// inference + qualifier + ref
foreach (i, ref x; arr) static assert(is(typeof(x) == int));
foreach (i, const ref x; arr) static assert(is(typeof(x) == const int));
static assert(!__traits(compiles, {
foreach (i, immutable ref x; arr) {}
}));
// with exact type + qualifier
foreach (i, int x; arr) static assert(is(typeof(x) == int));
foreach (i, const int x; arr) static assert(is(typeof(x) == const int));
foreach (i, immutable int x; arr) static assert(is(typeof(x) == immutable int));
// with exact type + qualifier + ref
foreach (i, ref int x; arr) static assert(is(typeof(x) == int));
foreach (i, const ref int x; arr) static assert(is(typeof(x) == const int));
static assert(!__traits(compiles, {
foreach (i, immutable ref int x; arr) {}
}));
// convertible type + qualifier
foreach (i, double x; arr) static assert(is(typeof(x) == double));
foreach (i, const double x; arr) static assert(is(typeof(x) == const double));
foreach (i, immutable double x; arr) static assert(is(typeof(x) == immutable double));
// convertible type + qualifier + ref
static assert(!__traits(compiles, {
foreach (i, ref double x; arr) {}
}));
static assert(!__traits(compiles, {
foreach (i, const ref double x; arr) {}
}));
static assert(!__traits(compiles, {
foreach (i, immutable ref double x; arr) {}
}));
}
// for the immutable elements
{
immutable(int)[] iarr = [1,2,3];
// inference + qualifier
foreach (i, x; iarr) static assert(is(typeof(x) == immutable int)); // same as variable declaration
foreach (i, const x; iarr) static assert(is(typeof(x) == immutable int)); // same as variable declaration
foreach (i, immutable x; iarr) static assert(is(typeof(x) == immutable int));
// inference + qualifier + ref
foreach (i, ref x; iarr) static assert(is(typeof(x) == immutable int)); // same as variable declaration
foreach (i, const ref x; iarr) static assert(is(typeof(x) == immutable int)); // same as variable declaration
foreach (i, immutable ref x; iarr) static assert(is(typeof(x) == immutable int));
// with exact type + qualifier
foreach (i, int x; iarr) static assert(is(typeof(x) == int));
foreach (i, const int x; iarr) static assert(is(typeof(x) == const int));
foreach (i, immutable int x; iarr) static assert(is(typeof(x) == immutable int));
// with exact type + qualifier + ref
static assert(!__traits(compiles, {
foreach (i, ref int x; iarr) {}
}));
foreach (i, const ref int x; iarr) static assert(is(typeof(x) == const int));
foreach (i, immutable ref int x; iarr) static assert(is(typeof(x) == immutable int));
// convertible type + qualifier
foreach (i , double x; iarr) static assert(is(typeof(x) == double));
foreach (i, const double x; iarr) static assert(is(typeof(x) == const double));
foreach (i, immutable double x; iarr) static assert(is(typeof(x) == immutable double));
// convertible type + qualifier + ref
static assert(!__traits(compiles, {
foreach (i, ref double x; iarr) {}
}));
static assert(!__traits(compiles, {
foreach (i, const ref double x; iarr) {}
}));
static assert(!__traits(compiles, {
foreach (i, immutable ref double x; iarr) {}
}));
}
}
void test4090c()
{
foreach ( x; 1..11) static assert(is(typeof(x) == int));
foreach ( const x; 1..11) static assert(is(typeof(x) == const int));
foreach (immutable x; 1..11) static assert(is(typeof(x) == immutable int));
foreach ( int x; 1..11) static assert(is(typeof(x) == int));
foreach ( const int x; 1..11) static assert(is(typeof(x) == const int));
foreach (immutable int x; 1..11) static assert(is(typeof(x) == immutable int));
foreach ( ref x; 1..11) static assert(is(typeof(x) == int));
foreach ( const ref x; 1..11) static assert(is(typeof(x) == const int));
static assert(!__traits(compiles, {
foreach (immutable ref x; 1..11) {}
}));
foreach ( double x; 1..11) static assert(is(typeof(x) == double));
foreach ( const double x; 1..11) static assert(is(typeof(x) == const double));
foreach (immutable double x; 1..11) static assert(is(typeof(x) == immutable double));
foreach ( ref double x; 1..11) static assert(is(typeof(x) == double));
foreach ( const ref double x; 1..11) static assert(is(typeof(x) == const double));
static assert(!__traits(compiles, {
foreach (immutable ref double x; 1..11) {}
}));
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/nogc.d 0000644 0001750 0001750 00000004611 13200164641 023004 0 ustar matthias matthias // REQUIRED_ARGS: -o-
/***************** Covariance ******************/
class C1
{
void foo() @nogc;
void bar();
}
class D1 : C1
{
override void foo(); // no error
override void bar() @nogc; // no error
}
/******************************************/
// __traits(compiles)
static assert(__traits(compiles, new Object()));
void foo_compiles() {}
@nogc void test_compiles()
{
auto fp = &foo_compiles;
static assert(!__traits(compiles, foo_compiles()));
static assert(!__traits(compiles, fp()));
static assert(!__traits(compiles, (*fp)()));
static assert(!__traits(compiles, [1,2,3]));
static assert(!__traits(compiles, [1:1, 2:2]));
struct Struct {}
static assert(!__traits(compiles, new int));
static assert(!__traits(compiles, new Struct()));
static assert(!__traits(compiles, new Object()));
int* p;
static assert(!__traits(compiles, delete p));
int[int] aa;
static assert(!__traits(compiles, aa[0]));
int[] a;
static assert(!__traits(compiles, a.length = 1));
static assert(!__traits(compiles, a.length += 1));
static assert(!__traits(compiles, a.length -= 1));
static assert(!__traits(compiles, a ~= 1));
static assert(!__traits(compiles, a ~ a));
}
/******************************************/
// 12630
void test12630() @nogc
{
// All of these declarations should cause no errors.
static const ex1 = new Exception("invalid");
//enum ex2 = new Exception("invalid");
static const arr1 = [[1,2], [3, 4]];
enum arr2 = [[1,2], [3, 4]];
//static const aa1 = [1:1, 2:2];
enum aa2 = [1:1, 2:2];
//static const v1 = aa1[1];
enum v2 = aa2[1];
Object o;
static const del1 = (delete o).sizeof;
enum del2 = (delete o).sizeof;
int[] a;
static const len1 = (a.length = 1).sizeof;
enum len2 = (a.length = 1).sizeof;
static const cata1 = (a ~= 1).sizeof;
enum cata2 = (a ~= 1).sizeof;
static const cat1 = (a ~ a).sizeof;
enum cat2 = (a ~ a).sizeof;
}
/******************************************/
// 12642
static if (is(__vector(ulong[2])))
{
import core.simd;
ulong2 test12642() @nogc
{
return [0, 0];
}
}
/******************************************/
// 13550
auto foo13550() @nogc
{
static int[] bar()
{
return new int[2];
}
return &bar;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test14962.d 0000644 0001750 0001750 00000001310 13200164641 023434 0 ustar matthias matthias template map(fun...)
{
auto map(R)(R r)
{
return MapResult!(fun, R)(r);
}
}
struct MapResult(alias fun, R)
{
R _input;
@property bool empty() { return _input.length == 0; }
@property auto front() { return fun(_input[0]); }
void popFront() { _input = _input[1..$]; }
}
struct Foo
{
int baz(int v)
{
static int id;
return v + id++;
}
void bar()
{
auto arr1 = [1, 2, 3];
auto arr2 = [4, 5, 6];
arr1.map!(
// lambda1
i =>
arr2.map!(
// lambda2
j =>
baz(i + j)
)
);
}
}
void main() {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test9526.d 0000644 0001750 0001750 00000000740 13200164641 023362 0 ustar matthias matthias template forward(args...)
{
@property fwd()() { return args[0]; }
static assert(__traits(compiles, { auto ex = fwd; }));
alias fwd forward;
}
void initializeClassInstance(C, Args...)(C chunk, auto ref Args args)
{
chunk.__ctor(forward!args);
}
void main()
{
static int si = 0;
static class C { this(int) { ++si; } }
void[__traits(classInstanceSize, C)] buff = void;
auto c = cast(C) buff.ptr;
initializeClassInstance(c, 0);
assert(si);
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice10431b.d 0000644 0001750 0001750 00000000135 13200164641 023346 0 ustar matthias matthias struct X(alias Y)
{
}
struct A
{
int[] data;
}
alias X!(A([])) X1;
alias X!(A([])) X2;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/99bottles.d 0000644 0001750 0001750 00000003374 13200164641 023721 0 ustar matthias matthias // written by Don Clugston:
// http://www.digitalmars.com/d/archives/digitalmars/D/announce/4374.html
// http://www.99-bottles-of-beer.net/language-d-1212.html
// Displays the "99 bottles of beer" song at compile time,
// using the template metaprograming facilities of D.
// No executable is generated. No libraries are used.
// Illustrates template default values, template string value parameters,
// compile-time concatenation of constant strings, static if.
module bottles99;
template decimaldigit(int n) {
const string decimaldigit = "0123456789"[n..n+1];
}
template itoa(ulong n)
{
static if ( n < 10L )
const string itoa = decimaldigit!(n);
else
const string itoa = itoa!( n / 10L ) ~ decimaldigit!( n % 10L );
}
template showHowMany(int n, string where, bool needcapital = false)
{
static if ( n > 1 )
const string showHowMany = itoa!(n) ~ " bottles of beer" ~ where ~ "\n";
else static if ( n == 1 )
const string showHowMany = "1 bottle of beer" ~ where ~ "\n";
else static if ( needcapital )
const string showHowMany = "No more bottles of beer" ~ where ~ "\n";
else
const string showHowMany = "no more bottles of beer" ~ where ~ "\n";
}
template beer(int maxbeers, int n = maxbeers)
{
static if ( n > 0 )
const string beer = showHowMany!(n, " on the wall,", true)
~ showHowMany!(n, ".")
~ "Take one down and pass it around, " ~ "\n"
~ showHowMany!( n - 1 , " on the wall.")
~ "\n" ~ beer!(maxbeers, n - 1); // recurse for subsequent verses.
else
const string beer = showHowMany!(n, " on the wall,", true)
~ showHowMany!(n, ".")
~ "Go to the store and buy some more, " ~ "\n"
~ showHowMany!( maxbeers, " on the wall.");
}
pragma(msg, beer!(99));
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test12009.d 0000644 0001750 0001750 00000000723 13200164641 023431 0 ustar matthias matthias struct RefCounted(T)
{
struct RefCountedStore
{
private struct Impl
{
T _payload;
}
private Impl* _store;
}
RefCountedStore _refCounted;
~this()
{
import core.stdc.stdlib : free;
}
}
struct GroupBy(R)
{
struct SharedInput
{
Group unused;
}
struct Group
{
private RefCounted!SharedInput _allGroups;
}
}
void main()
{
GroupBy!(int[]) g1;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test6013.d 0000644 0001750 0001750 00000000602 13200164641 023343 0 ustar matthias matthias import imports.test6013;
static assert(__traits(compiles, public_alias_value));
static assert(!__traits(compiles, private_alias_value));
static assert(__traits(compiles, public_alias_func()));
static assert(!__traits(compiles, private_alias_func()));
static assert(__traits(compiles, () { public_alias_type val; }));
static assert(!__traits(compiles, () { private_alias_type val; }));
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc9497a.d 0000644 0001750 0001750 00000000374 13200164641 023467 0 ustar matthias matthias // EXTRA_SOURCES: extra-files/ddoc9497a.ddoc
// PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 9497a
/**
foo function.
Args: $(XYZ arg1, arg2)
*/
void foo()
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddocYear.d 0000644 0001750 0001750 00000000234 13200164641 023605 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocYear-postscript.sh
/// $(YEAR)
int year;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/derivedarray.d 0000644 0001750 0001750 00000007741 13200164641 024546 0 ustar matthias matthias // PERMUTE_ARGS:
class C {}
class D : C {}
void dynamicarrays()
{
C[] a;
D[] b;
const(C)[] c;
const(D)[] d;
immutable(C)[] e;
immutable(D)[] f;
static assert( __traits(compiles, a = a));
static assert(!__traits(compiles, a = b));
static assert(!__traits(compiles, a = c));
static assert(!__traits(compiles, a = d));
static assert(!__traits(compiles, a = e));
static assert(!__traits(compiles, a = f));
static assert(!__traits(compiles, b = a));
static assert( __traits(compiles, b = b));
static assert(!__traits(compiles, b = c));
static assert(!__traits(compiles, b = d));
static assert(!__traits(compiles, b = e));
static assert(!__traits(compiles, b = f));
static assert( __traits(compiles, c = a));
static assert( __traits(compiles, c = b));
static assert( __traits(compiles, c = c));
static assert( __traits(compiles, c = d));
static assert( __traits(compiles, c = e));
static assert( __traits(compiles, c = f));
static assert(!__traits(compiles, d = a));
static assert( __traits(compiles, d = b));
static assert(!__traits(compiles, d = c));
static assert( __traits(compiles, d = d));
static assert(!__traits(compiles, d = e));
static assert( __traits(compiles, d = f));
static assert(!__traits(compiles, e = a));
static assert(!__traits(compiles, e = b));
static assert(!__traits(compiles, e = c));
static assert(!__traits(compiles, e = d));
static assert( __traits(compiles, e = e));
static assert( __traits(compiles, e = f));
static assert(!__traits(compiles, f = a));
static assert(!__traits(compiles, f = b));
static assert(!__traits(compiles, f = c));
static assert(!__traits(compiles, f = d));
static assert(!__traits(compiles, f = e));
static assert( __traits(compiles, f = f));
}
void statictodynamicarrays()
{
C[] a;
D[] b;
const(C)[] c;
const(D)[] d;
immutable(C)[] e;
immutable(D)[] f;
C[1] sa;
D[1] sb;
const(C)[1] sc = void;
const(D)[1] sd = void;
immutable(C)[1] se = void;
immutable(D)[1] sf = void;
static assert( __traits(compiles, a = sa));
static assert(!__traits(compiles, a = sb));
static assert(!__traits(compiles, a = sc));
static assert(!__traits(compiles, a = sd));
static assert(!__traits(compiles, a = se));
static assert(!__traits(compiles, a = sf));
static assert(!__traits(compiles, b = sa));
static assert( __traits(compiles, b = sb));
static assert(!__traits(compiles, b = sc));
static assert(!__traits(compiles, b = sd));
static assert(!__traits(compiles, b = se));
static assert(!__traits(compiles, b = sf));
static assert( __traits(compiles, c = sa));
static assert( __traits(compiles, c = sb));
static assert( __traits(compiles, c = sc));
static assert( __traits(compiles, c = sd));
static assert( __traits(compiles, c = se));
static assert( __traits(compiles, c = sf));
static assert(!__traits(compiles, d = sa));
static assert( __traits(compiles, d = sb));
static assert(!__traits(compiles, d = sc));
static assert( __traits(compiles, d = sd));
static assert(!__traits(compiles, d = se));
static assert( __traits(compiles, d = sf));
static assert(!__traits(compiles, e = sa));
static assert(!__traits(compiles, e = sb));
static assert(!__traits(compiles, e = sc));
static assert(!__traits(compiles, e = sd));
static assert( __traits(compiles, e = se));
static assert( __traits(compiles, e = sf));
static assert(!__traits(compiles, f = sa));
static assert(!__traits(compiles, f = sb));
static assert(!__traits(compiles, f = sc));
static assert(!__traits(compiles, f = sd));
static assert(!__traits(compiles, f = se));
static assert( __traits(compiles, f = sf));
}
void staticarrays()
{
C[1] sa;
D[1] sb;
const(C)[1] sc = sa;
const(D)[1] sd = sb;
sa = sb;
static assert(!__traits(compiles, sb = sa));
}
void main() {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice9663.d 0000644 0001750 0001750 00000000156 13200164641 023146 0 ustar matthias matthias // REQUIRED_ARGS: -wi
void main()
{
int[1] a;
int[] b = [1];
a = 1;
b[] = a;
b = a;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test8041.d 0000644 0001750 0001750 00000000302 13200164641 023343 0 ustar matthias matthias // PERMUTE_ARGS:
struct Foo { }
void main()
{
static Foo sf; // ok
__gshared Foo gf; // was: Error: non-constant expression gf = 0
__gshared int[1][1] arr; // dup: Issue 6089
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test6999.d 0000644 0001750 0001750 00000000435 13200164641 023376 0 ustar matthias matthias // 6999: inout in front of return type
struct A
{
inout:
inout(int) foo()
{
return 0;
}
}
struct B
{
inout
{
inout(int) foo()
{
return 0;
}
}
}
struct C
{
inout inout(int) foo()
{
return 0;
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test9369.d 0000644 0001750 0001750 00000000023 13200164641 023361 0 ustar matthias matthias Ddoc
---
a=1;
---
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test8513.d 0000644 0001750 0001750 00000001211 13200164641 023347 0 ustar matthias matthias interface I_Foo { void i_outer(); }
class C_Foo { void c_outer() { } }
class Bar
{
interface I_Foo { void i_inner(); }
class C_Foo { void c_inner() { } }
class Impl1 : C_Foo, I_Foo
{
override void i_inner() { }
override void c_inner() { }
}
class Impl2 : C_Foo, .I_Foo
{
override void i_outer() { }
override void c_inner() { }
}
class Impl3 : .C_Foo, I_Foo
{
override void i_inner() { }
override void c_outer() { }
}
class Impl4 : .C_Foo, .I_Foo
{
override void i_outer() { }
override void c_outer() { }
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test9680.sh 0000755 0001750 0001750 00000001401 13200164641 023550 0 ustar matthias matthias #!/usr/bin/env bash
name=`basename $0 .sh`
dir=${RESULTS_DIR}/compilable
if [ "${OS}" == "win32" -o "${OS}" == "Windows_NT" ]; then
kinds=( main winmain dllmain )
else
kinds=( main )
fi
for kind in "${kinds[@]}"
do
file_name=${name}${kind}
src_file=compilable/extra-files/${file_name}.d
expect_file=compilable/extra-files/${file_name}.out
output_file=${dir}/${file_name}.out
rm -f ${output_file}{,.2}
$DMD -m${MODEL} -v -o- ${src_file} > ${output_file}
grep "^entry ${kind}" ${output_file} > ${output_file}.2
if [ `wc -c ${output_file}.2 | while read a b; do echo $a; done` -eq 0 ]; then
echo "Error: not found expected entry point '${kind}' in ${src_file}"
exit 1;
fi
rm ${output_file}{,.2}
done
echo Success >${dir}/`basename $0`.out
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc7656.d 0000644 0001750 0001750 00000000624 13200164641 023317 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 7656
module ddoc7656;
/**
--------
int x; // This is a $ comment (and here is some
int y; // more information about that comment)
--------
*/
void main() { }
/**
(Regression check)
Example:
----
assert(add(1, 1) == 2);
----
*/
int add(int a, int b) { return a + b; }
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test6089.d 0000644 0001750 0001750 00000000074 13200164641 023363 0 ustar matthias matthias // PERMUTE_ARGS:
void main()
{
extern int[1][1] foo;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test1878a.d 0000644 0001750 0001750 00000000403 13200164641 023521 0 ustar matthias matthias void main()
{
ubyte from, to;
foreach(i; from..to)
{
static assert(is(typeof(i) == ubyte));
}
foreach(i; 'a'..'l')
{
static assert(is(typeof(i) == char));
}
foreach(i; '×' .. 'ת')
{
static assert(is(typeof(i) == wchar));
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/deprecate12979a.d 0000644 0001750 0001750 00000000365 13200164641 024571 0 ustar matthias matthias // REQUIRED_ARGS: -dw
// PERMUTE_ARGS:
/*
TEST_OUTPUT:
---
compilable/deprecate12979a.d(13): Deprecation: asm statement is assumed to throw - mark it with 'nothrow' if it does not
---
*/
void foo() nothrow
{
asm
{
ret;
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice14075.d 0000644 0001750 0001750 00000000406 13200164641 023215 0 ustar matthias matthias // REQUIRED_ARGS: -o-
// PERMUTE_ARGS:
struct Foo
{
auto opAssign(this X)(ref typeof(this));
auto opAssign(this X, V)(ref V) if (!is(V == typeof(this)));
}
void test()
{
Foo src;
const(Foo) target;
static if (is(typeof(target = src))) {}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc10366.d 0000644 0001750 0001750 00000000475 13200164641 023373 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 10366
///
struct S(T)
{
///
void method() {}
public
{
///
struct Nested
{
///
void nestedMethod() {}
}
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test9672.d 0000644 0001750 0001750 00000000160 13200164641 023360 0 ustar matthias matthias module test9672; // node
import imports.test9672a; // interpret
mixin template ForwardCtor()
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc6.d 0000644 0001750 0001750 00000000547 13200164641 023061 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 6
/**
*
*/
struct MyStruct(T)
{
static if( true )
{
void MyStruct() {}
}
}
void main()
{
}
/+
23
C:\code\d\bugs>dmd -D -o- 148_1.d
148_1.d(6): Error: static if conditional cannot be at global scope
+/
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testcov1.d 0000644 0001750 0001750 00000000217 13200164641 023624 0 ustar matthias matthias // EXTRA_SOURCES: imports/testcov1a.d imports/testcov1b.d
// PERMUTE_ARGS:
// REQUIRED_ARGS: -cov
import core.stdc.string;
import testcov1a;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc4899.d 0000644 0001750 0001750 00000001021 13200164641 023315 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -w -o-
/*
TEST_OUTPUT:
---
compilable/ddoc4899.d(16): Warning: Ddoc: Stray '('. This may cause incorrect Ddoc output. Use $(LPAREN) instead for unpaired left parentheses.
compilable/ddoc4899.d(16): Warning: Ddoc: Stray ')'. This may cause incorrect Ddoc output. Use $(RPAREN) instead for unpaired right parentheses.
---
*/
/++
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
+/
module d;
void main()
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test9434.d 0000644 0001750 0001750 00000000311 13200164641 023352 0 ustar matthias matthias import test9435;//semantic;
template Visitors()
{
mixin Semantic!(typeof(this));
}
class Node
{
mixin Visitors;
}
class Expression : Node
{
}
class BinaryExp(TokenType op) : Expression
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test4375.d 0000644 0001750 0001750 00000016426 13200164641 023367 0 ustar matthias matthias // 4375: disallow dangling else
void main() {
if (true) {
if (false) {
assert(1);
} else {
assert(2);
}
}
if (true) {
if (false)
assert(7);
} else
assert(8);
if (true) {
if (false)
assert(9);
else
assert(10);
}
{
if (true)
assert(11);
else
assert(12);
}
{
label1:
if (true)
assert(13);
else
assert(14);
}
if (true)
foreach (i; 0 .. 5) {
if (true)
assert(17);
else
assert(18);
}
if (true) {
foreach (i; 0 .. 5)
if (true)
assert(18.1);
} else
assert(18.2);
if (true)
assert(19);
else
assert(20);
if (true)
assert(21);
else if (false)
assert(22);
else
assert(23);
version (A) {
if (true)
assert(26);
} else
assert(27);
version (A) {
if (true)
assert(28);
else
assert(29);
}
version (A)
assert(30);
else version (B)
assert(31);
else
assert(32);
static if (true) {
static if (true)
assert(35);
} else
assert(36);
static if (true) {
static if (true)
assert(37);
else
assert(38);
}
static if (true)
assert(39);
else static if (true)
assert(40);
else
assert(41);
switch (4) {
case 0:
if (true)
assert(42);
else
assert(43);
break;
case 1: .. case 5:
if (true)
assert(44);
else
assert(45);
break;
default:
if (true)
assert(46);
else
assert(47);
break;
}
// (o_O)
switch (1)
default:
if (true)
assert(113);
else
assert(114);
// (o_O)
final switch (1)
case 1:
if (true)
assert(117);
else
assert(118);
mixin(q{
if (true)
assert(56);
else
assert(57);
});
while (false)
if (true)
assert(66);
else
assert(67);
if (true)
while (false)
assert(68);
else
assert(69);
do
if (true)
assert(72);
else
assert(73);
while (false);
if (true)
do
if (true)
assert(74);
else
assert(75);
while (false);
for (
if (true) // (o_O)
assert(78);
else
assert(79);
false; false
)
if (true)
assert(80);
else
assert(81);
if (true)
for (if (true) assert(84); else assert(85); false;)
assert(86);
if (true)
if (true)
if (true)
if (true)
if (true)
assert(87);
auto x = new C;
if (true)
while (false)
for (;;)
scope (exit)
synchronized (x)
assert(88);
else
assert(89);
if (true)
while (false)
for (;;) {
scope (exit)
synchronized (x)
if (true)
assert(90);
else
assert(89);
}
if (true)
while (false)
for (;;)
scope (exit)
synchronized (x)
if (true)
assert(90);
else
assert(89);
else
assert(12);
with (x)
if (false)
assert(92);
else
assert(93);
try
if (true)
assert(94);
else
assert(95);
catch (Exception e)
if (true)
assert(96);
else
assert(97);
finally
if (true)
assert(98);
else
assert(99);
if (true)
try
if (true)
assert(100);
else
assert(101);
finally
assert(102);
if (true)
try
assert(109);
catch(Exception e)
if (true)
assert(110);
else
assert(112);
finally
assert(111);
static struct F {
static if (true)
int x;
else
int y;
static if (true) {
static if (false)
int z;
} else
int w;
static if (true)
int t;
else static if (false)
int u;
else
int v;
}
if (true)
if (true)
assert(113);
else
assert(114);
else
assert(115);
static if (true)
static if (true)
assert(116);
else
assert(117);
else
assert(118);
}
unittest {
if (true)
assert(50);
else
assert(51);
}
class C {
invariant() {
if (true)
assert(58);
else
assert(59);
}
int f()
in {
if (true)
assert(60);
else
assert(61);
}
out(res) {
if (true)
assert(62);
else
assert(63);
}
body {
if (true)
assert(64);
else
assert(65);
return 0;
}
}
enum q = q{
if(true)
if(true)
assert(54.1);
else
assert(55.2);
};
static if (true)
struct F0 {}
else static if (true)
struct F1 {}
else
struct F2 {}
static if (true) {
static if (false)
struct F3 {}
} else
struct F4 {}
version(A) {
version(B)
struct F5 {}
} else
struct F6 {}
version(A) {
version(B)
struct F5a {}
else
struct F5b {}
}
version (C)
struct F5c {}
else
struct F5d {}
struct F7 {
static if (true)
int x;
else
float x;
private:
static if (true)
int y;
else
float y;
}
template F8() {
static if (true)
int x;
else
float x;
}
static if (true)
align(1)
static if (false)
struct F9 {}
static if (true)
align(1) {
extern(C)
pure
static if (false)
void F10(){}
else
void F11(){}
}
void f() {
int[] x;
static if (5 > 0)
version (Y)
scope (failure)
foreach (i, e; x)
while (i > 20)
with (e)
if (e < 0)
synchronized(e)
assert(1);
else
assert(2);
else
x = null;
else
x = null;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test10056.d 0000644 0001750 0001750 00000002427 13200164641 023434 0 ustar matthias matthias void main()
{
alias Zoo = Foo10056!(false, false, 1);
}
struct Foo10056(bool S, bool L, size_t N)
{
string bar()
{
Appender10056!(string) w;
char[] buf; put10056(w, buf);
return "";
}
public bool opEquals(T)(T other) //const
//If you add const, also fails to compile with 2.062.
{
alias Foo10056!(typeof(this), T, "CMP") P;
return false;
}
}
template Foo10056(T, U, string OP)
{
static if (T.ISEMPTY && U.ISEMPTY)
enum bool S = false;
else
enum bool S = false;
alias Foo10056 = Foo10056!(false, false, 0);
}
/**********************************************/
void put10056(R, E)(ref R r, E e)
{
static if (is(typeof(r.put(e))))
{
r.put(e);
}
else
{
static assert(false, "Cannot put a "~E.stringof~" into a "~R.stringof);
}
}
struct Appender10056(A : T[], T)
{
private template canPutItem(U)
{
enum bool canPutItem = is(U : T);
}
private template canPutRange(R)
{
enum bool canPutRange = is(typeof(Appender10056.init.put(R.init[0])));
}
void put(U)(U item) if (canPutItem!U)
{
char[T.sizeof == 1 ? 4 : 2] encoded;
put(encoded[]);
}
void put(R)(R items) if (canPutRange!R)
{
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc8739.d 0000644 0001750 0001750 00000000451 13200164641 023320 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 8739
module ddoc8739;
///
void delegate(int a) dg;
///
void delegate(int b) dg2;
///
void delegate(int c)[] dg3;
///
void delegate(int d)* dg4;
void main() {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test8631.d 0000644 0001750 0001750 00000000430 13200164641 023352 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -de
class B {
int foo() immutable { return 2; }
int foo() const { return 2; }
}
class D : B {
override int foo() immutable { return 2; }
int foo() const shared { return 2; }
override int foo() const { return 2; }
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice1524.d 0000644 0001750 0001750 00000001062 13200164641 023127 0 ustar matthias matthias // Issue 1524 - ICE(constfold.c) on using "is" with strings in CTFE
/* 1524 PATCH Assertion failure: '0' on line 863 in file 'constfold.c'
constfold.c
@@ -845,9 +845,9 @@
Loc loc = e1->loc;
int cmp;
- if (e1->op == TOKnull && e2->op == TOKnull)
+ if (e1->op == TOKnull || e2->op == TOKnull)
{
- cmp = 1;
+ cmp = (e1->op == TOKnull && e2->op == TOKnull) ? 1 : 0;
}
else if (e1->op == TOKsymoff && e2->op == TOKsymoff)
{
*/
bool isNull(string str)
{
return str is null;
}
const bool test = isNull("hello!");
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/depmsg.d 0000644 0001750 0001750 00000001043 13200164641 023331 0 ustar matthias matthias // REQUIRED_ARGS: -d
// PERMUTE_ARGS: -dw
void main()
{
class Inner
{
deprecated("With message!")
{
struct A { }
class B { }
interface C { }
union D { }
enum E { e };
//typedef int F;
alias int G;
static int H;
template I() { class I {} }
}
}
with(Inner)
{
A a;
B b;
C c;
D d;
E e;
//F f;
G g;
auto h = H;
I!() i;
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test10375.d 0000644 0001750 0001750 00000000356 13200164641 023437 0 ustar matthias matthias // REQUIRED_ARGS: -o-
import imports.test10375a;
void packIt(Pack)(Pack p){ } //3
void main()
{
alias p = packIt!(int);
p(2); // OK <- NG
packIt(2); // OK <- NG
packIt!(int)(2); // OK <- NG
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/bug6963.d 0000644 0001750 0001750 00000003122 13200164641 023157 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS:
/*
TEST_OUTPUT:
---
output foo: 1e: pure nothrow @nogc @safe void(int x)
output foo: 3e: pure nothrow @nogc @safe void(int x)
---
*/
alias void function(int) pure nothrow @safe @nogc FuncPtrType;
void foo1a(X)(X x) {}
void foo1b(X)(X x) {}
void foo1c(X)(X x) {}
void foo1d(X)(X x) {}
void foo1e(X)(X x) {}
// module level declaration with type inference
auto fptr1 = &foo1a!int;
static assert(is(typeof(fptr1) == FuncPtrType));
// array initializer
auto fptrlist1 = [&foo1b!int];
static assert(is(typeof(fptrlist1) == FuncPtrType[]));
// static assert
static assert(is(typeof(&foo1c!int) == FuncPtrType));
// static if
static if(is(typeof(&foo1d!int) PF))
static assert(is(PF == FuncPtrType));
else
static assert(0);
// pragma test
pragma(msg, "output foo: 1e: ", typeof(foo1e!int).stringof);
void foo2a(X)(X x) {}
void foo2b(X)(X x) {}
void foo2c(X)(X x) {}
FuncPtrType fptr3 = &foo2a!int; // most similar to original issue
FuncPtrType[] fptrlist3 = [&foo2b!int];
struct S{ FuncPtrType fp; }
S s = { &foo2c!int };
void foo3a(X)(X x) {}
void foo3b(X)(X x) {}
void foo3c(X)(X x) {}
void foo3d(X)(X x) {}
void foo3e(X)(X x) {}
void main()
{
auto fptr2 = &foo3a!int;
static assert(is(typeof(fptr2) == FuncPtrType));
auto fptrlist2 = [&foo3b!int];
static assert(is(typeof(fptrlist2) == FuncPtrType[]));
static assert(is(typeof(&foo1c!int) == FuncPtrType));
static if(is(typeof(&foo1d!int) PF))
static assert(is(PF == FuncPtrType));
else
static assert(0);
pragma(msg, "output foo: 3e: ", typeof(foo3e!int));
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test12979b.d 0000644 0001750 0001750 00000001214 13200164641 023607 0 ustar matthias matthias // REQUIRED_ARGS: -w -de
void foo() pure nothrow @nogc @safe
{
asm pure nothrow @nogc @trusted
{
ret;
}
}
void bar()()
{
asm pure nothrow @nogc @trusted
{
ret;
}
}
static assert(__traits(compiles, () pure nothrow @nogc @safe => bar()));
void baz()()
{
asm
{
ret;
}
}
// wait for deprecation of asm pure inference
// static assert(!__traits(compiles, () pure => baz()));
static assert(!__traits(compiles, () nothrow => baz()));
// wait for deprecation of asm @nogc inference
// static assert(!__traits(compiles, () @nogc => baz()));
static assert(!__traits(compiles, () @safe => baz()));
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/sw_transition_field.d 0000644 0001750 0001750 00000001131 13200164641 026116 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -c -transition=field
/*
TEST_OUTPUT:
---
compilable/sw_transition_field.d(15): sw_transition_field.S1.ix is immutable field
compilable/sw_transition_field.d(16): sw_transition_field.S1.cx is const field
compilable/sw_transition_field.d(21): sw_transition_field.S2!(immutable(int)).S2.f is immutable field
compilable/sw_transition_field.d(21): sw_transition_field.S2!(const(int)).S2.f is const field
---
*/
struct S1
{
immutable int ix = 1;
const int cx = 2;
}
struct S2(F)
{
F f = F.init;
}
alias S2!(immutable int) S2I;
alias S2!( const int) S2C;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice11906.d 0000644 0001750 0001750 00000000345 13200164641 023217 0 ustar matthias matthias // REQUIRED_ARGS: -o-
// PERMUTE_ARGS:
nothrow /*extern(Windows) */export int GetModuleHandleA(const char* lpModuleName);
void main()
{
/*extern(Windows) */int function(const char*) f;
assert(f != &GetModuleHandleA);
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice12002.d 0000644 0001750 0001750 00000000707 13200164641 023205 0 ustar matthias matthias // REQUIRED_ARGS: -inline
// PERMUTE_ARGS:
void doFormat(void delegate(dchar) putc, TypeInfo[] arguments)
{
void formatArg(char fc)
{
const(char)* prefix = "";
void putstr(const char[] s)
{
//if (flags & FL0pad)
{
while (*prefix)
putc(*prefix++);
}
foreach (dchar c; s)
putc(c);
}
putstr(null);
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test7754.d 0000644 0001750 0001750 00000000331 13200164641 023357 0 ustar matthias matthias // REQUIRED_ARGS: -H -Hd${RESULTS_DIR}/compilable
// POST_SCRIPT: compilable/extra-files/test7754-postscript.sh
// PERMUTE_ARGS: -d -dw
struct Foo(T)
{
shared static this()
{
}
static this()
{
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test8717.d 0000644 0001750 0001750 00000003404 13200164641 023363 0 ustar matthias matthias module test8717;
struct SPR
{
private:
enum e = 1;
immutable int ii = 1;
immutable static int sii = 1;
static int sf() { return 1; }
int f() const { return 1; }
}
static assert(SPR.e == 1);
//static assert(SPR.ii == 1);
static assert(SPR.sii == 1);
static assert(SPR.sf() == 1);
static assert(SPR.init.e == 1);
static assert(SPR.init.ii == 1);
static assert(SPR.init.sii == 1);
static assert(SPR.sf() == 1);
static assert(SPR.init.f() == 1);
static if(SPR.e != 1) { static assert(0); }
//static if(SPR.ii != 1) { static assert(0); }
static if(SPR.sii != 1) { static assert(0); }
static if(SPR.sf() != 1) { static assert(0); }
static if(SPR.init.e != 1) { static assert(0); }
static if(SPR.init.ii != 1) { static assert(0); }
static if(SPR.init.sii != 1) { static assert(0); }
static if(SPR.sf() != 1) { static assert(0); }
static if(SPR.init.f() != 1) { static assert(0); }
struct SPT
{
protected:
enum e = 1;
immutable int ii = 1;
immutable static int sii = 1;
static int sf() { return 1; }
int f() const { return 1; }
}
static assert(SPT.e == 1);
//static assert(SPT.ii == 1);
static assert(SPT.sii == 1);
static assert(SPT.sf() == 1);
static assert(SPT.init.e == 1);
static assert(SPT.init.ii == 1);
static assert(SPT.init.sii == 1);
static assert(SPT.sf() == 1);
static assert(SPT.init.f() == 1);
static if(SPT.e != 1) { static assert(0); }
//static if(SPT.ii != 1) { static assert(0); }
static if(SPT.sii != 1) { static assert(0); }
static if(SPT.sf() != 1) { static assert(0); }
static if(SPT.init.e != 1) { static assert(0); }
static if(SPT.init.ii != 1) { static assert(0); }
static if(SPT.init.sii != 1) { static assert(0); }
static if(SPT.sf() != 1) { static assert(0); }
static if(SPT.init.f() != 1) { static assert(0); }
void main() { }
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/const.d 0000644 0001750 0001750 00000002122 13200164641 023177 0 ustar matthias matthias
static assert(2.0 * 3.0 == 6 );
static assert(2.0 * 3.0i == 6i);
static assert(2.0i * 3.0 == 6i);
static assert(2.0i * 3.0i == -6 );
static assert(2.0 * (4.0 + 3.0i) == 8 + 6i);
static assert(2.0i * (4.0 + 3.0i) == 8i - 6 );
static assert((4.0 + 3.0i) * 2.0 == 8 + 6i);
static assert((4.0 + 3.0i) * 2.0i == 8i - 6 );
static assert((4.0 + 3.0i) * (5 + 7i) == -1 + 43i );
static assert((2.0).re == 2);
static assert((2.0i).re == 0);
static assert((3+2.0i).re == 3);
static assert((4.0i).im == 4);
static assert((2.0i).im == 2);
static assert((3+2.0i).im == 2);
static assert(6.0 / 2.0 == 3);
static assert(6i / 2i == 3);
static assert(6 / 2i == -3i);
static assert(6i / 2 == 3i);
static assert((6 + 4i) / 2 == 3 + 2i);
static assert((6 + 4i) / 2i == -3i + 2);
//static assert(2 / (6 + 4i) == -3i);
//static assert(2i / (6 + 4i) == 3i);
//static assert((1 + 2i) / (6 + 4i) == 3i);
static assert(6.0 % 2.0 == 0);
static assert(6.0 % 3.0 == 0);
static assert(6.0 % 4.0 == 2);
static assert(6.0i % 2.0i == 0);
static assert(6.0i % 3.0i == 0);
static assert(6.0i % 4.0i == 2i);
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testDIP37a.d 0000644 0001750 0001750 00000000303 13200164641 023677 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -c -Icompilable/extra-files
// EXTRA_SOURCES: extra-files/pkgDIP37/datetime/package.d
// EXTRA_SOURCES: extra-files/pkgDIP37/datetime/common.d
void main()
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test8296.d 0000644 0001750 0001750 00000000411 13200164641 023360 0 ustar matthias matthias struct bar2
{
int i;
@disable this();
this(int i)
{
this.i = i;
}
}
class InnerBar {
bar2 b;
this()
{
b = bar2(0);
}
}
struct bar1
{
InnerBar b;
}
class Foo
{
bar1 m_bar1;
}
void main(string[] args)
{
auto foo = new Foo();
} ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testDIP42.d 0000644 0001750 0001750 00000005034 13200164641 023540 0 ustar matthias matthias // REQUIRED_ARGS: -o-
// PERMUTE_ARGS:
// enum ident(tpl) = Initializer;
enum isIntegral(T) = is(T == int) || is(T == long);
static assert( isIntegral!int);
static assert( isIntegral!long);
static assert(!isIntegral!double);
static assert(!isIntegral!(int[]));
version(none)
{
enum
allSatisfy(alias pred, TL...) =
TL.length == 0 || (pred!(TL[0]) && allSatisfy!(pred, TL[1..$])),
anySatisfy(alias pred, TL...) =
TL.length != 0 && (pred!(TL[0]) || anySatisfy!(pred, TL[1..$])) || false;
static assert( allSatisfy!(isIntegral, int, long));
static assert(!allSatisfy!(isIntegral, int, double));
static assert( anySatisfy!(isIntegral, int, double));
static assert(!anySatisfy!(isIntegral, int[], double));
}
void test1()
{
// statement
enum isIntegral2(T) = is(T == int) || is(T == long);
static assert(isIntegral2!int);
}
/******************************************/
// alias ident(tpl) = Type;
alias TypeTuple(TL...) = TL;
static assert(is(TypeTuple!(int, long)[0] == int));
static assert(is(TypeTuple!(int, long)[1] == long));
alias Id(T) = T, Id(alias A) = A;
static assert(is(Id!int == int));
static assert(__traits(isSame, Id!TypeTuple, TypeTuple));
void test2()
{
// statement
alias TypeTuple2(TL...) = TL;
static assert(is(TypeTuple2!(int, long)[0] == int));
static assert(is(TypeTuple2!(int, long)[1] == long));
alias IdT(T) = T, IdA(alias A) = A;
static assert(is(IdT!int == int));
static assert(__traits(isSame, IdA!TypeTuple, TypeTuple));
}
/******************************************/
// template auto declaration
auto tynameLen(T) = T.stringof.length;
void test3()
{
assert(tynameLen!int == 3);
assert(tynameLen!long == 4);
tynameLen!int = 4;
tynameLen!long = 5;
assert(tynameLen!int == 4);
assert(tynameLen!long == 5);
// statement
auto tynameLen2(T) = T.stringof.length;
assert(tynameLen2!int == 3);
assert(tynameLen2!long == 4);
tynameLen2!int = 4;
tynameLen2!long = 5;
assert(tynameLen2!int == 4);
assert(tynameLen2!long == 5);
}
/******************************************/
// template variable declaration
static T math_pi(T) = cast(T)3.1415;
enum bool isFloatingPoint(T) = is(T == float) || is(T == double);
static assert( isFloatingPoint!double);
static assert(!isFloatingPoint!string);
void main()
{
assert(math_pi!int == 3);
assert(math_pi!double == 3.1415);
enum bool isFloatingPoint2(T) = is(T == float) || is(T == double);
static assert( isFloatingPoint2!double);
static assert(!isFloatingPoint2!string);
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test10992b.d 0000644 0001750 0001750 00000000326 13200164641 023603 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -unittest
version(none)
{}
else
{
unittest { }
unittest { }
unittest { }
}
void main()
{
static assert(__traits(getUnitTests, mixin(__MODULE__)).length == 3);
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testimport12242.d 0000644 0001750 0001750 00000001412 13200164641 024657 0 ustar matthias matthias // PERMUTE_ARGS:
module testimport12242;
import imports.imp12242a; // test // stripA == OverloadSet
import imports.imp12242a1; // std.string // stripA == template
import imports.imp12242b1; // std.string // stripB == template
import imports.imp12242b; // test // stripB == OverloadSet
void main()
{
static assert(stripA(" af ") == 1);
static assert(" af ".stripA() == 1); // UFCS (1)
static assert(" af ".stripA == 1); // UFCS (2)
static assert(stripB(" af ") == 1);
static assert(" af ".stripB() == 1); // UFCS (1)
static assert(" af ".stripB == 1); // UFCS (2)
static assert(foo!int == 1);
static assert(foo!long == 2);
static assert(foo!float == 3);
static assert(foo!real == 4);
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test11237.d 0000644 0001750 0001750 00000000161 13200164641 023427 0 ustar matthias matthias // PERMUTE_ARGS:
// POST_SCRIPT: compilable/extra-files/test11237.sh
struct Buffer { ubyte[64 * 1024] buffer; }
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc3.d 0000644 0001750 0001750 00000002617 13200164641 023056 0 ustar matthias matthias // EXTRA_SOURCES: extra-files/ddoc3.ddoc
// PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 3
/**
* Summary
*
* Description1
*
* Description2
*
* Description3
*
* Macros:
* WIKI = StdStream
* meemie
* ARG0 = $0
* ARG1 = $1
* ARG2 = $2
* ARG3 = $3
* PLUS = $+
* TROW = $(TR $(TCOL $1,$+))
* TCOL = $(TD $1) $(TCOL $+)
* LPAREN = (
* See_Also:
* Things to see also.
*
* And more things $(BR)
* 'arg1, arg2, arg3' : $(ARG0 arg1, arg2, arg3). $(BR)
* 'arg2, arg3' : $(PLUS arg1, arg2, arg3). $(BR)
* 'arg1' : $(ARG1 arg1, arg2, arg3). $(BR)
* 'arg2' : $(ARG2 arg1, arg2, arg3). $(BR)
* 'arg3' : $(ARG3 arg1, arg2, arg3). $(BR)
*/
/**
* Things to see also $(HELLO).
*
* $(TABLE
* $(TROW 1, 2, 3)
* $(TROW 4, 5, 6)
* )
*
* $(D_CODE
$(B pragma)( $(I name) );
$(B pragma)( $(I name) , $(I option) [ $(I option) ] );
$(U $(LPAREN))
)
*/
/*
*/
module std.test;
/// A base class for stream exceptions.
class StreamException: Exception {
/** Construct a StreamException with given error message msg.
* Params:
* msg = the $(RED red) $(BLUE blue) $(GREEN green) $(YELLOW yellow).
* foo = next parameter which is a much longer
* message spanning multiple
* lines.
*/
this(string msg, int foo) { super(msg); }
/********** stars ***************/
int stars;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc4162.d 0000644 0001750 0001750 00000000361 13200164641 023302 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 4162
///
interface A
{
///
static void staticHello() { }
///
final void hello() { }
}
void main()
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test6395.d 0000644 0001750 0001750 00000000130 13200164641 023354 0 ustar matthias matthias // REQUIRED_ARGS: -c compilable/b6395 -Icompilable/extra-files
// 6395
import c6395;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test6056a.d 0000644 0001750 0001750 00000000135 13200164641 023514 0 ustar matthias matthias alias const(typeof('c')*) A;
alias const(typeof(0)*) B;
static assert(is(B == const(int*)));
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc5.d 0000644 0001750 0001750 00000000616 13200164641 023055 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 5
/**
Test module
*/
module test;
/// class to test DDOC on members
class TestMembers(TemplateArg)
{
public:
/**
a static method
Params: idx = index
*/
static void PublicStaticMethod(int idx)
{
}
}
void main()
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ldc_github_454.d 0000644 0001750 0001750 00000000120 13200164641 024545 0 ustar matthias matthias import std.file;
void main() {
auto a = dirEntries("","",SpanMode.depth);
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc648.d 0000644 0001750 0001750 00000002512 13200164641 023227 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 648
module ddoc648;
/// Mixin declaration
mixin template Mixin1()
{
/// struct S
struct S { }
}
/// class A
class A
{
/// field x
int x;
/// no docs for mixin statement (only for expanded members)
mixin Mixin1!();
}
/// class AB
class AB
{
/// field x
int x;
// no docs for mixin or its contents, must be a ddoc comment
mixin Mixin1!();
}
/// Mixin declaration2
mixin template Mixin2()
{
/// struct S2
struct S2 { }
}
/// Mixin declaration3
mixin template Mixin3()
{
/// another field
int f;
/// no docs for mixin statement (only for expanded members)
mixin Mixin2!();
}
/// class B1
class B1
{
/// no docs for mixin statement (only for expanded members)
mixin Mixin3!();
}
/// Mixin declaration3
mixin template Mixin4()
{
/// another field
int f;
// no docs at all for non-ddoc comment
mixin Mixin2!();
}
/// class B2
class B2
{
/// no docs for mixin statement (only for expanded members)
mixin Mixin4!();
}
/// no docs for mixin statement (only for expanded members)
mixin Mixin3!();
///
struct TS(T)
{
mixin template MT()
{
}
mixin MT; /// avoid calling semantic
///
int field;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testfwdref.d 0000644 0001750 0001750 00000020323 13200164641 024231 0 ustar matthias matthias // PERMUTE_ARGS:
/***************************************************/
// 6766
class Foo6766
{
this(int x) { }
void test(Foo6766 foo = new Foo6766(1)) { }
}
struct Bar6766
{
this(int x) { }
void test(Bar6766 bar = Bar6766(1)) { }
}
/***************************************************/
// 8609
struct Tuple8609(T)
{
T arg;
}
// ----
struct Foo8609a
{
Bar8609a b;
}
struct Bar8609a
{
int x;
Tuple8609!(Foo8609a) spam() { return Tuple8609!(Foo8609a)(); }
}
// ----
struct Foo8609b
{
Bar8609b b;
}
struct Bar8609b
{
int x;
Tuple8609!(Foo8609b[1]) spam() { return Tuple8609!(Foo8609b[1])(); }
}
/***************************************************/
// 8698
interface IRoot8698a {}
interface IClass8698a : IRoot8698a { }
struct Struct8698a { }
class Class8698a : IClass8698a { alias Struct8698a Value; }
void test8698a(Class8698a.Value) { }
//interface IRoot8698a {}
// ----
//interface IRoot8698b {}
interface IClass8698b : IRoot8698b { }
struct Struct8698b { }
class Class8698b : IClass8698b { alias Struct8698b Value; }
void test8698b(Class8698b.Value) { }
interface IRoot8698b {}
/***************************************************/
// 9514
template TStructHelpers9514a()
{
void opEquals(Foo9514a)
{
auto n = FieldNames9514a!();
}
}
struct Foo9514a
{
mixin TStructHelpers9514a!();
}
import imports.fwdref9514 : find9514; // selective import without aliasing
template FieldNames9514a()
{
static if (find9514!`true`([1])) enum int FieldNames9514a = 1;
}
// ----
template TStructHelpers9514b()
{
void opEquals(Foo9514b)
{
auto n = FieldNames9514b!();
}
}
struct Foo9514b
{
mixin TStructHelpers9514b!();
}
import imports.fwdref9514 : foo9514 = find9514; // selective import with aliasing
template FieldNames9514b()
{
static if (foo9514!`true`([1])) enum int FieldNames9514b = 1;
}
/***************************************************/
// 10015
struct S10015(T) { alias X = int; }
alias Y10015 = s10015.X;
S10015!int s10015;
/***************************************************/
// 10101
int front10101(int);
mixin template reflectRange10101()
{
static if (is(typeof(this.front10101)))
{
int x;
}
}
struct S10101(R)
{
R r_;
typeof(r_.front10101) front10101() @property { return r_.front10101; }
mixin reflectRange10101;
}
void test10101()
{
S10101!(int) s;
}
/***************************************************/
// 11019
class A11019
{
A11019 View() { return null; }
}
class B11019 : A11019
{
override D11019 View() { return null; }
}
class D11019 : B11019 {}
/***************************************************/
// 11166
template Tup11166(T...) { alias Tup11166 = T; }
struct S11166a
{
enum S11166a a = S11166a(0);
enum S11166a b = S11166a(1);
this(long value) { }
long value;
// only triggered when private and a template instance.
private alias types = Tup11166!(a, b);
}
struct S11166b
{
enum S11166b a = S11166b(0);
enum S11166b b = S11166b(1);
// not at the last of members
alias types = Tup11166!(a, b);
this(long value) { }
long value;
}
/***************************************************/
// 12152
class A12152
{
alias Y = B12152.X;
}
class B12152 : A12152
{
alias int X;
}
static assert(is(A12152.Y == int));
/***************************************************/
// 12201
template T12201()
{
alias imports.fwdref12201a.FILE* FP;
}
struct S12201a
{
mixin T12201;
import imports.fwdref12201a;
}
union U12201
{
mixin T12201;
import imports.fwdref12201a;
}
class C12201
{
mixin T12201;
import imports.fwdref12201a;
}
interface I12201
{
mixin T12201;
import imports.fwdref12201a;
}
template TI12201()
{
mixin T12201;
import imports.fwdref12201a;
}
mixin template TM12201()
{
mixin T12201;
import imports.fwdref12201a;
}
struct S12201b
{
alias ti = TI12201!();
mixin TM12201;
}
/***************************************************/
// 12531
struct Node12531(T)
{
T _val;
}
void test12531()
{
static struct Foo
{
Node12531!Foo* node;
}
}
/***************************************************/
// 12543
class C12543;
static assert(C12543.sizeof == (void*).sizeof);
static assert(C12543.alignof == (void*).sizeof);
static assert(C12543.mangleof == "C10testfwdref6C12543");
/***************************************************/
// 14010
enum E14010;
static assert(E14010.mangleof == "E10testfwdref6E14010");
struct S14010;
static assert(S14010.mangleof == "S10testfwdref6S14010");
/***************************************************/
// 12983
alias I12983 = int;
class B12983(T) { alias MyC = C12983!string; }
class C12983(T) : B12983!float
{
void m() { f12983(0); }
}
alias MyB12983 = B12983!float;
void f12983();
void f12983(I12983);
/***************************************************/
// 12984
class B12984a { alias MyD = D12984a!int; }
class C12984a : B12984a { }
class D12984a(T) { alias MyE = E12984a!float; }
class E12984a(T) : D12984a!int
{
void m()
{
auto c = new C12984a();
}
}
static assert(__traits(classInstanceSize, B12984a) == (void*).sizeof * 2);
static assert(__traits(classInstanceSize, C12984a) == (void*).sizeof * 2);
// ----
class B12984b { int b; alias MyD = D12984b!int; }
class C12984b : B12984b { int c; }
class D12984b(T) { int d; alias MyE = E12984b!float; }
class E12984b(T) : D12984b!int
{
int e;
void m()
{
auto c = new C12984b();
}
}
static assert(__traits(classInstanceSize, B12984b) == (void*).sizeof * 2 + int.sizeof);
static assert(__traits(classInstanceSize, C12984b) == (void*).sizeof * 2 + int.sizeof * 2);
/***************************************************/
// 14390
class B14390a { alias MyD = D14390a!int; }
class C14390a : B14390a { void f(int) {} }
class D14390a(T) { alias MyE = E14390a!float; }
class E14390a(T) : D14390a!int { void m() { auto c = new C14390a(); } }
class B14390b { alias MyD = D14390b!int; }
class C14390b : B14390b { static struct S {} }
class D14390b(T) { alias MyE = E14390b!float; }
class E14390b(T) : D14390b!int { void m() { auto c = new C14390b(); } }
/***************************************************/
// 13860
/*
TEST_OUTPUT:
---
pure nothrow @nogc @safe void()
pure nothrow @nogc @safe void()
---
*/
struct Foo13860(Bar...)
{
Bar bars;
auto baz(size_t d)() {}
pragma(msg, typeof(baz!0));
}
auto bar13860(S, R)(S s, R r)
{
pragma(msg, typeof(Foo13860!().baz!0));
}
void test13860()
{
int[] x;
int[] y;
x.bar13860(y);
}
/***************************************************/
// 14083
class NBase14083
{
int foo(NA14083 a) { return 1; }
int foo(NB14083 a) { return 2; }
}
class NA14083 : NBase14083
{
int v;
this(int v) { this.v = v; }
}
class NB14083 : NBase14083
{
override int foo(NA14083 a) { return a.v; }
}
class TBase14083(T)
{
int foo(TA14083!T a) { return 1; }
int foo(TB14083!T a) { return 2; }
}
class TA14083(T) : TBase14083!T
{
T v;
this(T v) { this.v = v; }
}
class TB14083(T) : TBase14083!T
{
override int foo(TA14083!T a) { return a.v; }
}
static assert(
{
NA14083 na = new NA14083(10);
NB14083 nb = new NB14083();
assert(na.foo(na) == 1);
assert(na.foo(nb) == 2);
assert(nb.foo(na) == 10);
TA14083!int ta = new TA14083!int(10);
TB14083!int tb = new TB14083!int();
assert(ta.foo(ta) == 1);
assert(ta.foo(tb) == 2);
assert(tb.foo(ta) == 10);
return true;
}());
/***************************************************/
// 14549
string foo14549(T)()
{
static if (T.tupleof.length >= 0)
return "";
}
class Frop14549
{
mixin(foo14549!(typeof(this)));
static if (__traits(compiles, undefined))
{
}
else
{
int bar = 0;
}
static if (!__traits(isVirtualMethod, this.bar)) {}
}
// ----
// regression case
template Mix14549()
{
mixin(code14549!(typeof(this)));
}
template code14549(T)
{
enum string code14549 =
q{ static if (!__traits(isVirtualMethod, "boo")) {} };
}
class Bar14549
{
mixin Mix14549;
int boo;
}
// ----
// 14609 - regression case
interface Foo14609(T)
{
static if (is(T == int))
public int bar();
}
class Frop14609 : Foo14609!int
{
public int bar() { return 0; }
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc9155.d 0000644 0001750 0001750 00000002501 13200164641 023307 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 9155
module ddoc9155;
/++
+ Note:
+ test document note
+ 2nd line
+ Example:
+ ---
+ import std.stdio; //&
+ writeln("Hello world!");
+ if (test) {
+ writefln("D programming language");
+ }
+
+ algorithm;
+
+ xxx; //comment
+ yyy;
+ /* test
+ * comment
+ */
+
+ // Create MIME Base64 with CRLF, per line 76.
+File f = File("./text.txt", "r");
+uint line = 0;
+ // The ElementType of data is not aggregation type
+foreach (encoded; Base64.encoder(data))
+ ---
+/
/**
--------------------------------------------------------
wstring ws;
transcode("hello world",ws);
// transcode from UTF-8 to UTF-16
--------------------------------------------------------
*/
/**
* Example:
* ---
* import std.stdio; //&
* writeln("Hello world!");
* if (test) {
* writefln("D programming language");
* }
*
* algorithm;
*
* xxx; //comment
* yyy;
* /+ test
* + comment
* +/
* ---
*/
/**
----
#!/usr/bin/env rdmd
// Computes average line length for standard input.
import std.stdio;
----
*/
/**
---
writefln(q"EOS
This
is a multi-line
heredoc string
EOS"
);
---
*/
void foo(){}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ldc_github_257.d 0000644 0001750 0001750 00000000173 13200164641 024556 0 ustar matthias matthias class Baz {
this(Bar[] a) {}
}
class Foo {
Bar[] foo(){ return []; }
}
class Bar {
Foo bar(){ return null; }
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testDIP37_10354.d 0000644 0001750 0001750 00000000333 13200164641 024275 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -o- -Icompilable/extra-files
module testDIP37_10354;
import pkgDIP37_10354.mfoo;
void main()
{
import pkgDIP37_10354;
foo!string(); // OK
bar!string(); // OK <- ICE
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test13858.d 0000644 0001750 0001750 00000000320 13200164641 023437 0 ustar matthias matthias // REQUIRED_ARGS: -w
// 13858
void foo() { assert(0); }
void main()
{
int x = 0;
LSwitch: switch (x)
{
case 0:
break LSwitch;
default: return;
}
foo();
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ldc_github_256.d 0000644 0001750 0001750 00000000105 13200164641 024550 0 ustar matthias matthias bool foo(void delegate() a, void delegate() b) {
return a < b;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test11137.d 0000644 0001750 0001750 00000000112 13200164641 023422 0 ustar matthias matthias // REQUIRED_ARGS: -ofC:\test.exeC:\test.exe
module test;
void main() { }
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test55.d 0000644 0001750 0001750 00000000407 13200164641 023206 0 ustar matthias matthias // COMPILE_SEPARATELY
// EXTRA_SOURCES: imports/test55a.d
// PERMUTE_ARGS: -dw
// REQUIRED_ARGS: -d
public import imports.test55a;
class Queue {
alias int ListHead;
Arm a;
}
class MessageQueue : Queue {
}
class Queue2 {
alias int ListHead;
Arm2 a;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test1673.d 0000644 0001750 0001750 00000002512 13200164641 023354 0 ustar matthias matthias module test1673;
template Foo(T...) { }
template Bar(T...)
{
template Doo(T...)
{
}
}
template Tuple(T...) { alias Tuple = T; }
void main()
{
static assert( __traits(isTemplate, Foo));
static assert(!__traits(isTemplate, Foo!int));
static assert(!__traits(isTemplate, main));
static assert( __traits(isTemplate, Bar));
static assert(!__traits(isTemplate, Bar!int));
static assert( __traits(isTemplate, Bar!(int).Doo));
static assert(!__traits(isTemplate, Bar!(int).Doo!int));
alias Tup = Tuple!(Foo, Foo!int, Bar, Bar!int, Bar!(int).Doo, Bar!(int).Doo!int);
static assert( __traits(isTemplate, Tup[0]));
static assert(!__traits(isTemplate, Tup[1]));
static assert( __traits(isTemplate, Tup[2]));
static assert(!__traits(isTemplate, Tup[3]));
static assert( __traits(isTemplate, Tup[4]));
static assert(!__traits(isTemplate, Tup[5]));
}
/// test overloads
void foo_over() { }
void foo_over(T : int)(T) { }
void foo_over(T : float)(T) { }
static assert(__traits(isTemplate, foo_over));
/// ditto
void bar_over() { }
void bar_over(int) { }
static assert(!__traits(isTemplate, bar_over));
/// alias to overloads
alias a_foo_over = foo_over;
static assert(__traits(isTemplate, a_foo_over));
/// ditto
alias a_bar_over = bar_over;
static assert(!__traits(isTemplate, a_bar_over));
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc198.d 0000644 0001750 0001750 00000000715 13200164641 023232 0 ustar matthias matthias // EXTRA_SOURCES: extra-files/ddoc198.ddoc
// PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 198
module ddoc198;
///
interface I1 { }
///
class C1 { }
///
class Foo : C1, I1 { }
///
enum X { x = 1 }
///
enum Y : X { y = X.x }
///
struct S1 { }
///
enum enS : S1 { a = S1() }
// disabled until class enums are possible
// enum enC : C1 { a = new C1() }
void main()
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test9435.d 0000644 0001750 0001750 00000000333 13200164641 023357 0 ustar matthias matthias import test9434;//expression;
enum TokenType { Dot }
template Tok(string type)
{
enum Tok = TokenType.Dot;
}
template Semantic(T)
{
invariant(){}
}
template Semantic(T) if (is(T == BinaryExp!(Tok!".")))
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test7172.d 0000644 0001750 0001750 00000001500 13200164641 023350 0 ustar matthias matthias void main()
{
abstract class AbstractC{}
static assert(!__traits(compiles, { new AbstractC(); }));
final class FinalC{}
static assert(!__traits(compiles, { class D : FinalC{} }));
scope class ScopeC{}
static assert(!__traits(compiles, { auto sc = new ScopeC(); }));
static assert( __traits(compiles, { scope sc = new ScopeC(); }));
synchronized class SyncC{ void f(){} }
static assert(SyncC.f.mangleof[$-13..$] == "5SyncC1fMOFZv");
@safe class SCx{ void f(){} }
@trusted class SCy{ void f(){} }
@system class SCz{ void f(){} }
static assert(SCx.f.mangleof[$-12..$] == "3SCx1fMFNfZv"); // Nf: FuncAttrSafe
static assert(SCy.f.mangleof[$-12..$] == "3SCy1fMFNeZv"); // Ne: FuncAttrTrusted
static assert(SCz.f.mangleof[$-10..$] == "3SCz1fMFZv"); // (none)
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test13194.d 0000644 0001750 0001750 00000000236 13200164641 023436 0 ustar matthias matthias module test13194;
class C13194
{
static Object o = void;
}
struct S13194
{
static Object o = void;
}
union U13194
{
static Object o = void;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc7715.d 0000644 0001750 0001750 00000000404 13200164641 023307 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 7715
module ddoc7656;
/**
$1 $2
---
string s = "$1$2 $ $4";
---
*/
void foo(){}
///
void test(string a = ")") {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testDIP37_10302.d 0000644 0001750 0001750 00000000333 13200164641 024266 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -c -Icompilable/extra-files
// EXTRA_SOURCES: extra-files/pkgDIP37_10302/liba.d
// EXTRA_SOURCES: extra-files/pkgDIP37_10302/libb.d
module test;
import pkgDIP37_10302;
void main() {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test8922f.d 0000644 0001750 0001750 00000000564 13200164641 023533 0 ustar matthias matthias // PERMUTE_ARGS:
void test()
{
import renamed = imports.bug8922;
enum x = __traits(parent, renamed).stringof;
static assert(x == "package imports");
static assert(!__traits(compiles, __traits(parent, imports)));
static assert(!__traits(compiles, __traits(parent, bug8922)));
static assert(!__traits(compiles, __traits(parent, imports.bug8922)));
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/a3682.d 0000644 0001750 0001750 00000000515 13200164641 022620 0 ustar matthias matthias // EXTRA_SOURCES: imports/b3682.d
// PERMUTE_ARGS:
// 3682
struct Tuple(Types...)
{
Tuple!(Types[0..1]) slice()()
{
Tuple!(Types[0..1]) x;
return x;
}
void fail()
{
Tuple!(float, double, int) a;
auto s = a.slice();
static assert(is(typeof(s) == Tuple!(float)));
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test6319.d 0000644 0001750 0001750 00000000164 13200164641 023357 0 ustar matthias matthias // REQUIRED_ARGS: -debug
int x;
void main() pure
{
debug
{
{
x = 0;
}
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test11225a.d 0000644 0001750 0001750 00000000114 13200164641 023563 0 ustar matthias matthias /*
TEST_OUTPUT:
---
WORKS
---
*/
import imports.test11225b;
interface I {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testlibmain.d 0000644 0001750 0001750 00000000070 13200164641 024364 0 ustar matthias matthias // REQUIRED_ARGS: -lib
// PERMUTE_ARGS:
void main() {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc9305.d 0000644 0001750 0001750 00000004447 13200164641 023317 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 9305
module ddoc9305;
/**
foo()
*/
void foo(alias p = (a => a))() {}
/* ret / prm / body */
/* _ / _ / expr */ template X(alias pred = x => x) {} ///
/* _ / _ / stmt */ template X(alias pred = (x){ int y; return y; }) {} /// ditto
/* _ / x / expr */ template X(alias pred = (int x) => x) {} /// ditto
/* _ / x / stmt */ template X(alias pred = (int x){ int y; return y; }) {} /// ditto
/* x / _ / expr */
/* x / _ / stmt */
/* x / x / expr */
/* x / x / stmt */
/* _ / _ / expr */ template X(alias pred = function (x) => x) {} ///
/* _ / _ / stmt */ template X(alias pred = function (x){ return x + 1; }) {} /// ditto
/* _ / x / expr */ template X(alias pred = function (int x) => x) {} /// ditto
/* _ / x / stmt */ template X(alias pred = function (int x){ return x + 1; }) {} /// ditto
/* x / _ / expr */ template X(alias pred = function int(x) => x) {} /// ditto
/* x / _ / stmt */ template X(alias pred = function int(x){ return x + 1; }) {} /// ditto
/* x / x / expr */ template X(alias pred = function int(int x) => x) {} /// ditto
/* x / x / stmt */ template X(alias pred = function int(int x){ return x + 1; }) {} /// ditto
/* _ / _ / expr */ template X(alias pred = delegate (x) => x) {} ///
/* _ / _ / stmt */ template X(alias pred = delegate (x){ return x + 1; }) {} /// ditto
/* _ / x / expr */ template X(alias pred = delegate (int x) => x) {} /// ditto
/* _ / x / stmt */ template X(alias pred = delegate (int x){ return x + 1; }) {} /// ditto
/* x / _ / expr */ template X(alias pred = delegate int(x) => x) {} /// ditto
/* x / _ / stmt */ template X(alias pred = delegate int(x){ return x + 1; }) {} /// ditto
/* x / x / expr */ template X(alias pred = delegate int(int x) => x) {} /// ditto
/* x / x / stmt */ template X(alias pred = delegate int(int x){ return x + 1; }) {} /// ditto
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test1353.d 0000644 0001750 0001750 00000000320 13200164641 023342 0 ustar matthias matthias
class A {}
interface B {}
interface C {}
interface D(X) {}
void fun()
{
class T : typeof(new A), .B, const(C), D!int {}
version(none)
{
class U : int, float, __vector(int[3]) {}
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test6534.d 0000644 0001750 0001750 00000005073 13200164641 023362 0 ustar matthias matthias void main()
{
class MC{ int x; }
const class CC{ int x; } static assert(is(typeof( CC.x) == const));
immutable class IC{ int x; } static assert(is(typeof( IC.x) == immutable));
shared class SC{ int x; } static assert(is(typeof( SC.x) == shared));
shared const class SCC{ int x; } static assert(is(typeof(SCC.x) == shared) && is(typeof(SCC.x) == const));
struct MS{ int x; }
const struct CS{ int x; } static assert(is(typeof( CS.x) == const));
immutable struct IS{ int x; } static assert(is(typeof( IS.x) == immutable));
shared struct SS{ int x; } static assert(is(typeof( SS.x) == shared));
shared const struct SCS{ int x; } static assert(is(typeof(SCS.x) == shared) && is(typeof(SCS.x) == const));
union MU{ int x; }
const union CU{ int x; } static assert(is(typeof( CU.x) == const));
immutable union IU{ int x; } static assert(is(typeof( IU.x) == immutable));
shared union SU{ int x; } static assert(is(typeof( SU.x) == shared));
shared const union SCU{ int x; } static assert(is(typeof(SCU.x) == shared) && is(typeof(SCU.x) == const));
static class S_MC{ int x; }
const static class S_CC{ int x; } static assert(is(typeof( S_CC.x) == const));
immutable static class S_IC{ int x; } static assert(is(typeof( S_IC.x) == immutable));
shared static class S_SC{ int x; } static assert(is(typeof( S_SC.x) == shared));
shared const static class S_SCC{ int x; } static assert(is(typeof(S_SCC.x) == shared) && is(typeof(S_SCC.x) == const));
static struct S_MS{ int x; }
const static struct S_CS{ int x; } static assert(is(typeof( S_CS.x) == const));
immutable static struct S_IS{ int x; } static assert(is(typeof( S_IS.x) == immutable));
shared static struct S_SS{ int x; } static assert(is(typeof( S_SS.x) == shared));
shared const static struct S_SCS{ int x; } static assert(is(typeof(S_SCS.x) == shared) && is(typeof(S_SCS.x) == const));
static union S_MU{ int x; }
const static union S_CU{ int x; } static assert(is(typeof( S_CU.x) == const));
immutable static union S_IU{ int x; } static assert(is(typeof( S_IU.x) == immutable));
shared static union S_SU{ int x; } static assert(is(typeof( S_SU.x) == shared));
shared const static union S_SCU{ int x; } static assert(is(typeof(S_SCU.x) == shared) && is(typeof(S_SCU.x) == const));
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/warn3882.d 0000644 0001750 0001750 00000002511 13200164641 023347 0 ustar matthias matthias // PERMUTE_ARGS: -w -wi -debug
/*
TEST_OUTPUT:
---
---
*/
@safe pure nothrow void strictVoidReturn(T)(T x) {}
@safe pure nothrow void nonstrictVoidReturn(T)(ref T x) {}
void test3882()
{
int x = 3;
strictVoidReturn(x);
nonstrictVoidReturn(x);
}
/******************************************/
// 12619
extern (C) @system nothrow pure void* memcpy(void* s1, in void* s2, size_t n);
// -> weakly pure
void test12619() pure
{
ubyte[10] a, b;
debug memcpy(a.ptr, b.ptr, 5); // memcpy call should have side effect
}
/******************************************/
// 12760
struct S12760(T)
{
T i;
this(T j) inout {}
}
struct K12760
{
S12760!int nullable;
this(int)
{
nullable = 0; // weak purity
}
}
/******************************************/
// 12909
int f12909(immutable(int[])[int] aa) pure nothrow
{
//aa[0] = []; // fix for issue 13701
return 0;
}
void test12909()
{
immutable(int[])[int] aa;
f12909(aa);
// from 12910
const(int[])[int] makeAA() { return null; } // to make r-value
makeAA().rehash();
}
/******************************************/
// 13899
const struct Foo13899
{
int opApply(immutable int delegate(in ref int) pure nothrow dg) pure nothrow
{
return 1;
}
}
void test13899()
{
foreach (x; Foo13899())
{
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice13088.d 0000644 0001750 0001750 00000000302 13200164641 023213 0 ustar matthias matthias // REQUIRED_ARGS: -o-
// PERMUTE_ARGS:
struct X
{
void mfoo(this T)() {}
}
void test()
{
shared const X scx;
scx.mfoo();
}
struct Vec
{
int x;
void sc() shared const {}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test4364.d 0000644 0001750 0001750 00000000207 13200164641 023353 0 ustar matthias matthias struct Object{}
class Game {}
void main()
{
static assert(is(Object == struct));
static assert(is(object.Object == class));
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc7555.d 0000644 0001750 0001750 00000001426 13200164641 023316 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 7555
module ddoc7555;
/**
Dummy doc.
$(X0
DelimitedString
TokenString)
$(X1
DelimitedString
TokenString)
$(X2 x,HexString)
$(X2 x, HexString)
$(X3 x,x,HexString)
$(X3 x,x, HexString)
$(X4 x,x,x,HexString)
$(X4 x,x,x, HexString)
$(X5 x,x,x,x,HexString)
$(X5 x,x,x,x, HexString)
$(X6 x,x,x,x,x,HexString)
$(X6 x,x,x,x,x, HexString)
$(X7 x,x,x,x,x,x,HexString)
$(X7 x,x,x,x,x,x, HexString)
$(X8 x,x,x,x,x,x,x,HexString)
$(X8 x,x,x,x,x,x,x, HexString)
$(X9 x,x,x,x,x,x,x,x,HexString)
$(X9 x,x,x,x,x,x,x,x, HexString)
Macros:
X0=$0
X1=$1
X2=$2
X3=$3
X4=$4
X5=$5
X6=$6
X7=$7
X8=$8
X9=$9
*/
void dummy();
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test10992.d 0000644 0001750 0001750 00000000260 13200164641 023436 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -unittest
unittest { }
unittest { }
unittest { }
void main()
{
static assert(__traits(getUnitTests, mixin(__MODULE__)).length == 3);
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/json.d 0000644 0001750 0001750 00000003673 13200164641 023036 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -o- -X -Xf${RESULTS_DIR}/compilable/json.out
// POST_SCRIPT: compilable/extra-files/json-postscript.sh
module json;
static this() {}
static ~this() {}
alias int myInt;
myInt x; // bug 3404
struct Foo(T) { T t; }
class Bar(int T) { int t = T; }
interface Baz(T...) { T[0] t() const; } // bug 3466
template P(alias T) {}
class Bar2 : Bar!1, Baz!(int, 2, null) {
this() {}
~this() {} // bug 4178
static foo() {}
protected abstract Foo!int baz();
override int t() const { return 0; }
}
class Bar3 : Bar2 {
private int val;
this(int i) { val = i; }
protected override Foo!int baz() { return Foo!int(val); }
}
struct Foo2 {
Bar2 bar2;
union U {
struct {
short s;
int i;
}
Object o;
}
}
/++
+ Documentation test
+/
@trusted myInt bar(ref uint blah, Bar2 foo = new Bar3(7)) // bug 4477
{
return -1;
}
@property int outer() nothrow
in {
assert(true);
}
out(result) {
assert(result == 18);
}
body {
int x = 8;
int inner(void* v) nothrow
{
int y = 2;
assert(true);
return x + y;
}
int z = inner(null);
return x + z;
}
/** Issue 9484 - selective and renamed imports */
import imports.jsonimport1 : target1, target2;
import imports.jsonimport2 : alias1 = target1, alias2 = target2;
import imports.jsonimport3 : alias3 = target1, alias4 = target2, target3;
import imports.jsonimport4;
struct S
{
/** Issue 9480 - Template name should be stripped of parameters */
this(T)(T t) { }
}
/** Issue 9755 - Protection not emitted properly for Templates. */
private struct S1_9755(T) { }
package struct S2_9755(T) { }
class C_9755
{
protected static class CI_9755(T) { }
}
/** Issue 10011 - init property is wrong for object initializer. */
const Object c_10011 = new Object();
///
enum Numbers
{
unspecified1,
one = 2,
two = 3,
FILE_NOT_FOUND = 101,
unspecified3,
unspecified4,
four = 4,
}
template IncludeConstraint(T) if (T == string) {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc10325.d 0000644 0001750 0001750 00000000417 13200164641 023362 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 10325
module ddoc10325;
/** */
template templ(T...)
if (someConstraint!T)
{
}
/** */
void foo(T)(T t)
if (someConstraint!T)
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test7569.d 0000644 0001750 0001750 00000000137 13200164641 023367 0 ustar matthias matthias template Tuple(T...)
{
alias T Tuple;
}
void main()
{
Tuple!(int, int) tup1 = void;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc12706.d 0000644 0001750 0001750 00000000274 13200164641 023370 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 12706
///
void test()(string[] args) if (args[$])
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test10066.d 0000644 0001750 0001750 00000002243 13200164641 023431 0 ustar matthias matthias void main()
{
alias Zoo = Foo!(1);
}
struct Foo(size_t N)
{
string bar()
{
Appender!(string) w;
char[] buf; put(w, buf);
return "";
}
public bool opEquals(T)(T other) const
// Add const, different from bug 10056
{
alias Foo!(typeof(this), T, "CMP") P;
return false;
}
}
template Foo(T, U, string OP)
{
static if (T.ISEMPTY && U.ISEMPTY)
enum bool S = false;
else
enum bool S = false;
alias Foo = Foo!(0);
}
/**********************************************/
void put(R, E)(ref R r, E e)
{
static if (is(typeof(r.put(e))))
{
r.put(e);
}
else
{
static assert(false, "Cannot put a "~E.stringof~" into a "~R.stringof);
}
}
struct Appender(A : T[], T)
{
private template canPutItem(U)
{
enum bool canPutItem = is(U : T);
}
private template canPutRange(R)
{
enum bool canPutRange = is(typeof(Appender.init.put(R.init[0])));
}
void put(U)(U item) if (canPutItem!U)
{
char[T.sizeof == 1 ? 4 : 2] encoded;
put(encoded[]);
}
void put(R)(R items) if (canPutRange!R)
{
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testpostblit.d 0000644 0001750 0001750 00000000217 13200164641 024614 0 ustar matthias matthias struct Test1a
{
this(this)
{
}
}
struct Test1b
{
Test1a a;
}
struct Test1c
{
const Test1b b;
@disable this(this);
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test67.d 0000644 0001750 0001750 00000000124 13200164641 023205 0 ustar matthias matthias // PERMUTE_ARGS:
import imports.test67a;
interface I
{
}
interface SubI : I
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test7065.d 0000644 0001750 0001750 00000002301 13200164641 023351 0 ustar matthias matthias void main()
{
align(1)
struct X1 { ubyte b; int n; }
static assert(X1.sizeof == 8);
static assert(X1.b.offsetof == 0);
static assert(X1.n.offsetof == 4);
//X1 x1;
//assert(cast(void*)&x1.b == cast(void*)&x1 + 0);
//assert(cast(void*)&x1.n == cast(void*)&x1 + 1);
struct Y1 { ubyte b; int n; }
static assert(Y1.sizeof == 8);
static assert(Y1.b.offsetof == 0);
static assert(Y1.n.offsetof == 4);
//Y1 y1;
//assert(cast(void*)&y1.b == cast(void*)&y1 + 0);
//assert(cast(void*)&y1.n == cast(void*)&y1 + 4);
int local;
align(1)
struct X2 { ubyte b; int n; int f(){ return local; } }
static assert(X2.sizeof == 8 + (void*).sizeof);
static assert(X2.b.offsetof == 0);
static assert(X2.n.offsetof == 4);
//X2 x2;
//assert(cast(void*)&x2.b == cast(void*)&x2 + 0);
//assert(cast(void*)&x2.n == cast(void*)&x2 + 1);
struct Y2 { ubyte b; int n; int f(){ return local; } }
static assert(Y2.sizeof == 8 + (void*).sizeof);
static assert(Y2.b.offsetof == 0);
static assert(Y2.n.offsetof == 4);
//Y2 y2;
//assert(cast(void*)&y2.b == cast(void*)&y2 + 0);
//assert(cast(void*)&y2.n == cast(void*)&y2 + 4);
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/sw_transition_tls.d 0000644 0001750 0001750 00000000345 13200164641 025643 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -c -transition=tls
/*
TEST_OUTPUT:
---
compilable/sw_transition_tls.d(11): x is thread local
compilable/sw_transition_tls.d(15): y is thread local
---
*/
int x;
struct S
{
static int y;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test9692.d 0000644 0001750 0001750 00000000272 13200164641 023366 0 ustar matthias matthias module test9692;
import test9692a;
import imports.test9692b;
enum x = [__traits(allMembers, imports.test9692b)]; // ok
enum y = [__traits(allMembers, test9692a)]; // ng: should work
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice10040.d 0000644 0001750 0001750 00000000344 13200164641 023202 0 ustar matthias matthias struct MsgProc1 { mixin MsgMixin; }
struct MsgProc2 { mixin MsgMixin; }
struct MsgHeader {}
template MsgMixin()
{
mixin(mixinMembers!(MsgHeader.init));
}
string mixinMembers(T ...)()
{
struct Op {}
return null;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test4003.d 0000644 0001750 0001750 00000000141 13200164641 023336 0 ustar matthias matthias // EXTRA_SOURCES: imports/test4003a.d
// PERMUTE_ARGS:
import imports.stdio4003;
void main(){}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test7491.d 0000644 0001750 0001750 00000002522 13200164641 023361 0 ustar matthias matthias struct Struct
{
import object;
import imports.test7491a;
import renamed=imports.test7491b;
}
struct AliasThis
{
Struct _struct;
alias _struct this;
}
class Base
{
import object;
import imports.test7491a;
import renamed=imports.test7491b;
}
class Derived : Base
{
}
interface Interface
{
import object;
import imports.test7491a;
import renamed=imports.test7491b;
}
class Impl : Interface
{
}
static assert(__traits(compiles, Struct.object));
static assert(__traits(compiles, Struct.imports));
static assert(__traits(compiles, Struct.renamed));
static assert(__traits(compiles, AliasThis.object));
static assert(__traits(compiles, AliasThis.imports));
static assert(__traits(compiles, AliasThis.renamed));
static assert(__traits(compiles, Base.object));
static assert(__traits(compiles, Base.imports));
static assert(__traits(compiles, Base.renamed));
static assert(__traits(compiles, Derived.object));
static assert(__traits(compiles, Derived.imports));
static assert(__traits(compiles, Derived.renamed));
static assert(__traits(compiles, Interface.object));
static assert(__traits(compiles, Interface.imports));
static assert(__traits(compiles, Interface.renamed));
static assert(__traits(compiles, Impl.object));
static assert(__traits(compiles, Impl.imports));
static assert(__traits(compiles, Impl.renamed));
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test11471.d 0000644 0001750 0001750 00000000157 13200164641 023434 0 ustar matthias matthias // REQUIRED_ARGS: -profile
void main() nothrow
{ asm { nop; } } // Error: asm statements are assumed to throw
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc10870.d 0000644 0001750 0001750 00000000265 13200164641 023370 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 10870
///
interface I
{
///
void f();
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/fail260.d 0000644 0001750 0001750 00000001211 13200164641 023212 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -d
struct Static(uint width2, uint height2)
{
immutable width = width2;
immutable height = height2;
static Static opCall()
{
Static ret;
return ret;
}
alias float E;
template MultReturn(alias M1, alias M2)
{
alias Static!(M2.width, M1.height) MultReturn;
}
void opMultVectors(M2)(M2 b)
{
alias MultReturn!(Static, M2) ret_matrix;
}
}
void test()
{
alias Static!(4, 1) matrix_stat;
static matrix_stat m4 = matrix_stat();
alias Static!(1, 4) matrix_stat2;
static m6 = matrix_stat2();
m6.opMultVectors(m4);
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ldc_github_791.d 0000644 0001750 0001750 00000000063 13200164641 024557 0 ustar matthias matthias int crash()
{
asm
{
naked;
ret;
};
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice11610.d 0000644 0001750 0001750 00000004000 13200164641 023177 0 ustar matthias matthias
struct Token
{
TokenType type;
}
enum TokenType : ushort
{
invalid
}
class Parser
{
bool peekIsOneOf(TokenType[] types...)
{
canFind(types, tokens[1].type);
return true;
}
Token[] tokens;
}
/*************************************************/
// std.algorithm
R find(alias pred = "a == b", R, E)(R haystack, E needle)
{
enum isIntegralNeedle = isSomeChar!E/* || isIntegral!E || isBoolean!E*/;
return haystack;
}
bool canFind(alias pred = "a == b", R, E)(R haystack, E needle)
if (is(typeof(find!pred(haystack, needle)))) // 1st instantiate of find template with error gagging
{
return find!pred(haystack, needle).length != 0; // 2nd instantiate of find template without gagging
}
/*************************************************/
// std.traits
template CharTypeOf(T)
{
inout( char) idx( inout( char) );
inout(wchar) idx( inout(wchar) );
inout(dchar) idx( inout(dchar) );
shared(inout char) idx( shared(inout char) );
shared(inout wchar) idx( shared(inout wchar) );
shared(inout dchar) idx( shared(inout dchar) );
static if (is(T == enum))
{
/* This line instantiates CharTypeOf!short and will make error.
* But, when CharTypeOf!short is re-instantiated without gagging,
* that's for correct error report, its 'members' does not re-created.
* so, members' semantic will call FuncDeclaration::overloadInsert of
* 'idx' functions, and will make circular linked list of
* FuncDeclaration::overnext. Finally, iterating it will cause
* infinite recursion and compiler segfault.
*/
alias .CharTypeOf!(OriginalType!T) CharTypeOf;
}
else static if (is(typeof(idx(T.init)) X))
{
alias X CharTypeOf;
}
else
static assert(0, T.stringof~" is not a character type");
}
template isSomeChar(T)
{
enum isSomeChar = is(CharTypeOf!T);
}
template OriginalType(T)
{
alias OriginalType = ushort;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/b33.d 0000644 0001750 0001750 00000000211 13200164641 022435 0 ustar matthias matthias // EXTRA_SOURCES: imports/b33a.d
// PERMUTE_ARGS:
module b33;
private import imports.b33a;
size_t fn()
{
return find( "123" );
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ldc_aggregate.d 0000644 0001750 0001750 00000000236 13200164641 024625 0 ustar matthias matthias
union A
{
TypeInfo info;
void[0] result;
}
struct B
{
TypeInfo info;
void[0] result;
}
class C
{
TypeInfo info;
void[0] result;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc9497c.d 0000644 0001750 0001750 00000000374 13200164641 023471 0 ustar matthias matthias // EXTRA_SOURCES: extra-files/ddoc9497c.ddoc
// PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 9497c
/**
foo function.
Args: $(XYZ arg1, arg2)
*/
void foo()
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc9497d.d 0000644 0001750 0001750 00000000374 13200164641 023472 0 ustar matthias matthias // EXTRA_SOURCES: extra-files/ddoc9497d.ddoc
// PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 9497d
/**
foo function.
Args: $(XYZ arg1, arg2)
*/
void foo()
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice10598.d 0000644 0001750 0001750 00000000112 13200164641 023215 0 ustar matthias matthias // EXTRA_SOURCES: imports/ice10598a.d imports/ice10598b.d
void main() {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testheader12567b.d 0000644 0001750 0001750 00000000334 13200164641 024753 0 ustar matthias matthias // REQUIRED_ARGS: -o- -H -Hf${RESULTS_DIR}/compilable/header12567b.di
// PERMUTE_ARGS:
// POST_SCRIPT: compilable/extra-files/header-postscript.sh header12567b
deprecated("message") module header12567b;
void main() {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test7030.d 0000644 0001750 0001750 00000001333 13200164641 023345 0 ustar matthias matthias extern(C++)
{
struct S
{
void foo(int) const;
void bar(int);
static __gshared int boo;
}
}
// DMD adds the extra underscore that is required for platform ABI compliance
// to the mangleof string, see https://issues.dlang.org/show_bug.cgi?id=8207 and
// LDC GitHub issue #114.
version (DigitalMars) version (OSX) version = DMD_OSX;
version (DMD_OSX)
{
static assert(S.foo.mangleof == "__ZNK1S3fooEi");
static assert(S.bar.mangleof == "__ZN1S3barEi");
static assert(S.boo.mangleof == "__ZN1S3booE");
}
else version (Posix)
{
static assert(S.foo.mangleof == "_ZNK1S3fooEi");
static assert(S.bar.mangleof == "_ZN1S3barEi");
static assert(S.boo.mangleof == "_ZN1S3booE");
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/iasm_labeloperand.d 0000644 0001750 0001750 00000001557 13200164641 025525 0 ustar matthias matthias // LLVM mach-o backend: "32-bit absolute addressing is not supported in 64-bit mode"
version (LDC) version(OSX) version = LDC_OSX;
version (LDC_OSX) {} else
version (D_InlineAsm_X86)
version = TestInlineAsm;
else version (D_InlineAsm_X86_64)
version = TestInlineAsm;
else
pragma(msg, "Inline asm not supported, not testing.");
version (TestInlineAsm)
{
void testInlineAsm()
{
asm
{
L1:
nop;
nop;
nop;
nop;
mov EAX, dword ptr L1; // Check back references
mov EAX, dword ptr L2; // Check forward references
mov EAX, dword ptr DS:L1; // Not really useful in standard use, but who knows.
mov EAX, dword ptr FS:L2; // Once again, not really useful, but it is valid.
mov EAX, dword ptr CS:L1; // This is what the first test case should implicitly be.
L2:
nop;
nop;
nop;
nop;
}
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc9.d 0000644 0001750 0001750 00000000651 13200164641 023060 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 9
// 273
/// Template Documentation (OK)
template Template(T) { }
/// Function Documentation (Not included at all by DDoc)
void Function(T)(T x) { }
/// Class Documentation (OK)
class Class(T) { }
/// Struct Documentation
struct Struct(T) { }
/// Union Documentation
union Union(T) { }
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice11925.d 0000644 0001750 0001750 00000000562 13200164641 023221 0 ustar matthias matthias void test11925a()
{
try
{
try
{
L1: {}
}
finally
{
}
}
finally
{
}
goto L1;
}
void test11925b()
{
switch (1)
{
case 1:
goto L1;
break;
default:
break;
}
try
{
L1: { }
}
finally
{
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test10752.d 0000644 0001750 0001750 00000000206 13200164641 023430 0 ustar matthias matthias import imports.test10752;
void main()
{
static assert(!__traits(compiles, priv));
static assert(!__traits(compiles, priv));
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc7795.d 0000644 0001750 0001750 00000000514 13200164641 023321 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 7795
module ddoc7795;
struct TimeValue {
this(int hour, int minute, int second = 0, int ms = 0) {}
}
///
struct DateTime {
///
this(TimeValue t = TimeValue(0, 0)) {}
}
void main() { }
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ldc_github_982.d 0000644 0001750 0001750 00000000130 13200164641 024554 0 ustar matthias matthias import std.datetime;
void main() {
auto r = cast(Duration[2])benchmark!({},{})(1);
} ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ldc_github_637.d 0000644 0001750 0001750 00000000076 13200164641 024562 0 ustar matthias matthias extern(C):
struct Value
{
this(string) {}
string s;
} ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc9727.d 0000644 0001750 0001750 00000000544 13200164641 023321 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 9727
module ddoc9727;
/** The function foo. */
void foo(int x);
/** */
unittest
{
foo(1);
}
/** foo can be used like this: */
unittest
{
foo(2);
}
/** foo can also be used like this: */
unittest
{
foo(3);
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test8922b.d 0000644 0001750 0001750 00000000345 13200164641 023524 0 ustar matthias matthias // PERMUTE_ARGS:
void test()
{
import imports.bug8922;
static assert(!__traits(compiles, __traits(parent, imports)));
enum x = __traits(parent, imports.bug8922).stringof;
static assert(x == "package imports");
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc6491.d 0000644 0001750 0001750 00000000425 13200164641 023312 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 6491
module ddoc6491;
import core.cpuid;
enum int c6491 = 4;
/// test
void bug6491a(int a = ddoc6491.c6491, string b = core.cpuid.vendor);
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test8922a.d 0000644 0001750 0001750 00000000341 13200164641 023517 0 ustar matthias matthias // PERMUTE_ARGS:
import imports.bug8922;
void test()
{
static assert(!__traits(compiles, __traits(parent, imports)));
enum x = __traits(parent, imports.bug8922).stringof;
static assert(x == "package imports");
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddocunittest.d 0000644 0001750 0001750 00000015736 13200164641 024601 0 ustar matthias matthias // PERMUTE_ARGS: -unittest
// REQUIRED_ARGS: -D -w -o- -c -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh unittest
module ddocunittest;
/* Insert test-cases for documented unittests feature here. */
/// foo function - 1 example
int foo(int a, int b) { return a + b; }
///
unittest
{
assert(foo(1, 1) == 2);
}
/// bar function - 1 example
bool bar() { return true; }
///
unittest
{
// documented
assert(bar());
}
/// placeholder
unittest
{
}
/// doo function - no examples
void doo() { }
///
private unittest
{
// undocumented
doo();
}
unittest
{
// undocumented
doo();
}
/**
add function - 3 examples
Examples:
----
assert(add(1, 1) == 2);
----
*/
int add(int a, int b) { return a + b; }
///
unittest
{
// documented
assert(add(3, 3) == 6);
assert(add(4, 4) == 8);
}
unittest
{
// undocumented
assert(add(2, 2) + add(2, 2) == 8);
}
///
unittest
{
// documented
assert(add(5, 5) == 10);
assert(add(6, 6) == 12);
}
/// class Foo
immutable pure nothrow class Foo
{
int x;
///
unittest
{
// another foo example
Foo foo = new Foo;
}
}
///
unittest
{
Foo foo = new Foo;
}
pure
{
const
{
immutable
{
/// some class - 1 example
class SomeClass {}
}
}
}
///
unittest
{
SomeClass sc = new SomeClass;
}
/// Outer - 1 example
class Outer
{
/// Inner
static class Inner
{
}
///
unittest
{
Inner inner = new Inner;
}
}
///
unittest
{
Outer outer = new Outer;
}
/** foobar - no examples */
void foobar()
{
}
unittest
{
foobar();
}
/**
func - 4 examples
Examples:
---
foo(1);
---
Examples:
---
foo(2);
---
*/
void foo(int x) { }
///
unittest
{
foo(2);
}
///
unittest
{
foo(4);
}
// ------------------------------------
// insert import declaration between documented function and unittests
///
void fooImport() {}
import core.stdc.stdio;
/// test
unittest { fooImport(); }
///
void fooStaticImport() {}
static import core.stdc.stdlib;
/// test
unittest { fooStaticImport(); }
///
void fooPublicImport() {}
public import core.stdc.string;
/// test
unittest { fooPublicImport(); }
///
void fooSelectiveImport() {}
import core.stdc.ctype : isalpha;
/// test
unittest { fooSelectiveImport(); }
///
void fooRenamedImport() {}
import io = core.stdc.stdio;
/// test
unittest { fooRenamedImport(); }
// ------------------------------------
// documented unittest after conditional declarations
static if (true)
void fooConditionalDecl1a() {} /** */
unittest { int x1a; } ///
static if (true)
{ void fooConditionalDecl1b() {} /** */ }
unittest { int x1b; } ///
static if (false)
void fooConditionalDecl2a() {} /** */
unittest { int x2a; } ///
static if (false)
{ void fooConditionalDecl2b() {} /** */ }
unittest { int x2b; } ///
static if (true)
{ void fooConditionalDecl3a() {} /** */ }
else
{ void barConditionalDecl3a() {} /** */ }
unittest { int x3a; } ///
static if (true)
{ void fooConditionalDecl3b() {} /** */ }
else
{ void barConditionalDecl3b() {} /** */ }
unittest { int x3b; } ///
static if (false)
void fooConditionalDecl4a() {} /** */
else
void barConditionalDecl4a() {} /** */
unittest { int x4a; } ///
static if (false)
{ void fooConditionalDecl4b() {} /** */ }
else
{ void barConditionalDecl4b() {} /** */ }
unittest { int x4b; } ///
static if (true)
{}
else
void barConditionalDecl5a() {} /** */
unittest { int x5a; } ///
static if (true)
{}
else
{ void barConditionalDecl5b() {} /** */ }
unittest { int x5b; } ///
static if (false)
{}
else
void barConditionalDecl6a() {} /** */
///
unittest { int x6a; }
static if (false)
{}
else
{ void barConditionalDecl6b() {} /** */ }
///
unittest { int x6b; }
// ------------------------------------
// 9474
///
void foo9474() { }
version(none)
unittest { }
/// Example
unittest { foo9474(); }
/// doc
void bar9474() { }
version(none)
unittest { }
/// Example
unittest { bar9474(); }
///
struct S9474
{
}
///
unittest { S9474 s; }
///
auto autovar9474 = 1;
///
unittest { int v = autovar9474; }
///
auto autofun9474() { return 1; }
///
unittest { int n = autofun9474(); }
///
template Template9474()
{
/// Shouldn't link following unittest to here
void foo() {}
}
///
unittest { alias Template9474!() T; }
// ------------------------------------
// 9713
///
void fooNoDescription() {}
///
unittest { fooNoDescription(); }
///
unittest { if (true) {fooNoDescription(); } /* comment */ }
// ------------------------------------
/// test for bugzilla 9757
void foo9757() {}
/// ditto
void bar9757() {}
/// ditto
void baz9757() {}
///
unittest { foo9757(); bar9757(); }
///
unittest { bar9757(); foo9757(); }
/// with template functions
auto redBlackTree(E)(E[] elems...)
{
return 1;
}
/// ditto
auto redBlackTree(bool allowDuplicates, E)(E[] elems...)
{
return 2;
}
/// ditto
auto redBlackTree(alias less, E)(E[] elems...)
{
return 3;
}
///
unittest
{
auto rbt1 = redBlackTree(0, 1, 5, 7);
auto rbt2 = redBlackTree!string("hello", "world");
auto rbt3 = redBlackTree!true(0, 1, 5, 7, 5);
auto rbt4 = redBlackTree!"a > b"(0, 1, 5, 7);
}
// ------------------------------------
// Issue 9758
/// test
void foo(){}
///
unittest { }
// ------------------------------------
// Issue 10519
///
bool balancedParens10519(string, char, char) { return true; }
///
unittest
{
auto s = "1 + (2 * (3 + 1 / 2)";
assert(!balancedParens10519(s, '(', ')'));
}
// ------------------------------------
// Issue 12097
/// declaration
struct S12097
{
/// method
void foo() {}
}
/// ditto
void f12097() {}
/// ddoc code 1
unittest
{
int a = 1;
}
/// ditto
struct T12097(T) {}
/// ddoc code 2
unittest
{
int[] arr;
}
// ------------------------------------
// 14594
/*******************
* testA
*/
void fun14594a()() {}
///
unittest { fun14594a(); }
/*******************
* testB
*/
void fun14594b()() {}
/// ditto
void fun14594b(T)(T) {}
///
unittest { fun14594b(); fun14594b(1); }
/*******************
* testC
*/
void fun14594c()() {}
///
unittest { fun14594c(); fun14594c(1); }
/// ditto
void fun14594c(T)(T) {}
/*******************
* testD
*/
void fun14594d()() {}
///
unittest { fun14594d(); }
/// ditto
void fun14594d(T)(T) {}
///
unittest { fun14594d(1); }
/*******************
* testE
*/
template fun14594e()
{
/// concatenated doc-comment fun14594e
void fun14594e() {}
/// ignored-unittest fun14594e
unittest { fun14594e(); }
}
/// doc-unittest fun14594e
unittest { fun14594e(); }
/*******************
* testF
*/
template fun14594f()
{
/// concatenated doc-comment fun14594f
void fun14594f() {}
/// ignored-unittest fun14594f
unittest { fun14594f(); }
}
/// ditto
template fun14594f(T)
{
/// ignored doc-comment fun14594f
void fun14594f(T) {}
/// ignored-unittest fun14594f
unittest { fun14594f(1); }
}
/// doc-unittest fun14594f
unittest { fun14594f(); }
// ------------------------------------
void main() { }
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/bug11735.d 0000644 0001750 0001750 00000001211 13200164641 023225 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS:
/*
TEST_OUTPUT:
---
print string
print wstring
print dstring
يطبع الترميز Ø§Ù„Ù…ÙˆØØ¯
يطبع الترميز Ø§Ù„Ù…ÙˆØØ¯
يطبع الترميز Ø§Ù„Ù…ÙˆØØ¯
foo_str
foo_wstr
foo_dstr
---
*/
pragma(msg, "print string");
pragma(msg, "print wstring"w);
pragma(msg, "print dstring"d);
pragma(msg, "يطبع الترميز Ø§Ù„Ù…ÙˆØØ¯");
pragma(msg, "يطبع الترميز Ø§Ù„Ù…ÙˆØØ¯"w);
pragma(msg, "يطبع الترميز Ø§Ù„Ù…ÙˆØØ¯"d);
void main()
{
enum a = "foo_str";
enum b = "foo_wstr"w;
enum c = "foo_dstr"d;
pragma(msg, a);
pragma(msg, b);
pragma(msg, c);
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test15056.d 0000644 0001750 0001750 00000000562 13200164641 023437 0 ustar matthias matthias nothrow:
version (Windows)
{
version (LP_64)
import core.stdc.stdlib;
else
// doesn't currently work b/c SEH remains present even in nothrow code
void* alloca(size_t) { return null; }
}
else
import core.stdc.stdlib;
struct S
{
~this() nothrow {}
}
S foo(void* p = alloca(1234))
{
return S();
}
int main()
{
foo();
return 0;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ldc_github_1292.d 0000644 0001750 0001750 00000000271 13200164641 024635 0 ustar matthias matthias void main()
{
fun();
}
void fun()
{
double x0 = 0,
x1 = 1;
asm nothrow @nogc
{
movlpd qword ptr x0, XMM0;
movhpd qword ptr x1, XMM0;
}
} ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice8392.d 0000644 0001750 0001750 00000000176 13200164641 023146 0 ustar matthias matthias // EXTRA_SOURCES: imports/a8392.d
module ice8392;
struct A
{
}
auto fooa(alias handler)(A a)
{
return handler(null);
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/protection.d 0000644 0001750 0001750 00000005737 13200164641 024256 0 ustar matthias matthias import imports.protectionimp;
alias TypeTuple(T...) = T;
private
{
void localF() {}
class localC {}
struct localS {}
union localU {}
interface localI {}
enum localE { foo }
mixin template localMT() {}
class localTC(T) {}
struct localTS(T) {}
union localTU(T) {}
interface localTI(T) {}
void localTF(T)() {}
}
void main()
{
// Private non-template declarations
static assert(!__traits(compiles, privF()));
static assert(!__traits(compiles, privC));
static assert(!__traits(compiles, privS));
static assert(!__traits(compiles, privU));
static assert(!__traits(compiles, privI));
static assert(!__traits(compiles, privE));
static assert(!__traits(compiles, privMT));
// Private local non-template declarations.
static assert( __traits(compiles, localF()));
static assert( __traits(compiles, localC));
static assert( __traits(compiles, localS));
static assert( __traits(compiles, localU));
static assert( __traits(compiles, localI));
static assert( __traits(compiles, localE));
static assert( __traits(compiles, localMT));
// Private template declarations.
static assert(!__traits(compiles, privTF!int()));
static assert(!__traits(compiles, privTC!int));
static assert(!__traits(compiles, privTS!int));
static assert(!__traits(compiles, privTU!int));
static assert(!__traits(compiles, privTI!int));
// Private local template declarations.
static assert( __traits(compiles, localTF!int()));
static assert( __traits(compiles, localTC!int));
static assert( __traits(compiles, localTS!int));
static assert( __traits(compiles, localTU!int));
static assert( __traits(compiles, localTI!int));
// Public template function with private type parameters.
static assert(!__traits(compiles, publF!privC()));
static assert(!__traits(compiles, publF!privS()));
static assert(!__traits(compiles, publF!privU()));
static assert(!__traits(compiles, publF!privI()));
static assert(!__traits(compiles, publF!privE()));
// Public template function with private alias parameters.
static assert(!__traits(compiles, publFA!privC()));
static assert(!__traits(compiles, publFA!privS()));
static assert(!__traits(compiles, publFA!privU()));
static assert(!__traits(compiles, publFA!privI()));
static assert(!__traits(compiles, publFA!privE()));
// Private alias.
static assert(!__traits(compiles, privA));
// Public template mixin.
static assert( __traits(compiles, publMT));
}
/***************************************************/
// 14169
template staticMap14169(alias fun, T...)
{
static if (T.length > 0)
alias staticMap14169 = TypeTuple!(fun!(T[0]), staticMap14169!(fun, T[1..$]));
else
alias staticMap14169 = TypeTuple!();
}
class C14169
{
private struct InnerStruct(string NameS)
{
alias Name = NameS;
}
alias DimensionNames = staticMap14169!(GetName14169, InnerStruct!"A");
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test12979a.d 0000644 0001750 0001750 00000000111 13200164641 023601 0 ustar matthias matthias void parse()
{
asm pure nothrow @nogc @trusted {}
asm @safe {}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc7.d 0000644 0001750 0001750 00000001232 13200164641 023052 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 7
//-----------------------------------------------
/// my enum
enum E1
{
A, /// element a
B /// element b
}
/// my enum
enum E2
{
/// element a
A,
/// element b
B
}
/// my enum
enum E3
{
A /// element a
, B /// element b
}
/// my enum
enum E4
{
A /// element a
,
B /// element b
}
/// my enum
enum E5
{
/// element a
A
,
/// element b
B
}
/// Some doc
void foo() {}
/// More doc
alias foo bar;
/// asdf
class C
{
/// Some doc
abstract void foo();
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test14781.d 0000644 0001750 0001750 00000001274 13200164641 023444 0 ustar matthias matthias // REQUIRED_ARGS: -o-
// PERMUTE_ARGS:
void impure() {} // impure
auto fb1(T)() pure
{
int x;
struct A(S)
{
void fc(T2)()
{
x = 1; // accessing pure function context is just ok
impure(); // impure function call makes fc as impure
}
this(S a) {}
}
return A!int();
}
auto fb2(T)() pure
{
int x;
struct A(S)
{
void fc(T2)()
{
impure(); // impure function call makes fc as impure
x = 1; // accessing pure function context is just ok
}
this(S a) {}
}
return A!int();
}
void test1()
{
fb1!int().fc!int();
fb2!int().fc!int();
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test12967.d 0000644 0001750 0001750 00000004371 13200164641 023451 0 ustar matthias matthias // REQUIRED_ARGS: -o-
// PERMUTE_ARGS:
void foo() {}
alias F = typeof(foo);
const { void block_c() {} }
immutable { void block_i() {} }
inout { void block_w() {} }
shared { void block_s() {} }
shared const { void block_sc() {} }
shared inout { void block_sw() {} }
static assert(is(typeof(block_c) == F));
static assert(is(typeof(block_i) == F));
static assert(is(typeof(block_w) == F));
static assert(is(typeof(block_s) == F));
static assert(is(typeof(block_sc) == F));
static assert(is(typeof(block_sw) == F));
version (all) { const: void label_c() {} }
version (all) { immutable: void label_i() {} }
version (all) { inout: void label_w() {} }
version (all) { shared: void label_s() {} }
version (all) { shared const: void label_sc() {} }
version (all) { shared inout: void label_sw() {} }
static assert(is(typeof(label_c) == F));
static assert(is(typeof(label_i) == F));
static assert(is(typeof(label_w) == F));
static assert(is(typeof(label_s) == F));
static assert(is(typeof(label_sc) == F));
static assert(is(typeof(label_sw) == F));
class C
{
const { static void block_c() {} }
immutable { static void block_i() {} }
inout { static void block_w() {} }
shared { static void block_s() {} }
shared const { static void block_sc() {} }
shared inout { static void block_sw() {} }
static assert(is(typeof(block_c) == F));
static assert(is(typeof(block_i) == F));
static assert(is(typeof(block_w) == F));
static assert(is(typeof(block_s) == F));
static assert(is(typeof(block_sc) == F));
static assert(is(typeof(block_sw) == F));
version (all) { const: static void label_c() {} }
version (all) { immutable: static void label_i() {} }
version (all) { inout: static void label_w() {} }
version (all) { shared: static void label_s() {} }
version (all) { shared const: static void label_sc() {} }
version (all) { shared inout: static void label_sw() {} }
static assert(is(typeof(label_c) == F));
static assert(is(typeof(label_i) == F));
static assert(is(typeof(label_w) == F));
static assert(is(typeof(label_s) == F));
static assert(is(typeof(label_sc) == F));
static assert(is(typeof(label_sw) == F));
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testheader12567a.d 0000644 0001750 0001750 00000000321 13200164641 024746 0 ustar matthias matthias // REQUIRED_ARGS: -o- -H -Hf${RESULTS_DIR}/compilable/header12567a.di
// PERMUTE_ARGS:
// POST_SCRIPT: compilable/extra-files/header-postscript.sh header12567a
deprecated module header12567a;
void main() {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test8922e.d 0000644 0001750 0001750 00000000561 13200164641 023527 0 ustar matthias matthias // PERMUTE_ARGS:
import renamed = imports.bug8922;
void test()
{
enum x = __traits(parent, renamed).stringof;
static assert(x == "package imports");
static assert(!__traits(compiles, __traits(parent, imports)));
static assert(!__traits(compiles, __traits(parent, bug8922)));
static assert(!__traits(compiles, __traits(parent, imports.bug8922)));
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test70.d 0000644 0001750 0001750 00000000156 13200164641 023204 0 ustar matthias matthias import imports.test70 : foo;
void foo(int) // overloads with selective import
{
}
void bar()
{
foo();
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test69.d 0000644 0001750 0001750 00000002653 13200164641 023220 0 ustar matthias matthias // PERMUTE_ARGS:
// ICE(expression.c) DMD 0.110
// http://www.digitalmars.com/d/archives/digitalmars/D/bugs/2966.html
string str255() { return "\255"; }
void fromFail49()
{
switch("abc")
{
case "":
case str255():
break;
default:
break;
}
}
// Bugzilla 5735
struct A {}
void b() {}
void foo(bool cond) {}
void main()
{
A a;
int i;
static assert(!__traits(compiles, assert(a)));
static assert(!__traits(compiles, assert(i || a)));
static assert(!__traits(compiles, assert(0 || a)));
static assert(!__traits(compiles, assert(i && a)));
static assert(!__traits(compiles, assert(1 && a)));
static assert(!__traits(compiles, foo(a)));
static assert(!__traits(compiles, foo(i || a)));
static assert(!__traits(compiles, foo(0 || a)));
static assert(!__traits(compiles, foo(i && a)));
static assert(!__traits(compiles, foo(1 && a)));
static assert(!__traits(compiles, assert(b)));
static assert(!__traits(compiles, assert(i || b)));
static assert(!__traits(compiles, assert(0 || b)));
static assert(!__traits(compiles, assert(i && b)));
static assert(!__traits(compiles, assert(1 && b)));
static assert(!__traits(compiles, foo(b)));
static assert(!__traits(compiles, foo(i || b)));
static assert(!__traits(compiles, foo(0 || b)));
static assert(!__traits(compiles, foo(i && b)));
static assert(!__traits(compiles, foo(1 && b)));
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ldc_github_461.d 0000644 0001750 0001750 00000000610 13200164641 024547 0 ustar matthias matthias import std.stdio;
void foo(bool[] err = null)
{
if (err !is null)
{
if (err[0])
{
writeln(err);
}
else
{
writeln("Nothing to do.");
}
}
else
{
writeln("Null input.");
}
}
void main()
{
foo();
bool[] err = [false, false, false];
foo(err);
err[0] = true;
foo(err);
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testDIP37_10421.d 0000644 0001750 0001750 00000000455 13200164641 024275 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -c -Icompilable/extra-files
// EXTRA_SOURCES: extra-files/pkgDIP37_10421/algo/package.d
// EXTRA_SOURCES: extra-files/pkgDIP37_10421/algo/mod.d
// EXTRA_SOURCES: extra-files/pkgDIP37_10421/except.d
module testDIP37_10421;
import pkgDIP37_10421.algo;
void main() {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ldc_github_421.d 0000644 0001750 0001750 00000000323 13200164641 024544 0 ustar matthias matthias int main() {
import core.simd;
float[16] a = 1.0;
float4 t = 0, k = 2;
auto b = cast(float4[])a;
for (size_t i = 0; i < b.length; i++)
t += b[i] * k;
return cast(int)t.array[2];
} ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testfptr.d 0000644 0001750 0001750 00000031222 13200164641 023727 0 ustar matthias matthias // PERMUTE_ARGS:
ref int frvv();
class A {}
class B : A {}
B restrictedfunc(in const(int)) @safe pure nothrow;
A relaxedfunc(in int);
void bug3797()
{
// Cannot convert if the return type or parameters are different
void function() vv;
void function(int) vi;
int function() iv;
const(int) function() cv;
immutable(int) function() xv;
static assert( is(typeof( vv = vv )));
static assert(!is(typeof( vv = vi )));
static assert(!is(typeof( vv = iv )));
static assert(!is(typeof( vv = cv )));
static assert(!is(typeof( vv = xv )));
static assert(!is(typeof( vi = vv )));
static assert( is(typeof( vi = vi )));
static assert(!is(typeof( vi = iv )));
static assert(!is(typeof( vi = cv )));
static assert(!is(typeof( vi = cx )));
static assert(!is(typeof( iv = vv )));
static assert(!is(typeof( iv = vi )));
static assert( is(typeof( iv = iv )));
static assert( is(typeof( iv = cv )));
static assert( is(typeof( iv = xv )));
static assert(!is(typeof( cv = vv )));
static assert( is(typeof( cv = iv )));
static assert(!is(typeof( cv = vi )));
static assert( is(typeof( cv = cv )));
static assert( is(typeof( cv = xv )));
static assert(!is(typeof( xv = vv )));
static assert( is(typeof( xv = iv )));
static assert(!is(typeof( xv = vi )));
static assert( is(typeof( xv = cv )));
static assert( is(typeof( xv = xv )));
int* function() ipfunc;
const(int*) function() cipfunc;
static assert( is(typeof( cipfunc = ipfunc )) );
static assert(!is(typeof( ipfunc = cipfunc )) );
// functions with different linkages can't convert
extern(C) void function() cfunc;
extern(D) void function() dfunc;
static assert(!is(typeof( cfunc = dfunc )));
static assert(!is(typeof( dfunc = cfunc )));
// ref return can't convert to non-ref return
typeof(&frvv) rvv;
static assert(!is(typeof( rvv = iv )));
static assert(!is(typeof( rvv = cv )));
static assert(!is(typeof( iv = rvv )));
static assert(!is(typeof( cv = rvv )));
// variadic functions don't mix
void function(...) vf;
static assert(!is(typeof( vf = vv )));
static assert(!is(typeof( vv = vf )));
// non-nothrow -> nothrow
void function() nothrow ntf;
static assert(!is(typeof( ntf = vv )));
static assert( is(typeof( vv = ntf )));
// @safe <-> @trusted -> @system
void function() @system systemfunc;
void function() @trusted trustedfunc;
void function() @safe safefunc;
static assert( is(typeof( trustedfunc = safefunc )));
static assert( is(typeof( systemfunc = trustedfunc )));
static assert( is(typeof( systemfunc = safefunc )));
static assert( is(typeof( safefunc = trustedfunc )));
static assert(!is(typeof( trustedfunc = systemfunc )));
static assert(!is(typeof( safefunc = systemfunc )));
// pure -> non-pure
void function() nonpurefunc;
void function() pure purefunc;
static assert(!is(typeof( purefunc = nonpurefunc )));
static assert( is(typeof( nonpurefunc = purefunc )));
// Cannot convert parameter storage classes (except const to in and in to const)
void function(const(int)) constfunc;
void function(in int) infunc;
void function(out int) outfunc;
void function(ref int) reffunc;
void function(lazy int) lazyfunc;
static assert(is(typeof( infunc = constfunc )));
static assert(is(typeof( constfunc = infunc )));
static assert(!is(typeof( infunc = outfunc )));
static assert(!is(typeof( infunc = reffunc )));
static assert(!is(typeof( infunc = lazyfunc )));
static assert(!is(typeof( outfunc = infunc )));
static assert(!is(typeof( outfunc = reffunc )));
static assert(!is(typeof( outfunc = lazyfunc )));
static assert(!is(typeof( reffunc = infunc )));
static assert(!is(typeof( reffunc = outfunc )));
static assert(!is(typeof( reffunc = lazyfunc )));
static assert(!is(typeof( lazyfunc = infunc )));
static assert(!is(typeof( lazyfunc = outfunc )));
static assert(!is(typeof( lazyfunc = reffunc )));
// Test class covariance
A function() afunc;
B function() bfunc;
static assert( is(typeof( afunc = bfunc )));
static assert(!is(typeof( bfunc = afunc )));
// Test all the conversions at once
typeof(&restrictedfunc) prestrictedfunc;
typeof(&relaxedfunc) prelaxedfunc = prestrictedfunc;
}
void bug3797dg()
{
ref int frvv() { return *(new int); }
B restrictedfunc(in const(int)) @safe pure nothrow { return null; }
A relaxedfunc(in int) { return null; }
// Cannot convert if the return type or parameters are different
void delegate() vv;
void delegate(int) vi;
int delegate() iv;
const(int) delegate() cv;
immutable(int) delegate() xv;
static assert( is(typeof( vv = vv )));
static assert(!is(typeof( vv = vi )));
static assert(!is(typeof( vv = iv )));
static assert(!is(typeof( vv = cv )));
static assert(!is(typeof( vv = xv )));
static assert(!is(typeof( vi = vv )));
static assert( is(typeof( vi = vi )));
static assert(!is(typeof( vi = iv )));
static assert(!is(typeof( vi = cv )));
static assert(!is(typeof( vi = cx )));
static assert(!is(typeof( iv = vv )));
static assert(!is(typeof( iv = vi )));
static assert( is(typeof( iv = iv )));
static assert( is(typeof( iv = cv )));
static assert( is(typeof( iv = xv )));
static assert(!is(typeof( cv = vv )));
static assert( is(typeof( cv = iv )));
static assert(!is(typeof( cv = vi )));
static assert( is(typeof( cv = cv )));
static assert( is(typeof( cv = xv )));
static assert(!is(typeof( xv = vv )));
static assert( is(typeof( xv = iv )));
static assert(!is(typeof( xv = vi )));
static assert( is(typeof( xv = cv )));
static assert( is(typeof( xv = xv )));
int* delegate() ipfunc;
const(int*) delegate() cipfunc;
static assert( is(typeof( cipfunc = ipfunc )) );
static assert(!is(typeof( ipfunc = cipfunc )) );
// delegates with different linkages can't convert
extern(C) void delegate() cfunc;
extern(D) void delegate() dfunc;
static assert(!is(typeof( cfunc = dfunc )));
static assert(!is(typeof( dfunc = cfunc )));
// ref return can't convert to non-ref return
typeof(&frvv) rvv;
static assert(!is(typeof( rvv = iv )));
static assert(!is(typeof( rvv = cv )));
static assert(!is(typeof( iv = rvv )));
static assert(!is(typeof( cv = rvv )));
// variadic delegates don't mix
void delegate(...) vf;
static assert(!is(typeof( vf = vv )));
static assert(!is(typeof( vv = vf )));
// non-nothrow -> nothrow
void delegate() nothrow ntf;
static assert(!is(typeof( ntf = vv )));
static assert( is(typeof( vv = ntf )));
// @safe <-> @trusted -> @system
void delegate() @system systemfunc;
void delegate() @trusted trustedfunc;
void delegate() @safe safefunc;
static assert( is(typeof( trustedfunc = safefunc )));
static assert( is(typeof( systemfunc = trustedfunc )));
static assert( is(typeof( systemfunc = safefunc )));
static assert( is(typeof( safefunc = trustedfunc )));
static assert(!is(typeof( trustedfunc = systemfunc )));
static assert(!is(typeof( safefunc = systemfunc )));
// pure -> non-pure
void delegate() nonpurefunc;
void delegate() pure purefunc;
static assert(!is(typeof( purefunc = nonpurefunc )));
static assert( is(typeof( nonpurefunc = purefunc )));
// Cannot convert parameter storage classes (except const to in and in to const)
void delegate(const(int)) constfunc;
void delegate(in int) infunc;
void delegate(out int) outfunc;
void delegate(ref int) reffunc;
void delegate(lazy int) lazyfunc;
static assert(is(typeof( infunc = constfunc )));
static assert(is(typeof( constfunc = infunc )));
static assert(!is(typeof( infunc = outfunc )));
static assert(!is(typeof( infunc = reffunc )));
static assert(!is(typeof( infunc = lazyfunc )));
static assert(!is(typeof( outfunc = infunc )));
static assert(!is(typeof( outfunc = reffunc )));
static assert(!is(typeof( outfunc = lazyfunc )));
static assert(!is(typeof( reffunc = infunc )));
static assert(!is(typeof( reffunc = outfunc )));
static assert(!is(typeof( reffunc = lazyfunc )));
static assert(!is(typeof( lazyfunc = infunc )));
static assert(!is(typeof( lazyfunc = outfunc )));
static assert(!is(typeof( lazyfunc = reffunc )));
// Test class covariance
A delegate() afunc;
B delegate() bfunc;
static assert( is(typeof( afunc = bfunc )));
static assert(!is(typeof( bfunc = afunc )));
// Test all the conversions at once
typeof(&restrictedfunc) prestrictedfunc;
typeof(&relaxedfunc) prelaxedfunc = prestrictedfunc;
}
void bug3268()
{
auto a = &bug3268;
const b = a;
assert(a == a);
assert(a == b);
assert(b == b);
immutable c = cast(immutable)a;
assert(a == c);
assert(b == c);
assert(c == c);
static assert(is(typeof(*a) == typeof(*b)));
static assert(is(typeof(*a) == typeof(*c)));
}
void bug3268dg()
{
void bug3268x() {}
auto a = &bug3268x;
const b = a;
assert(a == a);
assert(a == b);
assert(b == b);
immutable c = cast(immutable)a;
assert(a == c);
assert(b == c);
assert(c == c);
}
void bug3833()
{
bool b;
void function() func;
void function() pure purefunc;
void function() nothrow nothrowfunc;
void function() @safe safefunc;
void function() @trusted trustedfunc;
static assert( is(typeof( b ? func : purefunc ) == typeof( func )));
static assert( is(typeof( b ? func : nothrowfunc ) == typeof( func )));
static assert( is(typeof( b ? func : safefunc ) == typeof( func )));
static assert( is(typeof( b ? func : trustedfunc ) == typeof( func )));
static assert( is(typeof( b ? purefunc : nothrowfunc ) == typeof( func )));
static assert( is(typeof( b ? purefunc : safefunc ) == typeof( func )));
static assert( is(typeof( b ? purefunc : trustedfunc ) == typeof( func )));
static assert( is(typeof( b ? nothrowfunc : safefunc ) == typeof( func )));
static assert( is(typeof( b ? nothrowfunc : trustedfunc ) == typeof( func )));
static assert( is(typeof( b ? safefunc : trustedfunc ) == typeof( trustedfunc )));
auto arr = [func, purefunc, nothrowfunc, safefunc, trustedfunc];
static assert( is(typeof( arr ) == typeof(func)[]) );
}
void bug3833dg()
{
bool b;
void delegate() func;
void delegate() pure purefunc;
void delegate() nothrow nothrowfunc;
void delegate() @safe safefunc;
void delegate() @trusted trustedfunc;
static assert( is(typeof( b ? func : purefunc ) == typeof( func )));
static assert( is(typeof( b ? func : nothrowfunc ) == typeof( func )));
static assert( is(typeof( b ? func : safefunc ) == typeof( func )));
static assert( is(typeof( b ? func : trustedfunc ) == typeof( func )));
static assert( is(typeof( b ? purefunc : nothrowfunc ) == typeof( func )));
static assert( is(typeof( b ? purefunc : safefunc ) == typeof( func )));
static assert( is(typeof( b ? purefunc : trustedfunc ) == typeof( func )));
static assert( is(typeof( b ? nothrowfunc : safefunc ) == typeof( func )));
static assert( is(typeof( b ? nothrowfunc : trustedfunc ) == typeof( func )));
static assert( is(typeof( b ? safefunc : trustedfunc ) == typeof( trustedfunc )));
auto arr = [func, purefunc, nothrowfunc, safefunc, trustedfunc];
static assert( is(typeof( arr ) == typeof(func)[]) );
}
void bug4838()
{
void delegate() const dgc;
static assert(typeof(dgc).stringof == "void delegate() const");
void delegate() immutable dgi;
static assert(typeof(dgi).stringof == "void delegate() immutable");
void delegate() shared dgs;
static assert(typeof(dgs).stringof == "void delegate() shared");
void delegate() shared const dgsc;
static assert(typeof(dgsc).stringof == "void delegate() shared const");
void delegate() inout dgw;
static assert(typeof(dgw).stringof == "void delegate() inout");
void delegate() shared inout dgsw;
static assert(typeof(dgsw).stringof == "void delegate() shared inout");
}
void test8822()
{
struct S { void foo() const {} }
S s;
void delegate() const dg = &s.foo; // OK
void foo(void delegate() const dg){} // OK
struct Foo(T) {}
alias Foo!(void delegate() const) X; // NG -> OK
}
void main()
{
static assert(is(typeof(&main) P : U*, U));
auto x = cast(void*)&main;
const void * p = &main;
__gshared void function() gp = null;
__gshared void delegate() gp2 = null;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test1537.d 0000644 0001750 0001750 00000003450 13200164641 023355 0 ustar matthias matthias // 1537
void foo(char[] s)
{
int x = -1;
while (s.length)
{
char c = s[0];
if (c == '}')
break;
assert (c >= '0' && c <= '9', s[0..$]);
if (x == -1)
x = 0;
}
}
/**************************************/
enum bug4732 = 42;
static assert( __traits(identifier, bug4732) == "bug4732");
/**************************************/
template Compileable(int z) { bool OK=true;}
int bug5245a(U)()
{
{ enum T { a = 5 } T v; }
{ enum T { a = 6 } T w; }
return 91;
}
int bug5245b(U)()
{
{ struct T { int a = 2; } T v; }
{ union T { int a = 3; } T w; }
return 91;
}
int bug5245c(U)()
{
{ struct T { int a = 2; } T v; }
{ class T { int a = 3; } T w; }
return 91;
}
int bug5245d(U)()
{
{ enum T { a = 3 } T w; }
{ struct T { int a = 2; } T v; }
return 91;
}
static assert(!is(typeof(Compileable!(bug5245a!(int)()).OK)));
static assert(!is(typeof(Compileable!(bug5245b!(int)()).OK)));
static assert(!is(typeof(Compileable!(bug5245c!(int)()).OK)));
static assert(!is(typeof(Compileable!(bug5245d!(int)()).OK)));
/**************************************/
class Bug5349(T) // segfault D2.051
{
int x;
static int g()
{
class B
{
int inner()
{
return x; // should not compile
}
}
return (new B).inner();
}
int y = g();
}
static assert(!is(typeof(Bug5349!(int))));
/**************************************/
class Bug4033 {}
class Template4033(T) {
static assert(is(T : Bug4033));
}
alias Template4033!(Z4033) Bla;
class Z4033 : Bug4033 { }
/**************************************/
struct Bug4322 {
int[1] a = void;
}
void bug4322() {
Bug4322 f = Bug4322();
Bug4322 g = Bug4322.init;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc9676a.d 0000644 0001750 0001750 00000000351 13200164641 023461 0 ustar matthias matthias // PERMUTE_ARGS:
// EXTRA_SOURCES: /extra-files/ddoc9676a.ddoc
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 9676a
module ddoc9676a;
///
deprecated void foo() {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/interpret3.d 0000644 0001750 0001750 00000445736 13200164641 024176 0 ustar matthias matthias // PERMUTE_ARGS: -inline
template compiles(int T)
{
bool compiles = true;
}
alias TypeTuple(T...) = T;
/**************************************************
3901 Arbitrary struct assignment, ref return
**************************************************/
struct ArrayRet
{
int x;
}
int arrayRetTest(int z)
{
ArrayRet[6] w;
int q = (w[3].x = z);
return q;
}
static assert(arrayRetTest(51) == 51);
// Bugzilla 3842 -- must not segfault
int ice3842(int z)
{
ArrayRet w;
return arrayRetTest((*(&w)).x);
}
static assert(true || is(typeof(compiles!(ice3842(51)))));
int arrayret2()
{
int[5] a;
int[3] b;
b[] = a[1 .. $-1] = 5;
return b[1];
}
static assert(arrayret2() == 5);
struct DotVarTest
{
ArrayRet z;
}
struct DotVarTest2
{
ArrayRet z;
DotVarTest p;
}
int dotvar1()
{
DotVarTest w;
w.z.x = 3;
return w.z.x;
}
static assert(dotvar1() == 3);
int dotvar2()
{
DotVarTest2[4] m;
m[2].z.x = 3;
m[1].p.z.x = 5;
return m[2].z.x + 7;
}
static assert(dotvar2() == 10);
struct RetRefStruct
{
int x;
char c;
}
// Return value reference tests, for D2 only.
ref RetRefStruct reffunc1(ref RetRefStruct a)
{
int y = a.x;
return a;
}
ref RetRefStruct reffunc2(ref RetRefStruct a)
{
RetRefStruct z = a;
return reffunc1(a);
}
ref int reffunc7(ref RetRefStruct aa)
{
return reffunc1(aa).x;
}
ref int reffunc3(ref int a)
{
return a;
}
struct RefTestStruct
{
RetRefStruct r;
ref RefTestStruct reffunc4(ref RetRefStruct[3] a)
{
return this;
}
ref int reffunc6()
{
return this.r.x;
}
}
ref RetRefStruct reffunc5(ref RetRefStruct[3] a)
{
int t = 1;
for (int i = 0; i < 10; ++i)
{
if (i == 7)
++t;
}
return a[reffunc3(t)];
}
int retRefTest1()
{
RetRefStruct b = RetRefStruct(0, 'a');
reffunc1(b).x = 3;
return b.x - 1;
}
int retRefTest2()
{
RetRefStruct b = RetRefStruct(0, 'a');
reffunc2(b).x = 3;
RetRefStruct[3] z;
RefTestStruct w;
w.reffunc4(z).reffunc4(z).r.x = 4;
assert(w.r.x == 4);
w.reffunc6() = 218;
assert(w.r.x == 218);
z[2].x = 3;
int q = 4;
int u = reffunc5(z).x + reffunc3(q);
assert(u == 7);
reffunc5(z).x += 7;
assert(z[2].x == 10);
RetRefStruct m = RetRefStruct(7, 'c');
m.x = 6;
reffunc7(m) += 3;
assert(m.x == 9);
return b.x - 1;
}
int retRefTest3()
{
RetRefStruct b = RetRefStruct(0, 'a');
auto deleg = function (RetRefStruct a){ return a; };
typeof(deleg)[3] z;
z[] = deleg;
auto y = deleg(b).x + 27;
b.x = 5;
assert(y == 27);
y = z[1](b).x + 22;
return y - 1;
}
int retRefTest4()
{
RetRefStruct b = RetRefStruct(0, 'a');
reffunc3(b.x) = 218;
assert(b.x == 218);
return b.x;
}
static assert(retRefTest1() == 2);
static assert(retRefTest2() == 2);
static assert(retRefTest3() == 26);
static assert(retRefTest4() == 218);
/**************************************************
Bug 7887 assign to returned reference
**************************************************/
bool test7887()
{
ref int f(ref int x) { return x; }
int a;
f(a) = 42;
return (a == 42);
}
static assert(test7887());
/**************************************************
Bug 7473 struct non-ref
**************************************************/
struct S7473
{
int i;
}
static assert({
S7473 s = S7473(1);
assert(s.i == 1);
bug7473(s);
assert(s.i == 1);
return true;
}());
void bug7473(S7473 s)
{
s.i = 2;
}
struct S7473b
{
S7473 m;
}
static assert({
S7473b s = S7473b(S7473(7));
assert(s.m.i == 7);
bug7473b(s);
assert(s.m.i == 7);
return true;
}());
void bug7473b(S7473b s)
{
s.m.i = 2;
}
/**************************************************
Bug 4389
**************************************************/
int bug4389()
{
string s;
dchar c = '\u2348';
s ~= c;
assert(s.length == 3);
dchar d = 'D';
s ~= d;
assert(s.length == 4);
s = "";
s ~= c;
assert(s.length == 3);
s ~= d;
assert(s.length == 4);
string z;
wchar w = '\u0300';
z ~= w;
assert(z.length == 2);
z = "";
z ~= w;
assert(z.length == 2);
return 1;
}
static assert(bug4389());
// ICE(constfold.c)
int ice4389()
{
string s;
dchar c = '\u2348';
s ~= c;
s = s ~ "xxx";
return 1;
}
static assert(ice4389());
// ICE(expression.c)
string ice4390()
{
string s;
dchar c = '`';
s ~= c;
s ~= c;
return s;
}
static assert(mixin(ice4390()) == ``);
// bug 5248 (D1 + D2)
struct Leaf5248
{
string Compile_not_ovloaded()
{
return "expression";
}
}
struct Matrix5248
{
Leaf5248 Right;
string Compile()
{
return Right.Compile_not_ovloaded();
}
};
static assert(Matrix5248().Compile());
/**************************************************
4837 >>>=
**************************************************/
bool bug4837()
{
ushort x = 0x89AB;
x >>>= 4;
assert(x == 0x89A);
byte y = 0x7C;
y >>>= 2;
assert(y == 0x1F);
return true;
}
static assert(bug4837());
/**************************************************
10252 shift out of range
**************************************************/
int lshr10252(int shift)
{
int a = 5;
return a << shift;
}
int rshr10252(int shift)
{
int a = 5;
return a >> shift;
}
int ushr10252(int shift)
{
int a = 5;
return a >>> shift;
}
static assert( is(typeof(compiles!(lshr10252( 4)))));
static assert(!is(typeof(compiles!(lshr10252(60)))));
static assert( is(typeof(compiles!(rshr10252( 4)))));
static assert(!is(typeof(compiles!(rshr10252(80)))));
static assert( is(typeof(compiles!(ushr10252( 2)))));
static assert(!is(typeof(compiles!(ushr10252(60)))));
/**************************************************
1982 CTFE null problems
**************************************************/
enum a1982 = [1, 2, 3];
static assert(a1982 !is null);
string foo1982() { return null; }
static assert(foo1982() is null);
static assert(!foo1982().length);
static assert(null is null);
/**************************************************
7988 CTFE return values should be allowed in compile-time expressions
**************************************************/
class X7988 { int y; this() { y = 2; } }
static assert((new X7988).y == 2);
/**************************************************
8253 ICE: calling of member function of non-CTFE class variable
**************************************************/
class Bug8253
{
bool j()
{
return true;
}
}
Bug8253 m8253;
static assert(!is(typeof(compiles!(m8253.j()))));
/**************************************************
8285 Issue with slice returned from CTFE function
**************************************************/
string foo8285()
{
string s = "ab";
return s[0 .. $];
}
template T8285b(string s) { }
template T8285a()
{
enum s = foo8285();
alias T8285b!(s) t2;
}
int bar8285()
{
alias T8285a!() t1;
return 0;
}
int baz8285(int x)
{
return 0;
}
static assert(baz8285(bar8285()) == 0);
// test case 2
string xbar8285()
{
string s = "ab";
return s[0 .. $];
}
template xT8285a()
{
enum xT8285a = xbar8285()[0 .. $];
}
string xbaz8285()
{
return xT8285a!();
}
string xfoo8285(string s)
{
return s;
}
static assert(xfoo8285(xbaz8285()) == "ab");
/**************************************************
'this' parameter bug revealed during refactoring
**************************************************/
int thisbug1(int x) { return x; }
struct ThisBug1
{
int m = 1;
int wut()
{
return thisbug1(m);
}
}
int thisbug2()
{
ThisBug1 spec;
return spec.wut();
}
static assert(thisbug2());
/**************************************************
6972 ICE with cast()cast()assign
**************************************************/
int bug6972()
{
ubyte n = 6;
n /= 2u;
return n;
}
static assert(bug6972() == 3);
/**************************************************
Bug 6164
**************************************************/
size_t bug6164()
{
int[] ctfe2(int n)
{
int[] r = [];
if (n != 0)
r ~= [1] ~ ctfe2(n - 1);
return r;
}
return ctfe2(2).length;
}
static assert(bug6164() == 2);
/**************************************************
Interpreter code coverage tests
**************************************************/
int cov1(int a)
{
a %= 15382;
a /= 5;
a = ~ a;
bool c = (a == 0);
bool b = true && c;
assert(b == 0);
b = false && c;
assert(b == 0);
b = false || c;
assert(b == 0);
a ^= 0x45349;
a = ~ a;
a &= 0xFF3F;
a >>>= 1;
a = a ^ 0x7393;
a = a >> 1;
a = a >>> 1;
a = a | 0x010101;
return a;
}
static assert(cov1(534564) == 71589);
int cov2()
{
int i = 0;
do
{
goto DOLABEL;
DOLABEL:
if (i != 0)
{
goto IFLABEL;
IFLABEL:
switch(i)
{
case 3:
break;
case 6:
goto SWITCHLABEL;
SWITCHLABEL:
i = 27;
goto case 3;
default:
assert(0);
}
return i;
}
i = 6;
} while(true);
return 88; // unreachable
}
static assert(cov2() == 27);
template CovTuple(T...)
{
alias T CovTuple;
}
alias CovTuple!(int, long) TCov3;
int cov3(TCov3 t)
{
TCov3 s;
s = t;
assert(s[0] == 1);
assert(s[1] == 2);
return 7;
}
static assert(cov3(1, 2) == 7);
int badassert1(int z)
{
assert(z == 5, "xyz");
return 1;
}
size_t badslice1(int[] z)
{
return z[0 .. 3].length;
}
size_t badslice2(int[] z)
{
return z[0 .. badassert1(1)].length;
}
size_t badslice3(int[] z)
{
return z[badassert1(1) .. 2].length;
}
static assert(!is(typeof(compiles!(badassert1(67)))));
static assert( is(typeof(compiles!(badassert1(5)))));
static assert(!is(typeof(compiles!(badslice1([1,2])))));
static assert(!is(typeof(compiles!(badslice2([1,2])))));
static assert(!is(typeof(compiles!(badslice3([1,2,3])))));
/*******************************************/
int bug7894()
{
for (int k = 0; k < 2; ++k)
{
goto Lagain;
Lagain:
;
}
int m = 1;
do
{
++m;
goto Ldo;
Ldo: ;
} while (m < 3);
assert(m == 3);
return 1;
}
static assert(bug7894());
/*******************************************/
size_t bug5524(int x, int[] more...)
{
int[0] zz;
assert(zz.length == 0);
return 7 + more.length + x;
}
static assert(bug5524(3) == 10);
// 5722
static assert(("" ~ "\©"[0]).length == 1);
const char[] null5722 = null;
static assert((null5722 ~ "\©"[0]).length == 1);
static assert(("\©"[0] ~ null5722).length == 1);
/*******************************************
* Tests for CTFE Array support.
* Including bugs 1330, 3801, 3835, 4050,
* 4051, 5147, and major functionality
*******************************************/
char[] bug1330StringIndex()
{
char[] blah = "foo".dup;
assert(blah == "foo");
char[] s = blah[0 .. 2];
blah[0] = 'h';
assert(s == "ho");
s[0] = 'm';
return blah;
}
static assert(bug1330StringIndex() == "moo");
static assert(bug1330StringIndex() == "moo"); // check we haven't clobbered any string literals
int[] bug1330ArrayIndex()
{
int[] blah = [1,2,3];
int[] s = blah;
s = blah[0 .. 2];
int z = blah[0] = 6;
assert(z == 6);
assert(blah[0] == 6);
assert(s[0] == 6);
assert(s == [6, 2]);
s[1] = 4;
assert(z == 6);
return blah;
}
static assert(bug1330ArrayIndex() == [6, 4, 3]);
static assert(bug1330ArrayIndex() == [6, 4, 3]); // check we haven't clobbered any literals
char[] bug1330StringSliceAssign()
{
char[] blah = "food".dup;
assert(blah == "food");
char[] s = blah[1 .. 4];
blah[0 .. 2] = "hc";
assert(s == "cod");
s[0 .. 2] = ['a', 'b']; // Mix string + array literal
assert(blah == "habd");
s[0 .. 2] = "mq";
return blah;
}
static assert(bug1330StringSliceAssign() == "hmqd");
static assert(bug1330StringSliceAssign() == "hmqd");
int[] bug1330ArraySliceAssign()
{
int[] blah = [1, 2, 3, 4];
int[] s = blah[1 .. 4];
blah[0 .. 2] = [7, 9];
assert(s == [9, 3, 4]);
s[0 .. 2] = [8, 15];
return blah;
}
static assert(bug1330ArraySliceAssign() == [7, 8, 15, 4]);
int[] bug1330ArrayBlockAssign()
{
int[] blah = [1, 2, 3, 4, 5];
int[] s = blah[1 .. 4];
blah[0 .. 2] = 17;
assert(s == [17, 3, 4]);
s[0 .. 2] = 9;
return blah;
}
static assert(bug1330ArrayBlockAssign() == [17, 9, 9, 4, 5]);
char[] bug1330StringBlockAssign()
{
char[] blah = "abcde".dup;
char[] s = blah[1 .. 4];
blah[0 .. 2] = 'x';
assert(s == "xcd");
s[0 .. 2] = 'y';
return blah;
}
static assert(bug1330StringBlockAssign() == "xyyde");
int assignAA(int x)
{
int[int] aa;
int[int] cc = aa;
assert(cc.values.length == 0);
assert(cc.keys.length == 0);
aa[1] = 2;
aa[x] = 6;
int[int] bb = aa;
assert(bb.keys.length == 2);
assert(cc.keys.length == 0); // cc is not affected to aa, because it is null
aa[500] = 65;
assert(bb.keys.length == 3); // but bb is affected by changes to aa
return aa[1] + aa[x];
}
static assert(assignAA(12) == 8);
template Compileable(int z) { bool OK; }
int arraybounds(int j, int k)
{
int[] xxx = [1, 2, 3, 4, 5];
int[] s = xxx[1 .. $];
s = s[j .. k]; // slice of slice
return s[$ - 1];
}
static assert(!is(typeof(Compileable!(arraybounds(1, 14)))));
static assert(!is(typeof(Compileable!(arraybounds(15, 3)))));
static assert(arraybounds(2, 4) == 5);
int arraybounds2(int j, int k)
{
int[] xxx = [1, 2, 3, 4, 5];
int[] s = xxx[j .. k]; // direct slice
return 1;
}
static assert(!is(typeof(Compileable!(arraybounds2(1, 14)))));
static assert(!is(typeof(Compileable!(arraybounds2(15, 3)))));
static assert(arraybounds2(2, 4) == 1);
int bug5147a()
{
int[1][2] a = 37;
return a[0][0];
}
static assert(bug5147a() == 37);
int bug5147b()
{
int[4][2][3][17] a = 37;
return a[0][0][0][0];
}
static assert(bug5147b() == 37);
int setlen()
{
int[][] zzz;
zzz.length = 2;
zzz[0].length = 10;
assert(zzz.length == 2);
assert(zzz[0].length == 10);
assert(zzz[1].length == 0);
return 2;
}
static assert(setlen() == 2);
int[1][1] bug5147()
{
int[1][1] a = 1;
return a;
}
static assert(bug5147() == [[1]]);
enum int[1][1] enum5147 = bug5147();
static assert(enum5147 == [[1]]);
immutable int[1][1] bug5147imm = bug5147();
// Index referencing
int[2][2] indexref1()
{
int[2][2] a = 2;
a[0] = 7;
int[][] b = [null, null];
b[0 .. $] = a[0][0 .. 2];
assert(b[0][0] == 7);
assert(b[0][1] == 7);
int[] w;
w = a[0];
assert(w[0] == 7);
w[0 .. $] = 5;
assert(a[0] != [7, 7]);
assert(a[0] == [5, 5]);
assert(b[0] == [5, 5]);
return a;
}
int[2][2] indexref2()
{
int[2][2] a = 2;
a[0] = 7;
int[][2] b = null;
b[0 .. $] = a[0];
assert(b[0][0] == 7);
assert(b[0][1] == 7);
assert(b == [[7, 7], [7, 7]]);
int[] w;
w = a[0];
assert(w[0] == 7);
w[0 .. $] = 5;
assert(a[0] != [7, 7]);
assert(a[0] == [5, 5]);
assert(b[0] == [5, 5]);
return a;
}
int[2][2] indexref3()
{
int[2][2] a = 2;
a[0]=7;
int[][2] b = [null, null];
b[0 .. $] = a[0];
assert(b[0][0] == 7);
assert(b[0][1] == 7);
int[] w;
w = a[0];
assert(w[0] == 7);
w[0 .. $] = 5;
assert(a[0] != [7, 7]);
assert(a[0] == [5, 5]);
assert(b[0] == [5, 5]);
return a;
}
int[2][2] indexref4()
{
int[2][2] a = 2;
a[0] = 7;
int[][2] b =[[1, 2, 3], [1, 2, 3]]; // wrong code
b[0] = a[0];
assert(b[0][0] == 7);
assert(b[0][1] == 7);
int[] w;
w = a[0]; //[0 .. $];
assert(w[0] == 7);
w[0 .. $] = 5;
assert(a[0] != [7, 7]);
assert(a[0] == [5, 5]);
assert(b[0] == [5, 5]);
return a;
}
static assert(indexref1() == [[5, 5], [2, 2]]);
static assert(indexref2() == [[5, 5], [2, 2]]);
static assert(indexref3() == [[5, 5], [2, 2]]);
static assert(indexref4() == [[5, 5], [2, 2]]);
int staticdynamic()
{
int[2][1] a = 2;
assert(a == [[2, 2]]);
int[][1] b = a[0][0 .. 1];
assert(b[0] == [2]);
auto k = b[0];
auto m = a[0][0 .. 1];
assert(k == [2]);
assert(m == k);
return 0;
}
static assert(staticdynamic() == 0);
int[] crashing()
{
int[12] cra;
return (cra[2 .. $] = 3);
}
static assert(crashing()[9] == 3);
int chainassign()
{
int[4] x = 6;
int[] y = new int[4];
auto k = (y[] = (x[] = 2));
return k[0];
}
static assert(chainassign() == 2);
// index assignment
struct S3801
{
char c;
int[3] arr;
this(int x, int y)
{
c = 'x';
arr[0] = x;
arr[1] = y;
}
}
int bug3801()
{
S3801 xxx = S3801(17, 67);
int[] w = xxx.arr;
xxx.arr[1] = 89;
assert(xxx.arr[0] == 17);
assert(w[1] == 89);
assert(w == [17, 89, 0]);
return xxx.arr[1];
}
enum : S3801 { bug3801e = S3801(17, 18) }
static assert(bug3801e.arr == [17, 18, 0]);
immutable S3801 bug3801u = S3801(17, 18);
static assert(bug3801u.arr == [17, 18, 0]);
static assert(bug3801() == 89);
int bug3835()
{
int[4] arr;
arr[] = 19;
arr[0] = 4;
int kk;
foreach (ref el; arr)
{
el += 10;
kk = el;
}
assert(arr[2] == 29);
arr[0] += 3;
return arr[0];
}
static assert(bug3835() == 17);
auto bug5852(const(string) s)
{
string[] r;
r ~= s;
assert(r.length == 1);
return r[0].length;
}
static assert(bug5852("abc") == 3);
// 7217
struct S7217 { int[] arr; }
bool f7217()
{
auto s = S7217();
auto t = s.arr;
return true;
}
static assert(f7217());
/*******************************************
Set array length
*******************************************/
static assert(
{
struct W { int[] z; }
W w;
w.z.length = 2;
assert(w.z.length == 2);
w.z.length = 6;
assert(w.z.length == 6);
return true;
}());
// 7185 char[].length = n
bool bug7185()
{
auto arr = new char[2];
auto arr2 = new char[2];
arr2[] = "ab";
arr.length = 1;
arr2.length = 7;
assert(arr.length == 1);
assert(arr2.length == 7);
assert(arr2[0 .. 2] == "ab");
return true;
}
static assert(bug7185());
bool bug9908()
{
static const int[3] sa = 1;
return sa == [1, 1, 1];
}
static assert(bug9908());
/*******************************************
6934
*******************************************/
struct Struct6934
{
int[] x = [1, 2];
}
void bar6934(ref int[] p)
{
p[0] = 12;
assert(p[0] == 12);
p[0 .. 1] = 17;
assert(p[0] == 17);
p = p[1 .. $];
}
int bug6934()
{
Struct6934 q;
bar6934(q.x);
int[][] y = [[2, 5], [3, 6, 8]];
bar6934(y[0]);
return 1;
}
static assert(bug6934());
/*******************************************
Bug 5671
*******************************************/
static assert(['a', 'b'] ~ "c" == "abc");
/*******************************************
8624
*******************************************/
int evil8624()
{
long m = 0x1_0000_0000L;
assert(m != 0);
long[] a = [0x1_0000_0000L];
long[] b = [0x4_0000_0000L];
assert(a[] != b[]);
return 1;
}
static assert(evil8624());
/*******************************************
8644 array literal >,<
*******************************************/
int bug8644()
{
auto m = "a";
auto z = ['b'];
auto c = "b7";
auto d = ['b', '6'];
assert(m < z);
assert(z > m);
assert(z <= c);
assert(c > z);
assert(c > d);
assert(d >= d);
return true;
}
static assert(bug8644());
/*******************************************
Bug 6159
*******************************************/
struct A6159 {}
static assert({ return A6159.init is A6159.init; }());
static assert({ return [1] is [1]; }());
/*******************************************
Bug 5685
*******************************************/
string bug5685()
{
return "xxx";
}
struct Bug5865
{
void test1()
{
enum file2 = (bug5685())[0 .. $];
}
}
/*******************************************
6235 - Regression ICE on $ in template
*******************************************/
struct Bug6235(R)
{
enum XXX = is(typeof(R.init[0 .. $]) : const ubyte[]);
}
Bug6235!(ubyte[]) bug6235;
/*******************************************
8673 ICE
*******************************************/
enum dollar8673 = [0][(() => $ - 1)()];
/*******************************************
Bug 5840
*******************************************/
struct Bug5840
{
string g;
int w;
}
int bug5840(int u)
{
// check for clobbering
Bug5840 x = void;
x.w = 4;
x.g = "3gs";
if (u == 1)
bug5840(2);
if (u == 2)
{
x.g = "abc";
x.w = 3465;
}
else
{
assert(x.g == "3gs");
assert(x.w == 4);
}
return 56;
}
static assert(bug5840(1) == 56);
/*******************************************
7810
*******************************************/
int bug7810()
{
int[1][3] x = void;
x[0] = [2];
x[1] = [7];
assert(x[0][0] == 2);
char[1][3] y = void;
y[0] = "a";
y[1] = "b";
assert(y[0][0] == 'a');
return 1;
}
static assert(bug7810());
struct Bug7810
{
int w;
}
int bug7810b(T)(T[] items...)
{
assert(items[0] == Bug7810(20));
return 42;
}
static assert(bug7810b(Bug7810(20), Bug7810(10)) == 42);
/*******************************************
std.datetime ICE (30 April 2011)
*******************************************/
struct TimeOfDayZ
{
public:
this(int hour) { }
invariant() { }
}
const testTODsThrownZ = TimeOfDayZ(0);
/*******************************************
Bug 5954
*******************************************/
struct Bug5954
{
int x;
this(int xx)
{
this.x = xx;
}
}
void bug5954()
{
enum f = Bug5954(10);
static assert(f.x == 10);
}
/*******************************************
Bug 5972
*******************************************/
int bug5972()
{
char[] z = "abc".dup;
char[][] a = [null, null];
a[0] = z[0 .. 2];
char[] b = a[0];
assert(b == "ab");
a[0][1] = 'q';
assert(a[0] == "aq");
assert(b == "aq");
assert(b[1] == 'q');
//a[0][0 .. $ - 1][0 .. $] = a[0][0 .. $ - 1][0 .. $]; // overlap
return 56;
}
static assert(bug5972() == 56);
/*******************************************
2.053beta [CTFE]ICE 'global errors'
*******************************************/
int wconcat(wstring replace)
{
wstring value;
value = "A"w;
value = value ~ replace;
return 1;
}
static assert(wconcat("X"w));
/*******************************************
10397 string concat
*******************************************/
static assert(!is(typeof(compiles!("abc" ~ undefined))));
static assert(!is(typeof(compiles!(otherundefined ~ "abc"))));
/*******************************************
9634 struct concat
*******************************************/
struct Bug9634
{
int raw;
}
bool bug9634()
{
Bug9634[] jr = [Bug9634(42)];
Bug9634[] ir = null ~ jr;
Bug9634[] kr = jr ~ null;
Bug9634[] mr = jr ~ jr;
jr[0].raw = 6;
assert(ir[0].raw == 42);
assert(kr[0].raw == 42);
assert(jr[0].raw == 6);
assert(&mr[0] != &mr[1]);
return true;
}
static assert(bug9634());
/*******************************************
Bug 4001: A Space Oddity
*******************************************/
int space() { return 4001; }
void oddity4001(int q)
{
const int bowie = space();
static assert(space() == 4001);
static assert(bowie == 4001);
}
/*******************************************
Bug 3779
*******************************************/
static const bug3779 = ["123"][0][$ - 1];
/*******************************************
Bug 8893 ICE with bad struct literal
*******************************************/
struct Foo8893
{
char[3] data;
}
int bar8893(Foo8893 f)
{
return f.data[0];
}
static assert(!is(typeof(compiles!(bar8893(Foo8893(['a','b']))))));
/*******************************************
non-Cow struct literals
*******************************************/
struct Zadok
{
int[3] z;
char[4] s = void;
ref int[] fog(ref int[] q) { return q; }
int bfg()
{
z[0] = 56;
auto zs = z[];
fog(zs) = [56, 6, 8];
assert(z[0] == 56);
assert(z[1] == 61);
assert(z[2] == 61);
assert(zs[0] == 56);
assert(zs[1] == 6);
return zs[2];
}
}
struct Vug
{
Zadok p;
int[] other;
}
int quop()
{
int[] heap = new int[5];
heap[] = 738;
Zadok pong;
pong.z = 3;
int[] w = pong.z;
assert(w[0] == 3);
Zadok phong;
phong.z = 61;
pong = phong;
assert(w[0] == 61);
Vug b = Vug(Zadok(17, "abcd"));
b = Vug(Zadok(17, "abcd"), heap);
b.other[2] = 78;
assert(heap[2] == 78);
char[] y = b.p.s;
assert(y[2] == 'c');
phong.s = ['z','x','f', 'g'];
w = b.p.z;
assert(y[2] == 'c');
assert(w[0] == 17);
b.p = phong;
assert(y[2] == 'f');
Zadok wok = Zadok(6, "xyzw");
b.p = wok;
assert(y[2] == 'z');
b.p = phong;
assert(w[0] == 61);
Vug q;
q.p = pong;
return pong.bfg();
}
static assert(quop() == 8);
static assert(quop() == 8); // check for clobbering
/**************************************************
Bug 5676 tuple assign of struct that has void opAssign
**************************************************/
struct S5676
{
int x;
void opAssign(S5676 rhs) { x = rhs.x; }
}
struct Tup5676(E...)
{
E g;
void foo(E values) { g = values; }
}
bool ice5676()
{
Tup5676!(S5676) q;
q.foo(S5676(3));
assert(q.g[0].x == 3);
return true;
}
static assert(ice5676());
/**************************************************
Bug 5682 Wrong CTFE with operator overloading
**************************************************/
struct A
{
int n;
auto opBinary(string op : "*")(A rhs)
{
return A(n * rhs.n);
}
}
A foo(A[] lhs, A[] rhs)
{
A current;
for (size_t k = 0; k < rhs.length; ++k)
{
current = lhs[k] * rhs[k];
}
return current;
}
auto test()
{
return foo([A(1), A(2)], [A(3), A(4)]);
}
static assert(test().n == 8);
/**************************************************
Attempt to modify a read-only string literal
**************************************************/
struct Xarg
{
char[] s;
}
int zfs(int n)
{
char[] m = "exy".dup;
if (n == 1)
{
// it's OK to cast to const, then cast back
string ss = cast(string)m;
m = cast(char[])ss;
m[2]='q';
return 56;
}
auto q = Xarg(cast(char[])"abc");
assert(q.s[1] == 'b');
if (n == 2)
q.s[1] = 'p';
else if (n == 3)
q.s[0 .. $] = 'p';
char* w = &q.s[2];
if (n == 4)
*w = 'z';
return 76;
}
static assert(!is(typeof(compiles!(zfs(2)))));
static assert(!is(typeof(compiles!(zfs(3)))));
static assert(!is(typeof(compiles!(zfs(4)))));
static assert( is(typeof(compiles!(zfs(1)))));
static assert( is(typeof(compiles!(zfs(5)))));
/**************************************************
.dup must protect string literals
**************************************************/
string mutateTheImmutable(immutable string _s)
{
char[] s = _s.dup;
foreach (ref c; s)
c = 'x';
return s.idup;
}
string doharm(immutable string _name)
{
return mutateTheImmutable(_name[2 .. $].idup);
}
enum victimLiteral = "CL_INVALID_CONTEXT";
enum thug = doharm(victimLiteral);
static assert(victimLiteral == "CL_INVALID_CONTEXT");
/**************************************************
Use $ in a slice of a dotvar slice
**************************************************/
int sliceDollar()
{
Xarg z;
z.s = new char[20];
z.s[] = 'b';
z.s = z.s[2 .. $ - 2];
z.s[$ - 2] = 'c';
return z.s[$ - 2];
}
static assert(sliceDollar() == 'c');
/**************************************************
Variation of 5972 which caused segfault
**************************************************/
int bug5972crash()
{
char[] z = "abc".dup;
char[][] a = [null, null];
a[0] = z[0 .. 2];
a[0][1] = 'q';
return 56;
}
static assert(bug5972crash() == 56);
/**************************************************
String slice assignment through ref parameter
**************************************************/
void popft(A)(ref A a)
{
a = a[1 .. $];
}
int sdfgasf()
{
auto scp = "abc".dup;
popft(scp);
return 1;
}
static assert(sdfgasf() == 1);
/**************************************************
8830 slice of slice.ptr
**************************************************/
string bug8830(string s)
{
auto ss = s[1 .. $];
return ss.ptr[0 .. 2];
}
static assert(bug8830("hello") == "el");
/**************************************************
8608 ICE
**************************************************/
void bug8608(ref int m) {}
void test8608()
{
int z;
int foo(bool b)
{
if (b)
bug8608(z);
return 1;
}
static assert( is(typeof(compiles!(foo(false)))));
static assert(!is(typeof(compiles!(foo(true) ))));
}
/**************************************************
Bug 7770
**************************************************/
immutable char[] foo7770 = "abcde";
int bug7770a(string a)
{
return 1;
}
bool bug7770b(char c)
{
return true;
}
static assert(bug7770a(foo7770[0 .. $]));
static assert(bug7770b(foo7770[$ - 2]));
void baz7770()
{
static assert(bug7770a(foo7770[0 .. $]));
static assert(bug7770b(foo7770[$ - 2]));
}
/**************************************************
8601 ICE
**************************************************/
dchar bug8601(dstring s)
{
dstring w = s[1 .. $];
return w[0];
}
enum dstring e8601 = [cast(dchar)'o', 'n'];
static assert(bug8601(e8601) == 'n');
/**************************************************
Bug 6015
**************************************************/
struct Foo6015
{
string field;
}
bool func6015(string input)
{
Foo6015 foo;
foo.field = input[0 .. $];
assert(foo.field == "test");
foo.field = "test2";
assert(foo.field != "test");
assert(foo.field == "test2");
return true;
}
static assert(func6015("test"));
/**************************************************
Bug 6001
**************************************************/
void bug6001e(ref int[] s)
{
int[] r = s;
s ~= 0;
}
bool bug6001f()
{
int[] s;
bug6001e(s);
return true;
}
static assert(bug6001f());
// Assignment to AAs
void blah(int[char] as)
{
auto k = [6: as];
as = k[6];
}
int blaz()
{
int[char] q;
blah(q);
return 67;
}
static assert(blaz() == 67);
void bug6001g(ref int[] w)
{
w = [88];
bug6001e(w);
w[0] = 23;
}
bool bug6001h()
{
int[] s;
bug6001g(s);
assert(s.length == 2);
assert(s[1] == 0);
assert(s[0] == 23);
return true;
}
static assert(bug6001h());
/**************************************************
10243 wrong code *&arr as ref parameter
10551 wrong code (&arr)[0] as ref parameter
**************************************************/
void bug10243(ref int n)
{
n = 3;
}
void bug10551(int* p)
{
bug10243(p[0]);
}
bool test10243()
{
int[1] arr;
bug10243(*arr.ptr);
assert(arr[0] == 3);
int[1] arr2;
bug10551(arr2.ptr);
assert(arr2[0] == 3);
int v;
bug10551(&v);
assert(v == 3);
return true;
}
static assert(test10243());
/**************************************************
Bug 4910
**************************************************/
int bug4910(int a)
{
return a;
}
static int var4910;
static assert(!is(typeof(Compiles!(bug4910(var4910)))));
static assert(bug4910(123));
/**************************************************
Bug 5845 - Regression(2.041)
**************************************************/
void test5845(ulong cols) {}
uint solve(bool niv, ref ulong cols)
{
if (niv)
solve(false, cols);
else
test5845(cols);
return 65;
}
ulong nqueen(int n)
{
ulong cols = 0;
return solve(true, cols);
}
static assert(nqueen(2) == 65);
/**************************************************
Bug 5258
**************************************************/
struct Foo5258 { int x; }
void bar5258(int n, ref Foo5258 fong)
{
if (n)
bar5258(n - 1, fong);
else
fong.x++;
}
int bug5258()
{
Foo5258 foo5258 = Foo5258();
bar5258(1, foo5258);
return 45;
}
static assert(bug5258() == 45);
struct Foo5258b { int[2] r; }
void baqopY(int n, ref int[2] fongo)
{
if (n)
baqopY(n - 1, fongo);
else
fongo[0]++;
}
int bug5258b()
{
Foo5258b qq;
baqopY(1, qq.r);
return 618;
}
static assert(bug5258b() == 618);
// Notice that this case involving reassigning the dynamic array
struct Foo5258c { int[] r; }
void baqop(int n, ref int[] fongo)
{
if (n)
baqop(n - 1, fongo);
else
{
fongo = new int[20];
fongo[0]++;
}
}
size_t bug5258c()
{
Foo5258c qq;
qq.r = new int[30];
baqop(1, qq.r);
return qq.r.length;
}
static assert(bug5258c() == 20);
/**************************************************
Bug 6049
**************************************************/
struct Bug6049
{
int m;
this(int x) { m = x; }
invariant() { }
}
const Bug6049[] foo6049 = [Bug6049(6), Bug6049(17)];
static assert(foo6049[0].m == 6);
/**************************************************
Bug 6052
**************************************************/
struct Bug6052
{
int a;
}
bool bug6052()
{
Bug6052[2] arr;
for (int i = 0; i < 2; ++ i)
{
Bug6052 el = {i};
Bug6052 ek = el;
arr[i] = el;
el.a = i + 2;
assert(ek.a == i); // ok
assert(arr[i].a == i); // fail
}
assert(arr[1].a == 1); // ok
assert(arr[0].a == 0); // fail
return true;
}
static assert(bug6052());
bool bug6052b()
{
int[][1] arr;
int[1] z = [7];
arr[0] = z;
assert(arr[0][0] == 7);
arr[0] = z;
z[0] = 3;
assert(arr[0][0] == 3);
return true;
}
static assert(bug6052b());
struct Bug6052c
{
int x;
this(int a) { x = a; }
}
int bug6052c()
{
Bug6052c[] pieces = [];
for (int c = 0; c < 2; ++ c)
pieces ~= Bug6052c(c);
assert(pieces[1].x == 1);
assert(pieces[0].x == 0);
return 1;
}
static assert(bug6052c() == 1);
static assert(bug6052c() == 1);
static assert({
Bug6052c[] pieces = [];
pieces.length = 2;
int c = 0;
pieces[0] = Bug6052c(c);
++c;
pieces[1] = Bug6052c(c);
assert(pieces[0].x == 0);
return true;
}());
static assert({
int[1][] pieces = [];
pieces.length = 2;
for (int c = 0; c < 2; ++ c)
pieces[c][0] = c;
assert(pieces[1][0] == 1);
assert(pieces[0][0] == 0);
return true;
}());
static assert({
Bug6052c[] pieces = [];
for (int c = 0; c < 2; ++ c)
pieces ~= Bug6052c(c);
assert(pieces[1].x == 1);
assert(pieces[0].x == 0);
return true;
}());
static assert({
int[1] z = 7;
int[1][] pieces = [z,z];
pieces[1][0]=3;
assert(pieces[0][0] == 7);
pieces = pieces ~ [z,z];
pieces[3][0] = 16;
assert(pieces[2][0] == 7);
pieces = [z,z] ~ pieces;
pieces[5][0] = 16;
assert(pieces[4][0] == 7);
return true;
}());
/**************************************************
Bug 6749
**************************************************/
struct CtState
{
string code;
}
CtState bug6749()
{
CtState[] pieces;
CtState r = CtState("correct");
pieces ~= r;
r = CtState("clobbered");
return pieces[0];
}
static assert(bug6749().code == "correct");
/**************************************************
Index + slice assign to function returns
**************************************************/
int[] funcRetArr(int[] a)
{
return a;
}
int testFuncRetAssign()
{
int[] x = new int[20];
funcRetArr(x)[2] = 4;
assert(x[2] == 4);
funcRetArr(x)[] = 27;
assert(x[15] == 27);
return 5;
}
static assert(testFuncRetAssign() == 5);
int keyAssign()
{
int[int] pieces;
pieces[3] = 1;
pieces.keys[0] = 4;
pieces.values[0] = 27;
assert(pieces[3] == 1);
return 5;
}
static assert(keyAssign() == 5);
/**************************************************
Bug 6054 -- AA literals
**************************************************/
enum x6054 = {
auto p = {
int[string] pieces;
pieces[['a'].idup] = 1;
return pieces;
}();
return p;
}();
/**************************************************
Bug 6077
**************************************************/
enum bug6077 = {
string s;
string t;
return s ~ t;
}();
/**************************************************
Bug 6078 -- Pass null array by ref
**************************************************/
struct Foo6078
{
int[] bar;
}
static assert({
Foo6078 f;
int i;
foreach (ref e; f.bar)
{
i += e;
}
return i;
}() == 0);
int bug6078(ref int[] z)
{
int[] q = z;
return 2;
}
static assert({
Foo6078 f;
return bug6078(f.bar);
}() == 2);
/**************************************************
Bug 6079 -- Array bounds checking
**************************************************/
static assert(!is(typeof(compiles!({
int[] x = [1, 2, 3, 4];
x[4] = 1;
return true;
}()
))));
/**************************************************
Bug 6100
**************************************************/
struct S6100
{
int a;
}
S6100 init6100(int x)
{
S6100 s = S6100(x);
return s;
}
static const S6100[2] s6100a = [init6100(1), init6100(2)];
static assert(s6100a[0].a == 1);
/**************************************************
Bug 4825 -- failed with -inline
**************************************************/
int a4825()
{
int r;
return r;
}
int b4825()
{
return a4825();
}
void c4825()
{
void d()
{
auto e = b4825();
}
static const int f = b4825();
}
/**************************************************
Bug 5708 -- failed with -inline
**************************************************/
string b5708(string s) { return s; }
string a5708(string s) { return b5708(s); }
void bug5708()
{
void m() { a5708("lit"); }
static assert(a5708("foo") == "foo");
static assert(a5708("bar") == "bar");
}
/**************************************************
Bug 6120 -- failed with -inline
**************************************************/
struct Bug6120(T)
{
this(int x) { }
}
static assert({
auto s = Bug6120!int(0);
return true;
}());
/**************************************************
Bug 6123 -- failed with -inline
**************************************************/
struct Bug6123(T)
{
void f() {}
// can also trigger if the struct is normal but f is template
}
static assert({
auto piece = Bug6123!int();
piece.f();
return true;
}());
/**************************************************
Bug 6053 -- ICE involving pointers
**************************************************/
static assert({
int* a = null;
assert(a is null);
assert(a == null);
return true;
}());
static assert({
int b;
int* a = &b;
assert(a !is null);
*a = 7;
assert(b == 7);
assert(*a == 7);
return true;
}());
int dontbreak6053()
{
auto q = &dontbreak6053;
void caz() {}
auto tr = &caz;
return 5;
}
static assert(dontbreak6053());
static assert({
int a;
*(&a) = 15;
assert(a == 15);
assert(*(&a) == 15);
return true;
}());
static assert({
int a = 5, b = 6, c = 2;
assert(*(c ? &a : &b) == 5);
assert(*(!c ? &a : &b) == 6);
return true;
}());
static assert({
int a, b, c;
(c ? a : b) = 1;
return true;
}());
static assert({
int a, b, c = 1;
int* p = &a;
(c ? *p : b) = 51;
assert(a == 51);
return true;
}());
/**************************************************
Pointer arithmetic, dereference, and comparison
**************************************************/
// dereference null pointer
static assert(!is(typeof(compiles!({
int a, b, c = 1;
int* p;
(c ? *p : b) = 51;
return 6;
}()
))));
static assert(!is(typeof(compiles!({
int* a = null;
assert(*a != 6);
return 72;
}()
))));
// cannot <, > compare pointers to different arrays
static assert(!is(typeof(compiles!({
int[5] a, b;
bool c = (&a[0] > &b[0]);
return 72;
}()
))));
// can ==, is, !is, != compare pointers for different arrays
static assert({
int[5] a;
int[5] b;
assert(!(&a[0] == &b[0]));
assert(&a[0] != &b[0]);
assert(!(&a[0] is &b[0]));
assert(&a[0] !is &b[0]);
return 72;
}());
static assert({
int[5] a;
a[0] = 25;
a[1] = 5;
int* b = &a[1];
assert(*b == 5);
*b = 34;
int c = *b;
*b += 6;
assert(b == &a[1]);
assert(b != &a[0]);
assert(&a[0] < &a[1]);
assert(&a[0] <= &a[1]);
assert(!(&a[0] >= &a[1]));
assert(&a[4] > &a[0]);
assert(c == 34);
assert(*b == 40);
assert(a[1] == 40);
return true;
}());
static assert({
int[12] x;
int* p = &x[10];
int* q = &x[4];
return p - q;
}() == 6);
static assert({
int[12] x;
int* p = &x[10];
int* q = &x[4];
q = p;
assert(p == q);
q = &x[4];
assert(p != q);
q = q + 6;
assert(q is p);
return 6;
}() == 6);
static assert({
int[12] x;
int[] y = x[2 .. 8];
int* p = &y[4];
int* q = &x[6];
assert(p == q);
p = &y[5];
assert(p > q);
p = p + 5; // OK, as long as we don't dereference
assert(p > q);
return 6;
}() == 6);
static assert({
char[12] x;
const(char)* p = "abcdef";
const (char)* q = p;
q = q + 2;
assert(*q == 'c');
assert(q > p);
assert(q - p == 2);
assert(p - q == -2);
q = &x[7];
p = &x[1];
assert(q>p);
return 6;
}() == 6);
// Relations involving null pointers
bool nullptrcmp()
{
// null tests
void* null1 = null, null2 = null;
int x = 2;
void* p = &x;
assert(null1 == null2);
assert(null1 is null2);
assert(null1 <= null2);
assert(null1 >= null2);
assert(!(null1 > null2));
assert(!(null2 > null1));
assert(null1 != p);
assert(null1 !is p);
assert(p != null1);
assert(p !is null1);
assert(null1 <= p);
assert(p >= null2);
assert(p > null1);
assert(!(null1 > p));
return true;
}
static assert(nullptrcmp());
/**************************************************
10840 null pointer in dotvar
**************************************************/
struct Data10840
{
bool xxx;
}
struct Bug10840
{
Data10840* _data;
}
bool bug10840(int n)
{
Bug10840 stack;
if (n == 1)
{
// detect deref through null pointer
return stack._data.xxx;
}
// Wrong-code for ?:
return stack._data ? false : true;
}
static assert(bug10840(0));
static assert(!is(typeof(Compileable!(bug10840(1)))));
/**************************************************
8216 ptr inside a pointer range
**************************************************/
// Four-pointer relations. Return true if [p1 .. p2] points inside [q1 .. q2]
// (where the end points dont coincide).
bool ptr4cmp(void* p1, void* p2, void* q1, void* q2)
{
// Each compare can be written with <, <=, >, or >=.
// Either && or || can be used, giving 32 permutations.
// Additionally each compare can be negated with !, yielding 128 in total.
bool b1 = (p1 > q1 && p2 <= q2);
bool b2 = (p1 > q1 && p2 < q2);
bool b3 = (p1 >= q1 && p2 <= q2);
bool b4 = (p1 >= q1 && p2 < q2);
bool b5 = (q1 <= p1 && q2 > p2);
bool b6 = (q1 <= p1 && q2 >= p2);
bool b7 = (p2 <= q2 && p1 > q1);
bool b8 = (!(p1 <= q1) && p2 <= q2);
bool b9 = (!(p1 <= q1) && !(p2 > q2));
bool b10 = (!!!(p1 <= q1) && !(p2 > q2));
assert(b1 == b2 && b1 == b3 && b1 == b4 && b1 == b5 && b1 == b6);
assert(b1 == b7 && b1 == b8 && b1 == b9 && b1 == b10);
bool c1 = (p1 <= q1 || p2 > q2);
assert(c1 == !b1);
bool c2 = (p1 < q1 || p2 >= q2);
bool c3 = (!(q1 <= p1) || !(q2 >= p2));
assert(c1 == c2 && c1 == c3);
return b1;
}
bool bug8216()
{
int[4] a;
int[13] b;
int v;
int* p = &v;
assert(!ptr4cmp(&a[0], &a[3], p, p));
assert(!ptr4cmp(&b[2], &b[9], &a[1], &a[2]));
assert(!ptr4cmp(&b[1], &b[9], &b[2], &b[8]));
assert( ptr4cmp(&b[2], &b[8], &b[1], &b[9]));
return 1;
}
static assert(bug8216());
/**************************************************
6517 ptr++, ptr--
**************************************************/
int bug6517()
{
int[] arr = [1, 2, 3];
auto startp = arr.ptr;
auto endp = arr.ptr + arr.length;
for (; startp < endp; startp++) {}
startp = arr.ptr;
assert(startp++ == arr.ptr);
assert(startp != arr.ptr);
assert(startp-- != arr.ptr);
assert(startp == arr.ptr);
return 84;
}
static assert(bug6517() == 84);
/**************************************************
Out-of-bounds pointer assignment and deference
**************************************************/
int ptrDeref(int ofs, bool wantDeref)
{
int[5] a;
int* b = &a[0];
b = b + ofs; // OK
if (wantDeref)
return *b; // out of bounds
return 72;
}
static assert(!is(typeof(compiles!(ptrDeref(-1, true)))));
static assert( is(typeof(compiles!(ptrDeref(4, true)))));
static assert( is(typeof(compiles!(ptrDeref(5, false)))));
static assert(!is(typeof(compiles!(ptrDeref(5, true)))));
static assert(!is(typeof(compiles!(ptrDeref(6, false)))));
static assert(!is(typeof(compiles!(ptrDeref(6, true)))));
/**************************************************
Pointer +=
**************************************************/
static assert({
int[12] x;
int zzz;
assert(&zzz);
int* p = &x[10];
int* q = &x[4];
q = p;
assert(p == q);
q = &x[4];
assert(p != q);
q += 4;
assert(q == &x[8]);
q = q - 2;
q = q + 4;
assert(q is p);
return 6;
}() == 6);
/**************************************************
Reduced version of bug 5615
**************************************************/
const(char)[] passthrough(const(char)[] x)
{
return x;
}
sizediff_t checkPass(Char1)(const(Char1)[] s)
{
const(Char1)[] balance = s[1 .. $];
return passthrough(balance).ptr - s.ptr;
}
static assert(checkPass("foobar") == 1);
/**************************************************
Pointers must not escape from CTFE
**************************************************/
struct Toq
{
const(char)* m;
}
Toq ptrRet(bool b)
{
string x = "abc";
return Toq(b ? x[0 .. 1].ptr : null);
}
static assert(is(typeof(compiles!({
enum Toq boz = ptrRet(false); // OK - ptr is null
Toq z = ptrRet(true); // OK -- ptr doesn't escape
return 4;
}()
))));
static assert(!is(typeof(compiles!({
enum Toq boz = ptrRet(true); // fail - ptr escapes
return 4;
}()
))));
/**************************************************
Pointers to struct members
**************************************************/
struct Qoz
{
int w;
int[3] yof;
}
static assert({
int[3] gaz;
gaz[2] = 3156;
Toq z = ptrRet(true);
auto p = z.m;
assert(*z.m == 'a');
assert(*p == 'a');
auto q = &z.m;
assert(*q == p);
assert(**q == 'a');
Qoz g = Qoz(2, [5, 6, 7]);
auto r = &g.w;
assert(*r == 2);
r = &g.yof[1];
assert(*r == 6);
g.yof[0] = 15;
++r;
assert(*r == 7);
r -= 2;
assert(*r == 15);
r = &gaz[0];
r += 2;
assert(*r == 3156);
return *p;
}() == 'a');
struct AList
{
AList* next;
int value;
static AList* newList()
{
AList[] z = new AList[1];
return &z[0];
}
static AList* make(int i, int j)
{
auto r = newList();
r.next = (new AList[1]).ptr;
r.value = 1;
AList* z = r.next;
(*z).value = 2;
r.next.value = j;
assert(r.value == 1);
assert(r.next.value == 2);
r.next.next = &(new AList[1])[0];
assert(r.next.next != null);
assert(r.next.next);
r.next.next.value = 3;
assert(r.next.next.value == 3);
r.next.next = newList();
r.next.next.value = 9;
return r;
}
static int checkList()
{
auto r = make(1,2);
assert(r.value == 1);
assert(r.next.value == 2);
assert(r.next.next.value == 9);
return 2;
}
}
static assert(AList.checkList() == 2);
/**************************************************
7194 pointers as struct members
**************************************************/
struct S7194 { int* p, p2; }
int f7194()
{
assert(S7194().p == null);
assert(!S7194().p);
assert(S7194().p == S7194().p2);
S7194 s = S7194();
assert(!s.p);
assert(s.p == null);
assert(s.p == s.p2);
int x;
s.p = &x;
s.p2 = s.p;
assert(s.p == &x);
return 0;
}
int g7194()
{
auto s = S7194();
assert(s.p); // should fail
return 0;
}
static assert(f7194() == 0);
static assert(!is(typeof(compiles!(g7194()))));
/**************************************************
7248 recursive struct pointers in array
**************************************************/
struct S7248 { S7248* ptr; }
bool bug7248()
{
S7248[2] sarr;
sarr[0].ptr = &sarr[1];
sarr[0].ptr = null;
S7248* t = sarr[0].ptr;
return true;
}
static assert(bug7248());
/**************************************************
7216 calling a struct pointer member
**************************************************/
struct S7216
{
S7216* p;
int t;
void f() { }
void g() { ++t; }
}
bool bug7216()
{
S7216 s0, s1;
s1.t = 6;
s0.p = &s1;
s0.p.f();
s0.p.g();
assert(s1.t == 7);
return true;
}
static assert(bug7216());
/**************************************************
10858 Wrong code with array of pointers
**************************************************/
bool bug10858()
{
int*[4] x;
x[0] = null;
assert(x[0] == null);
return true;
}
static assert(bug10858());
/**************************************************
12528 - painting inout type for value type literals
**************************************************/
inout(T)[] dup12528(T)(inout(T)[] a)
{
inout(T)[] res;
foreach (ref e; a)
res ~= e;
return res;
}
enum arr12528V1 = dup12528([0]);
enum arr12528V2 = dup12528([0, 1]);
static assert(arr12528V1 == [0]);
static assert(arr12528V2 == [0, 1]);
enum arr12528C1 = dup12528([new immutable Object]);
enum arr12528C2 = dup12528([new immutable Object, new immutable Object]);
static assert(arr12528C1.length == 1);
static assert(arr12528C2.length == 2 && arr12528C2[0] !is arr12528C2[1]);
/**************************************************
9745 Allow pointers to static variables
**************************************************/
shared int x9745;
shared int[5] y9745;
shared(int)* bug9745(int m)
{
auto k = &x9745;
auto j = &x9745;
auto p = &y9745[0];
auto q = &y9745[3];
assert(j - k == 0);
assert(j == k);
assert(q - p == 3);
--q;
int a = 0;
assert(p + 2 == q);
if (m == 7)
{
auto z1 = y9745[0 .. 2]; // slice global pointer
}
if (m == 8)
p[1] = 7; // modify through a pointer
if (m == 9)
a = p[1]; // read from a pointer
if (m == 0)
return &x9745;
return &y9745[1];
}
int test9745(int m)
{
bug9745(m);
// type painting
shared int* w = bug9745(0);
return 1;
}
shared int* w9745a = bug9745(0);
shared int* w9745b = bug9745(1);
static assert( is(typeof(compiles!(test9745(6)))));
static assert(!is(typeof(compiles!(test9745(7)))));
static assert(!is(typeof(compiles!(test9745(8)))));
static assert(!is(typeof(compiles!(test9745(9)))));
// pointers cast from an absolute address
// (mostly applies to fake pointers, eg Windows HANDLES)
bool test9745b()
{
void* b6 = cast(void*)0xFEFEFEFE;
void* b7 = cast(void*)0xFEFEFEFF;
assert(b6 is b6);
assert(b7 != b6);
return true;
}
static assert(test9745b());
/**************************************************
9364 ICE with pointer to local struct
**************************************************/
struct S9364
{
int i;
}
bool bug9364()
{
S9364 s;
auto k = (&s).i;
return 1;
}
static assert(bug9364());
/**************************************************
10251 Pointers to const globals
**************************************************/
static const int glob10251 = 7;
const(int)* bug10251()
{
return &glob10251;
}
static a10251 = &glob10251; // OK
static b10251 = bug10251();
/**************************************************
4065 [CTFE] AA "in" operator doesn't work
**************************************************/
bool bug4065(string s)
{
enum int[string] aa = ["aa":14, "bb":2];
int* p = s in aa;
if (s == "aa")
assert(*p == 14);
else if (s == "bb")
assert(*p == 2);
else
assert(!p);
int[string] zz;
assert(!("xx" in zz));
bool c = !p;
return cast(bool)(s in aa);
}
static assert(!bug4065("xx"));
static assert( bug4065("aa"));
static assert( bug4065("bb"));
/**************************************************
12689 - assigning via pointer from 'in' expression
**************************************************/
int g12689()
{
int[int] aa;
aa[1] = 13;
assert(*(1 in aa) == 13);
*(1 in aa) = 42;
return aa[1];
}
static assert(g12689() == 42);
/**************************************************
Pointers in ? :
**************************************************/
static assert({
int[2] x;
int* p = &x[1];
return p ? true: false;
}());
/**************************************************
Pointer slicing
**************************************************/
int ptrSlice()
{
auto arr = new int[5];
int* x = &arr[0];
int[] y = x[0 .. 5];
x[1 .. 3] = 6;
++x;
x[1 .. 3] = 14;
assert(arr[1] == 6);
assert(arr[2] == 14);
//x[-1 .. 4] = 5; // problematic because negative lower boundary will throw RangeError in runtime
(x - 1)[0 .. 3] = 5;
int[] z = arr[1 .. 2];
z.length = 4;
z[$ - 1] = 17;
assert(arr.length == 5);
return 2;
}
static assert(ptrSlice() == 2);
/**************************************************
6344 - create empty slice from null pointer
**************************************************/
static assert({
char* c = null;
auto m = c[0 .. 0];
return true;
}());
/**************************************************
8365 - block assignment of enum arrays
**************************************************/
enum E8365 { first = 7, second, third, fourth }
static assert({ E8365[2] x; return x[0]; }() == E8365.first);
static assert({ E8365[2][2] x; return x[0][0]; }() == E8365.first);
static assert({ E8365[2][2][2] x; return x[0][0][0]; }() == E8365.first);
/**************************************************
4448 - labelled break + continue
**************************************************/
int bug4448()
{
int n = 2;
L1:
do
{
switch(n)
{
case 5:
return 7;
default:
n = 5;
break L1;
}
int w = 7;
} while (0);
return 3;
}
static assert(bug4448() == 3);
int bug4448b()
{
int n = 2;
L1:
for (n = 2; n < 5; ++n)
{
for (int m = 1; m < 6; ++m)
{
if (n < 3)
{
assert(m == 1);
continue L1;
}
}
break;
}
return 3;
}
static assert(bug4448b() == 3);
/**************************************************
6985 - non-constant case
**************************************************/
int bug6985(int z)
{
int q = z * 2 - 6;
switch(z)
{
case q:
q = 87;
break;
default:
}
return q;
}
static assert(bug6985(6) == 87);
/**************************************************
6281 - [CTFE] A null pointer '!is null' returns 'true'
**************************************************/
static assert(!{
auto p = null;
return p !is null;
}());
static assert(!{
auto p = null;
return p != null;
}());
/**************************************************
6331 - evaluate SliceExp on if condition
**************************************************/
bool bug6331(string s)
{
if (s[0 .. 1])
return true;
return false;
}
static assert(bug6331("str"));
/**************************************************
6283 - assign to AA with slice as index
**************************************************/
static assert({
immutable p = "pp";
int[string] pieces = [p: 0];
pieces["qq"] = 1;
return true;
}());
static assert({
immutable renames = [0: "pp"];
int[string] pieces;
pieces[true ? renames[0] : "qq"] = 1;
pieces["anything"] = 1;
return true;
}());
static assert({
immutable qq = "qq";
string q = qq;
int[string] pieces = ["a":1];
pieces[q] = 0;
string w = "ab";
int z = pieces[w[0 .. 1]];
assert(z == 1);
return true;
}());
/**************************************************
6282 - dereference 'in' of an AA
**************************************************/
static assert({
int[] w = new int[4];
w[2] = 6;
auto c = [5: w];
auto kk = (*(5 in c))[2];
(*(5 in c))[2] = 8;
(*(5 in c))[1 .. $ - 2] = 4;
auto a = [4:"1"];
auto n = *(4 in a);
return n;
}() == "1");
/**************************************************
6337 - member function call on struct literal
**************************************************/
struct Bug6337
{
int k;
void six()
{
k = 6;
}
int ctfe()
{
six();
return k;
}
}
static assert(Bug6337().ctfe() == 6);
/**************************************************
6603 call manifest function pointer
**************************************************/
int f6603(int a) { return a + 5; }
enum bug6603 = &f6603;
static assert(bug6603(6) == 11);
/**************************************************
6375
**************************************************/
struct D6375
{
int[] arr;
}
A6375 a6375(int[] array)
{
return A6375(array);
}
struct A6375
{
D6375* _data;
this(int[] arr)
{
_data = new D6375;
_data.arr = arr;
}
int[] data()
{
return _data.arr;
}
}
static assert({
int[] a = [1, 2];
auto app2 = a6375(a);
auto data = app2.data();
return true;
}());
/**************************************************
6280 Converting pointers to bool
**************************************************/
static assert({
if ((0 in [0:0])) {}
if ((0 in [0:0]) && (0 in [0:0])) {}
return true;
}());
/**************************************************
6276 ~=
**************************************************/
struct Bug6276
{
int[] i;
}
static assert({
Bug6276 foo;
foo.i ~= 1;
foo.i ~= 2;
return true;
}());
/**************************************************
6374 ptr[n] = x, x = ptr[n]
**************************************************/
static assert({
int[] arr = [1];
arr.ptr[0] = 2;
auto k = arr.ptr[0];
assert(k == 2);
return arr[0];
}() == 2);
/**************************************************
6306 recursion and local variables
**************************************************/
void recurse6306()
{
bug6306(false);
}
bool bug6306(bool b)
{
int x = 0;
if (b)
recurse6306();
assert(x == 0);
x = 1;
return true;
}
static assert(bug6306(true));
/**************************************************
6386 ICE on unsafe pointer cast
**************************************************/
static assert(!is(typeof(compiles!({
int x = 123;
int* p = &x;
float z;
float* q = cast(float*)p;
return true;
}()
))));
static assert({
int[] x = [123, 456];
int* p = &x[0];
auto m = cast(const(int)*)p;
auto q = p;
return *q;
}());
/**************************************************
6420 ICE on dereference of invalid pointer
**************************************************/
static assert({
// Should compile, but pointer can't be dereferenced
int x = 123;
int* p = cast(int*)x;
auto q = cast(char*)x;
auto r = cast(char*)323;
// Valid const-changing cast
const float *m = cast(immutable float*)[1.2f,2.4f,3f];
return true;
}()
);
static assert(!is(typeof(compiles!({
int x = 123;
int* p = cast(int*)x;
int a = *p;
return true;
}()
))));
static assert(!is(typeof(compiles!({
int* p = cast(int*)123;
int a = *p;
return true;
}()
))));
static assert(!is(typeof(compiles!({
auto k = cast(int*)45;
*k = 1;
return true;
}()
))));
static assert(!is(typeof(compiles!({
*cast(float*)"a" = 4.0;
return true;
}()
))));
static assert(!is(typeof(compiles!({
float f = 2.8;
long *p = &f;
return true;
}()
))));
static assert(!is(typeof(compiles!({
long *p = cast(long*)[1.2f, 2.4f, 3f];
return true;
}()
))));
/**************************************************
6250 deref pointers to array
**************************************************/
int[]* simple6250(int[]* x) { return x; }
void swap6250(int[]* lhs, int[]* rhs)
{
int[] kk = *lhs;
assert(simple6250(lhs) == lhs);
lhs = simple6250(lhs);
assert(kk[0] == 18);
assert((*lhs)[0] == 18);
assert((*rhs)[0] == 19);
*lhs = *rhs;
assert((*lhs)[0] == 19);
*rhs = kk;
assert(*rhs == kk);
assert(kk[0] == 18);
assert((*rhs)[0] == 18);
}
int ctfeSort6250()
{
int[][2] x;
int[3] a = [17, 18, 19];
x[0] = a[1 .. 2];
x[1] = a[2 .. $];
assert(x[0][0] == 18);
assert(x[0][1] == 19);
swap6250(&x[0], &x[1]);
assert(x[0][0] == 19);
assert(x[1][0] == 18);
a[1] = 57;
assert(x[0][0] == 19);
return x[1][0];
}
static assert(ctfeSort6250() == 57);
/**************************************************
6672 circular references in array
**************************************************/
void bug6672(ref string lhs, ref string rhs)
{
auto tmp = lhs;
lhs = rhs;
rhs = tmp;
}
static assert({
auto kw = ["a"];
bug6672(kw[0], kw[0]);
return true;
}());
void slice6672(ref string[2] agg, ref string lhs)
{
agg[0 .. $] = lhs;
}
static assert({
string[2] kw = ["a", "b"];
slice6672(kw, kw[0]);
assert(kw[0] == "a");
assert(kw[1] == "a");
return true;
}());
// an unrelated rejects-valid bug
static assert({
string[2] kw = ["a", "b"];
kw[0 .. 2] = "x";
return true;
}());
void bug6672b(ref string lhs, ref string rhs)
{
auto tmp = lhs;
assert(tmp == "a");
lhs = rhs;
assert(tmp == "a");
rhs = tmp;
}
static assert({
auto kw=["a", "b"];
bug6672b(kw[0], kw[1]);
assert(kw[0] == "b");
assert(kw[1] == "a");
return true;
}());
/**************************************************
6399 (*p).length = n
**************************************************/
struct A6399
{
int[] arr;
int subLen()
{
arr = [1, 2, 3, 4, 5];
arr.length -= 1;
return cast(int)arr.length;
}
}
static assert({
A6399 a;
return a.subLen();
}() == 4);
/**************************************************
7789 (*p).length++ where *p is null
**************************************************/
struct S7789
{
size_t foo()
{
_ary.length += 1;
return _ary.length;
}
int[] _ary;
}
static assert(S7789().foo());
/**************************************************
6418 member named 'length'
**************************************************/
struct Bug6418
{
size_t length() { return 189; }
}
static assert(Bug6418.init.length == 189);
/**************************************************
4021 rehash
**************************************************/
bool bug4021()
{
int[int] aa = [1: 1];
aa.rehash;
return true;
}
static assert(bug4021());
/**************************************************
11629 crash on AA.rehash
**************************************************/
struct Base11629
{
alias T = ubyte, Char = char;
alias String = immutable(Char)[];
const Char[T] toChar;
this(int _dummy)
{
Char[T] toCharTmp = [0:'A'];
toChar = toCharTmp.rehash;
}
}
enum ct11629 = Base11629(4);
/**************************************************
3512 foreach (dchar; string)
6558 foreach (int, dchar; string)
**************************************************/
bool test3512()
{
string s = "öhai";
int q = 0;
foreach (wchar c; s)
{
if (q == 2)
assert(c == 'a');
++q;
}
assert(q == 4);
// _aApplycd1
foreach (dchar c; s)
{
++q;
if (c == 'h')
break;
}
assert(q == 6);
// _aApplycw2
foreach (int i, wchar c; s)
{
assert(i >= 0 && i < s.length);
}
// _aApplycd2
foreach (int i, dchar c; s)
{
assert(i >= 0 && i < s.length);
}
wstring w = "xüm";
// _aApplywc1
foreach (char c; w)
{
++q;
}
assert(q == 10);
// _aApplywd1
foreach (dchar c; w)
{
++q;
}
assert(q == 13);
// _aApplywc2
foreach (int i, char c; w)
{
assert(i >= 0 && i < w.length);
}
// _aApplywd2
foreach (int i, dchar c; w)
{
assert(i >= 0 && i < w.length);
}
dstring d = "yäq";
// _aApplydc1
q = 0;
foreach (char c; d)
{
++q;
}
assert(q == 4);
// _aApplydw1
q = 0;
foreach (wchar c; d)
{
++q;
}
assert(q == 3);
// _aApplydc2
foreach (int i, char c; d)
{
assert(i >= 0 && i < d.length);
}
// _aApplydw2
foreach (int i, wchar c; d)
{
assert(i >= 0 && i < d.length);
}
dchar[] dr = "squop"d.dup;
foreach (int n, char c; dr)
{
if (n == 2)
break;
assert(c != 'o');
}
// _aApplyRdc1
foreach_reverse (char c; dr)
{}
// _aApplyRdw1
foreach_reverse (wchar c; dr)
{}
// _aApplyRdc2
foreach_reverse (int n, char c; dr)
{
if (n == 4)
break;
assert(c != 'o');
}
// _aApplyRdw2
foreach_reverse (int i, wchar c; dr)
{
assert(i >= 0 && i < dr.length);
}
q = 0;
wstring w2 = ['x', 'ü', 'm']; // foreach over array literals
foreach_reverse (int n, char c; w2)
{
++q;
if (c == 'm') assert(n == 2 && q == 1);
if (c == 'x') assert(n == 0 && q == 4);
}
return true;
}
static assert(test3512());
/**************************************************
6510 ICE only with -inline
**************************************************/
struct Stack6510
{
struct Proxy
{
void shrink() {}
}
Proxy stack;
void pop()
{
stack.shrink();
}
}
int bug6510()
{
static int used()
{
Stack6510 junk;
junk.pop();
return 3;
}
return used();
}
void test6510()
{
static assert(bug6510() == 3);
}
/**************************************************
6511 arr[] shouldn't make a copy
**************************************************/
T bug6511(T)()
{
T[1] a = [1];
a[] += a[];
return a[0];
}
static assert(bug6511!ulong() == 2);
static assert(bug6511!long() == 2);
/**************************************************
6512 new T[][]
**************************************************/
bool bug6512(int m)
{
auto x = new int[2][][](m, 5);
assert(x.length == m);
assert(x[0].length == 5);
assert(x[0][0].length == 2);
foreach (i; 0.. m)
foreach (j; 0 .. 5)
foreach (k; 0 .. 2)
x[i][j][k] = k + j*10 + i*100;
foreach (i; 0.. m)
foreach (j; 0 .. 5)
foreach (k; 0 .. 2)
assert(x[i][j][k] == k + j*10 + i*100);
return true;
}
static assert(bug6512(3));
/**************************************************
6516 ICE(constfold.c)
**************************************************/
dstring bug6516()
{
return cast(dstring)new dchar[](0);
}
static assert(bug6516() == ""d);
/**************************************************
6727 ICE(interpret.c)
**************************************************/
const(char)* ice6727(const(char)* z) { return z; }
static assert({
auto q = ice6727("a".dup.ptr);
return true;
}());
/**************************************************
6721 Cannot get pointer to start of char[]
**************************************************/
static assert({
char[] c1 = "".dup;
auto p = c1.ptr;
string c2 = "";
auto p2 = c2.ptr;
return 6;
}() == 6);
/**************************************************
6693 Assign to null AA
**************************************************/
struct S6693
{
int[int] m;
}
static assert({
int[int][int] aaa;
aaa[3][1] = 4;
int[int][3] aab;
aab[2][1] = 4;
S6693 s;
s.m[2] = 4;
return 6693;
}() == 6693);
/**************************************************
7602 Segfault AA.keys on null AA
**************************************************/
string[] test7602()
{
int[string] array;
return array.keys;
}
enum bug7602 = test7602();
/**************************************************
6739 Nested AA assignment
**************************************************/
static assert({
int[int][int][int] aaa;
aaa[3][1][6] = 14;
return aaa[3][1][6];
}() == 14);
static assert({
int[int][int] aaa;
aaa[3][1] = 4;
aaa[3][3] = 3;
aaa[1][5] = 9;
auto kk = aaa[1][5];
return kk;
}() == 9);
/**************************************************
6751 ref AA assignment
**************************************************/
void bug6751(ref int[int] aa)
{
aa[1] = 2;
}
static assert({
int[int] aa;
bug6751(aa);
assert(aa[1] == 2);
return true;
}());
void bug6751b(ref int[int][int] aa)
{
aa[1][17] = 2;
}
struct S6751
{
int[int][int] aa;
int[int] bb;
}
static assert({
S6751 s;
bug6751b(s.aa);
assert(s.aa[1][17] == 2);
return true;
}());
static assert({
S6751 s;
s.aa[7][56] = 57;
bug6751b(s.aa);
assert(s.aa[1][17] == 2);
assert(s.aa[7][56] == 57);
bug6751c(s.aa);
assert(s.aa.keys.length == 1);
assert(s.aa.values.length == 1);
return true;
}());
static assert({
S6751 s;
s.bb[19] = 97;
bug6751(s.bb);
assert(s.bb[1] == 2);
assert(s.bb[19] == 97);
return true;
}());
void bug6751c(ref int[int][int] aa)
{
aa = [38: [56 : 77]];
}
/**************************************************
7790 AA foreach ref
**************************************************/
struct S7790
{
size_t id;
}
size_t bug7790(S7790[string] tree)
{
foreach (k, ref v; tree)
v.id = 1;
return tree["a"].id;
}
static assert(bug7790(["a":S7790(0)]) == 1);
/**************************************************
6765 null AA.length
**************************************************/
static assert({
int[int] w;
return w.length;
}() == 0);
/**************************************************
6769 AA.keys, AA.values with -inline
**************************************************/
static assert({
double[char[3]] w = ["abc" : 2.3];
double[] z = w.values;
return w.keys.length;
}() == 1);
/**************************************************
4022 AA.get
**************************************************/
static assert({
int[int] aa = [58: 13];
int r = aa.get(58, 1000);
assert(r == 13);
r = aa.get(59, 1000);
return r;
}() == 1000);
/**************************************************
6775 AA.opApply
**************************************************/
static assert({
int[int] aa = [58: 17, 45:6];
int valsum = 0;
int keysum = 0;
foreach (m; aa) // aaApply
{
valsum += m;
}
assert(valsum == 17 + 6);
valsum = 0;
foreach (n, m; aa) // aaApply2
{
valsum += m;
keysum += n;
}
assert(valsum == 17 + 6);
assert(keysum == 58 + 45);
// Check empty AA
valsum = 0;
int[int] bb;
foreach (m; bb)
{
++valsum;
}
assert(valsum == 0);
return true;
}());
/**************************************************
7890 segfault struct with AA field
**************************************************/
struct S7890
{
int[int] tab;
}
S7890 bug7890()
{
S7890 foo;
foo.tab[0] = 0;
return foo;
}
enum e7890 = bug7890();
/**************************************************
AA.remove
**************************************************/
static assert({
int[int] aa = [58: 17, 45:6];
aa.remove(45);
assert(aa.length == 1);
aa.remove(7);
assert(aa.length == 1);
aa.remove(58);
assert(aa.length == 0);
return true;
}());
/**************************************************
try, finally
**************************************************/
static assert({
int n = 0;
try
{
n = 1;
}
catch (Exception e)
{}
assert(n == 1);
try
{
n = 2;
}
catch (Exception e)
{}
finally
{
assert(n == 2);
n = 3;
}
assert(n == 3);
return true;
}());
/**************************************************
6800 bad pointer casts
**************************************************/
bool badpointer(int k)
{
int m = 6;
int* w = &m;
assert(*w == 6);
int[3] a = [17, 2, 21];
int* w2 = &a[2];
assert(*w2 == 21);
// cast int* to uint* is OK
uint* u1 = cast(uint*)w;
assert(*u1 == 6);
uint* u2 = cast(uint*)w2;
assert(*u2 == 21);
uint* u3 = cast(uint*)&m;
assert(*u3 == 6);
// cast int* to void* is OK
void* v1 = cast(void*)w;
void* v3 = &m;
void* v4 = &a[0];
// cast from void* back to int* is OK
int* t3 = cast(int*)v3;
assert(*t3 == 6);
int* t4 = cast(int*)v4;
assert(*t4 == 17);
// cast from void* to uint* is OK
uint* t1 = cast(uint*)v1;
assert(*t1 == 6);
// and check that they're real pointers
m = 18;
assert(*t1 == 18);
assert(*u3 == 18);
int** p = &w;
if (k == 1) // bad reinterpret
double *d1 = cast(double*)w;
if (k == 3) // bad reinterpret
char* d3 = cast(char*)w2;
if (k == 4) {
void* q1 = cast(void*)p; // OK-void is int*
void* *q = cast(void**)p; // OK-void is int
}
if (k == 5)
void*** q = cast(void***)p; // bad: too many *
if (k == 6) // bad reinterpret through void*
double* d1 = cast(double*)v1;
if (k == 7)
double* d7 = cast(double*)v4;
if (k == 8)
++v4; // can't do pointer arithmetic on void*
return true;
}
static assert(badpointer(4));
static assert(!is(typeof(compiles!(badpointer(1)))));
static assert( is(typeof(compiles!(badpointer(2)))));
static assert(!is(typeof(compiles!(badpointer(3)))));
static assert( is(typeof(compiles!(badpointer(4)))));
static assert(!is(typeof(compiles!(badpointer(5)))));
static assert(!is(typeof(compiles!(badpointer(6)))));
static assert(!is(typeof(compiles!(badpointer(7)))));
static assert(!is(typeof(compiles!(badpointer(8)))));
/**************************************************
10211 Allow casts S**->D**, when S*->D* is OK
**************************************************/
int bug10211()
{
int m = 7;
int* x = &m;
int** y = &x;
assert(**y == 7);
uint* p = cast(uint*)x;
uint** q = cast(uint**)y;
return 1;
}
static assert(bug10211());
/**************************************************
10568 CTFE rejects function pointer safety casts
**************************************************/
@safe void safetyDance() {}
int isItSafeToDance()
{
void function() @trusted yourfriends = &safetyDance;
void function() @safe nofriendsOfMine = yourfriends;
return 1;
}
static assert(isItSafeToDance());
/**************************************************
12296 CTFE rejects const compatible AA pointer cast
**************************************************/
int test12296()
{
immutable x = [5 : 4];
auto aa = &x;
const(int[int])* y = aa;
return 1;
}
static assert(test12296());
/**************************************************
9170 Allow reinterpret casts float<->int
**************************************************/
int f9170(float x)
{
return *(cast(int*)&x);
}
float i9170(int x)
{
return *(cast(float*)&x);
}
float u9170(uint x)
{
return *(cast(float*)&x);
}
int f9170arr(float[] x)
{
return *(cast(int*)&(x[1]));
}
long d9170(double x)
{
return *(cast(long*)&x);
}
int fref9170(ref float x)
{
return *(cast(int*)&x);
}
long dref9170(ref double x)
{
return *(cast(long*)&x);
}
bool bug9170()
{
float f = 1.25;
double d = 1.25;
assert(f9170(f) == 0x3FA0_0000);
assert(fref9170(f) == 0x3FA0_0000);
assert(d9170(d) == 0x3FF4_0000_0000_0000L);
assert(dref9170(d) == 0x3FF4_0000_0000_0000L);
float [3] farr = [0, 1.25, 0];
assert(f9170arr(farr) == 0x3FA0_0000);
int i = 0x3FA0_0000;
assert(i9170(i) == 1.25);
uint u = 0x3FA0_0000;
assert(u9170(u) == 1.25);
return true;
}
static assert(bug9170());
/**************************************************
6792 ICE with pointer cast of indexed array
**************************************************/
struct S6792
{
int i;
}
static assert({
{
void* p;
p = [S6792(1)].ptr;
S6792 s = *(cast(S6792*)p);
assert(s.i == 1);
}
{
void*[] ary;
ary ~= [S6792(2)].ptr;
S6792 s = *(cast(S6792*)ary[0]);
assert(s.i == 2);
}
{
void*[7] ary;
ary[6]= [S6792(2)].ptr;
S6792 s = *(cast(S6792*)ary[6]);
assert(s.i == 2);
}
{
void* p;
p = [S6792(1)].ptr;
void*[7] ary;
ary[5]= p;
S6792 s = *(cast(S6792*)ary[5]);
assert(s.i == 1);
}
{
S6792*[string] aa;
aa["key"] = [S6792(3)].ptr;
const(S6792) s = *(cast(const(S6792)*)aa["key"]);
assert(s.i == 3);
}
{
S6792[string] blah;
blah["abc"] = S6792(6);
S6792*[string] aa;
aa["kuy"] = &blah["abc"];
const(S6792) s = *(cast(const(S6792)*)aa["kuy"]);
assert(s.i == 6);
void*[7] ary;
ary[5]= &blah["abc"];
S6792 t = *(cast(S6792*)ary[5]);
assert(t.i == 6);
int q = 6;
ary[3]= &q;
int gg = *(cast(int*)(ary[3]));
}
return true;
}());
/**************************************************
7780 array cast
**************************************************/
int bug7780(int testnum)
{
int[] y = new int[2];
y[0] = 2000000;
if (testnum == 1)
{
void[] x = y;
return (cast(byte[])x)[1];
}
if (testnum == 2)
{
int[] x = y[0 .. 1];
return (cast(byte[])x)[1];
}
return 1;
}
static assert( is(typeof(compiles!(bug7780(0)))));
static assert(!is(typeof(compiles!(bug7780(1)))));
static assert(!is(typeof(compiles!(bug7780(2)))));
/**************************************************
14028 - static array pointer that refers existing array elements.
**************************************************/
int test14028a(size_t ofs)(bool ct)
{
int[4] a;
int[2]* p;
int num = ofs;
if (ct)
p = cast(int[2]*)&a[ofs]; // SymOffExp
else
p = cast(int[2]*)&a[num]; // CastExp + AddrExp
// pointers comparison
assert(cast(void*)a.ptr <= cast(void*)p);
assert(cast(void*)a.ptr <= cast(void*)&(*p)[0]);
assert(cast(void*)&a[0] <= cast(void*)p);
return 1;
}
static assert(test14028a!0(true));
static assert(test14028a!0(false));
static assert(test14028a!3(true));
static assert(test14028a!3(false));
static assert(!is(typeof(compiles!(test14028a!4(true)))));
static assert(!is(typeof(compiles!(test14028a!4(false)))));
int test14028b(int num)
{
int[4] a;
int[2]* p;
if (num == 1)
{
p = cast(int[2]*)&a[0]; // &a[0..2];
(*p)[0] = 1; // a[0] = 1
(*p)[1] = 2; // a[1] = 2
assert(a == [1,2,0,0]);
p = p + 1; // &a[0] -> &a[2]
(*p)[0] = 3; // a[2] = 3
(*p)[1] = 4; // a[3] = 4
assert(a == [1,2,3,4]);
}
if (num == 2)
{
p = cast(int[2]*)&a[1]; // &a[1..3];
(*p)[0] = 1; // a[1] = 1
p = p + 1; // &a[1..3] -> &a[3..5]
(*p)[0] = 2; // a[3] = 2
assert(a == [0,1,0,2]);
}
if (num == 3)
{
p = cast(int[2]*)&a[1]; // &a[1..3];
(*p)[0] = 1; // a[1] = 1
p = p + 1; // &a[1..3] -> &a[3..5]
(*p)[0] = 2; // a[3] = 2
(*p)[1] = 3; // a[4] = 3 (CTFE error)
}
if (num == 4)
{
p = cast(int[2]*)&a[0]; // &a[0..2];
p = p + 1; // &a[0..2] -> &a[2..4]
p = p + 1; // &a[2..4] -> &a[4..6] (ok)
}
if (num == 5)
{
p = cast(int[2]*)&a[1]; // &a[1..3];
p = p + 2; // &a[1..3] -> &a[5..7] (CTFE error)
}
return 1;
}
static assert(test14028b(1));
static assert(test14028b(2));
static assert(!is(typeof(compiles!(test14028b(3)))));
static assert(test14028b(4));
static assert(!is(typeof(compiles!(test14028b(5)))));
/**************************************************
10275 cast struct literals to immutable
**************************************************/
struct Bug10275
{
uint[] ivals;
}
Bug10275 bug10275()
{
return Bug10275([1, 2, 3]);
}
int test10275()
{
immutable(Bug10275) xxx = cast(immutable(Bug10275))bug10275();
return 1;
}
static assert(test10275());
/**************************************************
6851 passing pointer by argument
**************************************************/
void set6851(int* pn)
{
*pn = 20;
}
void bug6851()
{
int n = 0;
auto pn = &n;
*pn = 10;
assert(n == 10);
set6851(&n);
}
static assert({ bug6851(); return true; }());
/**************************************************
7876
**************************************************/
int* bug7876(int n)
{
int x;
auto ptr = &x;
if (n == 2)
ptr = null;
return ptr;
}
struct S7876
{
int* p;
}
S7876 bug7876b(int n)
{
int x;
S7876 s;
s.p = &x;
if (n == 11)
s.p = null;
return s;
}
int test7876(int n)
{
if (n >= 10)
{
S7876 m = bug7876b(n);
return 1;
}
int* p = bug7876(n);
return 1;
}
static assert( is(typeof(compiles!(test7876(2)))));
static assert(!is(typeof(compiles!(test7876(0)))));
static assert( is(typeof(compiles!(test7876(11)))));
static assert(!is(typeof(compiles!(test7876(10)))));
/**************************************************
11824
**************************************************/
int f11824(T)()
{
T[] arr = new T[](1);
T* getAddr(ref T a)
{
return &a;
}
getAddr(arr[0]);
return 1;
}
static assert(f11824!int()); // OK
static assert(f11824!(int[])()); // OK <- NG
/**************************************************
6817 if converted to &&, only with -inline
**************************************************/
static assert({
void toggle()
{
bool b;
if (b)
b = false;
}
toggle();
return true;
}());
/**************************************************
cast to void
**************************************************/
static assert({
cast(void)(71);
return true;
}());
/**************************************************
6816 nested function can't access this
**************************************************/
struct S6816
{
size_t foo()
{
return (){ return value +1 ; }();
}
size_t value;
}
enum s6816 = S6816().foo();
/**************************************************
7277 ICE nestedstruct.init.tupleof
**************************************************/
struct Foo7277
{
int a;
int func()
{
int b;
void nested()
{
b = 7;
a = 10;
}
nested();
return a+b;
}
}
static assert(Foo7277().func() == 17);
/**************************************************
10217 ICE. CTFE version of 9315
**************************************************/
bool bug10217()
{
struct S
{
int i;
void bar() {}
}
auto yyy = S.init.tupleof[$ - 1];
assert(!yyy);
return 1;
}
static assert(bug10217());
/**************************************************
8276 ICE
**************************************************/
void bug8676(int n)
{
const int X1 = 4 + n;
const int X2 = 4;
int X3 = 4;
int bar1() { return X1; }
int bar2() { return X2; }
int bar3() { return X3; }
static assert(!is(typeof(compiles!(bar1()))));
static assert( is(typeof(compiles!(bar2()))));
static assert(!is(typeof(compiles!(bar3()))));
}
/**************************************************
classes and interfaces
**************************************************/
interface SomeInterface
{
int daz();
float bar(char);
int baz();
}
interface SomeOtherInterface
{
int xxx();
}
class TheBase : SomeInterface, SomeOtherInterface
{
int q = 88;
int rad = 61;
int a = 14;
int somebaseclassfunc() { return 28; }
int daz() { return 0; }
int baz() { return 0; }
int xxx() { return 762; }
int foo() { return q; }
float bar(char c) { return 3.6; }
}
class SomeClass : TheBase, SomeInterface
{
int gab = 9;
int fab;
int a = 17;
int b = 23;
override int foo() { return gab + a; }
override float bar(char c) { return 2.6; }
int something() { return 0; }
override int daz() { return 0; }
override int baz() { return 0; }
}
class Unrelated : TheBase
{
this(int x) { a = x; }
}
auto classtest1(int n)
{
SomeClass c = new SomeClass;
assert(c.a == 17);
assert(c.q == 88);
TheBase d = c;
assert(d.a == 14);
assert(d.q == 88);
if (n == 7)
{
// bad cast -- should fail
Unrelated u = cast(Unrelated)d;
assert(u is null);
}
SomeClass e = cast(SomeClass)d;
d.q = 35;
assert(c.q == 35);
assert(c.foo() == 9 + 17);
++c.a;
assert(c.foo() == 9 + 18);
assert(d.foo() == 9 + 18);
d = new TheBase;
SomeInterface fc = c;
SomeOtherInterface ot = c;
assert(fc.bar('x') == 2.6);
assert(ot.xxx() == 762);
fc = d;
ot = d;
assert(fc.bar('x') == 3.6);
assert(ot.xxx() == 762);
Unrelated u2 = new Unrelated(7);
assert(u2.a == 7);
return 6;
}
static assert(classtest1(1));
static assert(classtest1(2));
static assert(classtest1(7)); // bug 7154
// can't initialize enum with not null class
SomeClass classtest2(int n)
{
return n == 5 ? (new SomeClass) : null;
}
static assert( is(typeof((){ enum const(SomeClass) xx = classtest2(2);}())));
static assert(!is(typeof((){ enum const(SomeClass) xx = classtest2(5);}())));
class RecursiveClass
{
int x;
this(int n) { x = n; }
RecursiveClass b;
void doit() { b = new RecursiveClass(7); b.x = 2;}
}
int classtest3()
{
RecursiveClass x = new RecursiveClass(17);
x.doit();
RecursiveClass y = x.b;
assert(y.x == 2);
assert(x.x == 17);
return 1;
}
static assert(classtest3());
/**************************************************
12016 class cast and qualifier reinterpret
**************************************************/
class B12016 { }
class C12016 : B12016 { }
bool f12016(immutable B12016 b)
{
assert(b);
return true;
}
static assert(f12016(new immutable C12016));
/**************************************************
10610 ice immutable implicit conversion
**************************************************/
class Bug10610(T)
{
int baz() immutable
{
return 1;
}
static immutable(Bug10610!T) min = new Bug10610!T();
}
void ice10610()
{
alias T10610 = Bug10610!(int);
static assert (T10610.min.baz());
}
/**************************************************
13141 regression fix caused by 10610
**************************************************/
struct MapResult13141(alias pred)
{
int[] range;
@property empty() { return range.length == 0; }
@property front() { return pred(range[0]); }
void popFront() { range = range[1 .. $]; }
}
string[] array13141(R)(R r)
{
typeof(return) result;
foreach (e; r)
result ~= e;
return result;
}
//immutable string[] splitterNames = [4].map!(e => "4").array();
immutable string[] splitterNames13141 = MapResult13141!(e => "4")([4]).array13141();
/**************************************************
11587 AA compare
**************************************************/
static assert([1:2, 3:4] == [3:4, 1:2]);
/**************************************************
14325 more AA comparisons
**************************************************/
static assert([1:1] != [1:2, 2:1]); // OK
static assert([1:1] != [1:2]); // OK
static assert([1:1] != [2:1]); // OK <- Error
static assert([1:1, 2:2] != [3:3, 4:4]); // OK <- Error
/**************************************************
7147 typeid()
**************************************************/
static assert({
TypeInfo xxx = typeid(Object);
TypeInfo yyy = typeid(new Error("xxx"));
return true;
}());
int bug7147(int n)
{
Error err = n ? new Error("xxx") : null;
TypeInfo qqq = typeid(err);
return 1;
}
// Must not segfault if class is null
static assert(!is(typeof(compiles!(bug7147(0)))));
static assert( is(typeof(compiles!(bug7147(1)))));
/**************************************************
14123 - identity TypeInfo objects
**************************************************/
static assert({
bool eq(TypeInfo t1, TypeInfo t2)
{
return t1 is t2;
}
class C {}
struct S {}
assert( eq(typeid(C), typeid(C)));
assert(!eq(typeid(C), typeid(Object)));
assert( eq(typeid(S), typeid(S)));
assert(!eq(typeid(S), typeid(int)));
assert( eq(typeid(int), typeid(int)));
assert(!eq(typeid(int), typeid(long)));
Object o = new Object;
Object c = new C;
assert( eq(typeid(o), typeid(o)));
assert(!eq(typeid(c), typeid(o)));
assert(!eq(typeid(o), typeid(S)));
return 1;
}());
/**************************************************
6885 wrong code with new array
**************************************************/
struct S6885
{
int p;
}
int bug6885()
{
auto array = new double[1][2];
array[1][0] = 6;
array[0][0] = 1;
assert(array[1][0] == 6);
auto barray = new S6885[2];
barray[1].p = 5;
barray[0].p = 2;
assert(barray[1].p == 5);
return 1;
}
static assert(bug6885());
/**************************************************
6886 ICE with new array of dynamic arrays
**************************************************/
int bug6886()
{
auto carray = new int[][2];
carray[1] = [6];
carray[0] = [4];
assert(carray[1][0] == 6);
return 1;
}
static assert(bug6886());
/**************************************************
10198 Multidimensional struct block initializer
**************************************************/
struct Block10198
{
int val[3][4];
}
int bug10198()
{
Block10198 pp = Block10198(67);
assert(pp.val[2][3] == 67);
assert(pp.val[1][3] == 67);
return 1;
}
static assert(bug10198());
/**************************************************
14440 Multidimensional block initialization should create distinct arrays for each elements
**************************************************/
struct Matrix14440(E, size_t row, size_t col)
{
E[col][row] array2D;
@safe pure nothrow
this(E[row * col] numbers...)
{
foreach (r; 0 .. row)
{
foreach (c; 0 .. col)
{
array2D[r][c] = numbers[r * col + c];
}
}
}
}
void test14440()
{
// Replace 'enum' with 'auto' here and it will work fine.
enum matrix = Matrix14440!(int, 3, 3)(
1, 2, 3,
4, 5, 6,
7, 8, 9
);
static assert(matrix.array2D[0][0] == 1);
static assert(matrix.array2D[0][1] == 2);
static assert(matrix.array2D[0][2] == 3);
static assert(matrix.array2D[1][0] == 4);
static assert(matrix.array2D[1][1] == 5);
static assert(matrix.array2D[1][2] == 6);
static assert(matrix.array2D[2][0] == 7);
static assert(matrix.array2D[2][1] == 8);
static assert(matrix.array2D[2][2] == 9);
}
/****************************************************
* Exception chaining tests from xtest46.d
****************************************************/
class A75
{
pure static void raise(string s)
{
throw new Exception(s);
}
}
int test75()
{
int x = 0;
try
{
A75.raise("a");
}
catch (Exception e)
{
x = 1;
}
assert(x == 1);
return 1;
}
static assert(test75());
/****************************************************
* Exception chaining tests from test4.d
****************************************************/
int test4_test54()
{
int status = 0;
try
{
try
{
status++;
assert(status == 1);
throw new Exception("first");
}
finally
{
status++;
assert(status == 2);
status++;
throw new Exception("second");
}
}
catch (Exception e)
{
assert(e.msg == "first");
assert(e.next.msg == "second");
}
return true;
}
static assert(test4_test54());
void foo55()
{
try
{
Exception x = new Exception("second");
throw x;
}
catch (Exception e)
{
assert(e.msg == "second");
}
}
int test4_test55()
{
int status = 0;
try
{
try
{
status++;
assert(status == 1);
Exception x = new Exception("first");
throw x;
}
finally
{
status++;
assert(status == 2);
status++;
foo55();
}
}
catch (Exception e)
{
assert(e.msg == "first");
assert(status == 3);
}
return 1;
}
static assert(test4_test55());
/****************************************************
* Exception chaining tests from eh.d
****************************************************/
void bug1513outer()
{
int result1513;
void bug1513a()
{
throw new Exception("d");
}
void bug1513b()
{
try
{
try
{
bug1513a();
}
finally
{
result1513 |= 4;
throw new Exception("f");
}
}
catch (Exception e)
{
assert(e.msg == "d");
assert(e.next.msg == "f");
assert(!e.next.next);
}
}
void bug1513c()
{
try
{
try
{
throw new Exception("a");
}
finally
{
result1513 |= 1;
throw new Exception("b");
}
}
finally
{
bug1513b();
result1513 |= 2;
throw new Exception("c");
}
}
void bug1513()
{
result1513 = 0;
try
{
bug1513c();
}
catch (Exception e)
{
assert(result1513 == 7);
assert(e.msg == "a");
assert(e.next.msg == "b");
assert(e.next.next.msg == "c");
}
}
bug1513();
}
void collideone()
{
try
{
throw new Exception("x");
}
finally
{
throw new Exception("y");
}
}
void doublecollide()
{
try
{
try
{
try
{
throw new Exception("p");
}
finally
{
throw new Exception("q");
}
}
finally
{
collideone();
}
}
catch (Exception e)
{
assert(e.msg == "p");
assert(e.next.msg == "q");
assert(e.next.next.msg == "x");
assert(e.next.next.next.msg == "y");
assert(!e.next.next.next.next);
}
}
void collidetwo()
{
try
{
try
{
throw new Exception("p2");
}
finally
{
throw new Exception("q2");
}
}
finally
{
collideone();
}
}
void collideMixed()
{
int works = 6;
try
{
try
{
try
{
throw new Exception("e");
}
finally
{
throw new Error("t");
}
}
catch (Exception f)
{
// Doesn't catch, because Error is chained to it.
works += 2;
}
}
catch (Error z)
{
works += 4;
assert(z.msg == "t"); // Error comes first
assert(z.next is null);
assert(z.bypassedException.msg == "e");
}
assert(works == 10);
}
class AnotherException : Exception
{
this(string s)
{
super(s);
}
}
void multicollide()
{
try
{
try
{
try
{
try
{
throw new Exception("m2");
}
finally
{
throw new AnotherException("n2");
}
}
catch (AnotherException s)
{
// Not caught -- we needed to catch the root cause "m2", not
// just the collateral "n2" (which would leave m2 uncaught).
assert(0);
}
}
finally
{
collidetwo();
}
}
catch (Exception f)
{
assert(f.msg == "m2");
assert(f.next.msg == "n2");
Throwable e = f.next.next;
assert(e.msg == "p2");
assert(e.next.msg == "q2");
assert(e.next.next.msg == "x");
assert(e.next.next.next.msg == "y");
assert(!e.next.next.next.next);
}
}
int testsFromEH()
{
bug1513outer();
doublecollide();
collideMixed();
multicollide();
return 1;
}
static assert(testsFromEH());
/**************************************************
With + synchronized statements + bug 6901
**************************************************/
struct With1
{
int a;
int b;
}
class Foo6
{
}
class Foo32
{
struct Bar
{
int x;
}
}
class Base56
{
private string myfoo;
private string mybar;
// Get/set properties that will be overridden.
void foo(string s) { myfoo = s; }
string foo() { return myfoo; }
// Get/set properties that will not be overridden.
void bar(string s) { mybar = s; }
string bar() { return mybar; }
}
class Derived56 : Base56
{
alias Base56.foo foo; // Bring in Base56's foo getter.
override void foo(string s) { super.foo = s; } // Override foo setter.
}
int testwith()
{
With1 x = With1(7);
with (x)
{
a = 2;
}
assert(x.a == 2);
// from test11.d
Foo6 foo6 = new Foo6();
with (foo6)
{
int xx;
xx = 4;
}
with (new Foo32)
{
Bar z;
z.x = 5;
}
Derived56 d = new Derived56;
with (d)
{
foo = "hi";
d.foo = "hi";
bar = "hi";
assert(foo == "hi");
assert(d.foo == "hi");
assert(bar == "hi");
}
int w = 7;
synchronized
{
++w;
}
assert(w == 8);
return 1;
}
static assert(testwith());
/**************************************************
9236 ICE switch with(EnumType)
**************************************************/
enum Command9236
{
Char,
Any,
};
bool bug9236(Command9236 cmd)
{
int n = 0;
with (Command9236) switch (cmd)
{
case Any:
n = 1;
break;
default:
n = 2;
}
assert(n == 1);
switch (cmd) with (Command9236)
{
case Any:
return true;
default:
return false;
}
}
static assert(bug9236(Command9236.Any));
/**************************************************
6416 static struct declaration
**************************************************/
static assert({
static struct S { int y = 7; }
S a;
a.y += 6;
assert(a.y == 13);
return true;
}());
/**************************************************
10499 static template struct declaration
**************************************************/
static assert({
static struct Result() {}
return true;
}());
/**************************************************
13757 extern(C) alias declaration
**************************************************/
static assert({
alias FP1 = extern(C) int function();
alias extern(C) int function() FP2;
return true;
}());
/**************************************************
6522 opAssign + foreach ref
**************************************************/
struct Foo6522
{
bool b = false;
void opAssign(int x)
{
this.b = true;
}
}
bool foo6522()
{
Foo6522[1] array;
foreach (ref item; array)
item = 1;
return true;
}
static assert(foo6522());
/**************************************************
7245 pointers + foreach ref
**************************************************/
int bug7245(int testnum)
{
int[3] arr;
arr[0] = 4;
arr[1] = 6;
arr[2] = 8;
int* ptr;
foreach (i, ref p; arr)
{
if (i == 1)
ptr = &p;
if (testnum == 1)
p = 5;
}
return *ptr;
}
static assert(bug7245(0) == 6);
static assert(bug7245(1) == 5);
/**************************************************
8498 modifying foreach
7658 foreach ref
8539 nested funcs, ref param, -inline
**************************************************/
int bug8498()
{
foreach (ref i; 0 .. 5)
{
assert(i == 0);
i = 100;
}
return 1;
}
static assert(bug8498());
string bug7658()
{
string[] children = ["0"];
foreach (ref child; children)
child = "1";
return children[0];
}
static assert(bug7658() == "1");
int bug8539()
{
static void one(ref int x)
{
x = 1;
}
static void go()
{
int y;
one(y);
assert(y == 1); // fails with -inline
}
go();
return 1;
}
static assert(bug8539());
/**************************************************
7874, 13297, 13740 - better lvalue handling
**************************************************/
int bug7874(int x){ return ++x = 1; }
static assert(bug7874(0) == 1);
// ----
struct S13297
{
int* p;
}
void f13297(ref int* p)
{
p = cast(int*) 1;
assert(p); // passes
}
static assert(
{
S13297 s;
f13297(s.p);
return s.p != null; // false
}());
// ----
class R13740
{
int e;
bool empty = false;
@property ref front() { return e; }
void popFront() { empty = true; }
}
static assert({
auto r = new R13740();
foreach (ref e; r)
e = 42;
assert(r.e == 42); /* fails in CTFE */
return true;
}());
/**************************************************
6919
**************************************************/
void bug6919(int* val)
{
*val = 1;
}
void test6919()
{
int n;
bug6919(&n);
assert(n == 1);
}
static assert({ test6919(); return true; }());
void bug6919b(string* val)
{
*val = "1";
}
void test6919b()
{
string val;
bug6919b(&val);
assert(val == "1");
}
static assert({ test6919b(); return true; }());
/**************************************************
6995
**************************************************/
struct Foo6995
{
static size_t index(size_t v)()
{
return v;
}
}
static assert(Foo6995.index!(27)() == 27);
/**************************************************
7043 ref with -inline
**************************************************/
int bug7043(S)(ref int x)
{
return x;
}
static assert({
int i = 416;
return bug7043!(char)(i);
}() == 416);
/**************************************************
6037 recursive ref
**************************************************/
void bug6037(ref int x, bool b)
{
int w = 3;
if (b)
{
bug6037(w, false);
assert(w == 6);
}
else
{
x = 6;
assert(w == 3); // fails
}
}
int bug6037outer()
{
int q;
bug6037(q, true);
return 401;
}
static assert(bug6037outer() == 401);
/**************************************************
14299 - [REG2.067a], more than one depth of recursive call with ref
**************************************************/
string gen14299(int max, int idx, ref string name)
{
string ret;
name = [cast(char)(idx + '0')];
ret ~= name;
if (idx < max)
{
string subname;
ret ~= gen14299(max, idx + 1, subname);
}
ret ~= name;
return ret;
}
string test14299(int max)
{
string n;
return gen14299(max, 0, n);
}
static assert(test14299(1) == "0110"); // OK <- fail
static assert(test14299(2) == "012210"); // OK <- ICE
static assert(test14299(3) == "01233210");
static assert(test14299(4) == "0123443210");
static assert(test14299(5) == "012345543210");
/**************************************************
7940 wrong code for complicated assign
**************************************************/
struct Bug7940
{
int m;
}
struct App7940
{
Bug7940[] x;
}
int bug7940()
{
Bug7940[2] y;
App7940 app;
app.x = y[0 .. 1];
app.x[0].m = 12;
assert(y[0].m == 12);
assert(app.x[0].m == 12);
return 1;
}
static assert(bug7940());
/**************************************************
10298 wrong code for struct array literal init
**************************************************/
struct Bug10298
{
int m;
}
int bug10298()
{
Bug10298[1] y = [Bug10298(78)];
y[0].m = 6;
assert(y[0].m == 6);
// Root cause
Bug10298[1] x;
x[] = [cast(const Bug10298)(Bug10298(78))];
assert(x[0].m == 78);
return 1;
}
static assert(bug10298());
/**************************************************
7266 dotvar ref parameters
**************************************************/
struct S7266 { int a; }
bool bug7266()
{
S7266 s;
s.a = 4;
bar7266(s.a);
assert(s.a == 5);
out7266(s.a);
assert(s.a == 7);
return true;
}
void bar7266(ref int b)
{
b = 5;
assert(b == 5);
}
void out7266(out int b)
{
b = 7;
assert(b == 7);
}
static assert(bug7266());
/**************************************************
9982 dotvar assign through pointer
**************************************************/
struct Bug9982
{
int a;
}
int test9982()
{
Bug9982 x;
int*q = &x.a;
*q = 99;
assert(x.a == 99);
return 1;
}
static assert(test9982());
// 9982, rejects-valid case
struct SS9982
{
Bug9982 s2;
this(Bug9982 s1)
{
s2.a = 6;
emplace9982(&s2, s1);
assert(s2.a == 3);
}
}
void emplace9982(Bug9982* chunk, Bug9982 arg)
{
*chunk = arg;
}
enum s9982 = Bug9982(3);
enum p9982 = SS9982(s9982);
/**************************************************
11618 dotvar assign through casted pointer
**************************************************/
struct Tuple11618(T...)
{
T field;
alias field this;
}
static assert({
Tuple11618!(immutable dchar) result = void;
auto addr = cast(dchar*)&result[0];
*addr = dchar.init;
return (result[0] == dchar.init);
}());
/**************************************************
7143 'is' for classes
**************************************************/
class C7143
{
int x;
}
int bug7143(int test)
{
C7143 c = new C7143;
C7143 d = new C7143;
if (test == 1)
{
if (c)
return c.x + 8;
return -1;
}
if (test == 2)
{
if (c is null)
return -1;
return c.x + 45;
}
if (test == 3)
{
if (c is c)
return 58;
}
if (test == 4)
{
if (c !is c)
return -1;
else
return 48;
}
if (test == 6)
d = c;
if (test == 5 || test == 6)
{
if (c is d)
return 188;
else
return 48;
}
return -1;
}
static assert(bug7143(1) == 8);
static assert(bug7143(2) == 45);
static assert(bug7143(3) == 58);
static assert(bug7143(4) == 48);
static assert(bug7143(5) == 48);
static assert(bug7143(6) == 188);
/**************************************************
7147 virtual function calls from base class
**************************************************/
class A7147
{
int foo() { return 0; }
int callfoo()
{
return foo();
}
}
class B7147 : A7147
{
override int foo() { return 1; }
}
int test7147()
{
A7147 a = new B7147;
return a.callfoo();
}
static assert(test7147() == 1);
/**************************************************
7158
**************************************************/
class C7158
{
bool b() { return true; }
}
struct S7158
{
C7158 c;
}
bool test7158()
{
S7158 s = S7158(new C7158);
return s.c.b;
}
static assert(test7158());
/**************************************************
8484
**************************************************/
class C8484
{
int n;
int b() { return n + 3; }
}
struct S
{
C8484 c;
}
int t8484(ref C8484 c)
{
return c.b();
}
int test8484()
{
auto s = S(new C8484);
s.c.n = 4;
return t8484(s.c);
}
static assert(test8484() == 7);
/**************************************************
7419
**************************************************/
struct X7419
{
double x;
this(double x)
{
this.x = x;
}
}
void bug7419()
{
enum x = {
auto p = X7419(3);
return p.x;
}();
static assert(x == 3);
}
/**************************************************
9445 ice
**************************************************/
template c9445(T...) { }
void ice9445(void delegate() expr, void function() f2)
{
static assert(!is(typeof(c9445!(f2()))));
static assert(!is(typeof(c9445!(expr()))));
}
/**************************************************
10452 delegate ==
**************************************************/
struct S10452
{
bool func() { return true; }
}
struct Outer10452
{
S10452 inner;
}
class C10452
{
bool func() { return true; }
}
bool delegate() ref10452(ref S10452 s)
{
return &s.func;
}
bool test10452()
{
bool delegate() bar = () { return true; };
assert(bar !is null);
assert(bar is bar);
S10452 bag;
S10452[6] bad;
Outer10452 outer;
C10452 tag = new C10452;
auto rat = &outer.inner.func;
assert(rat == rat);
auto tat = &tag.func;
assert(tat == tat);
auto bat = &outer.inner.func;
auto mat = &bad[2].func;
assert(mat is mat);
assert(rat == bat);
auto zat = &bag.func;
auto cat = &bag.func;
assert(zat == zat);
assert(zat == cat);
auto drat = ref10452(bag);
assert(cat == drat);
assert(drat == drat);
drat = ref10452(bad[2]);
assert( drat == mat);
assert(tat != rat);
assert(zat != rat);
assert(rat != cat);
assert(zat != bar);
assert(tat != cat);
cat = bar;
assert(cat == bar);
return true;
}
static assert(test10452());
/**************************************************
7162 and 4711
**************************************************/
void f7162() { }
bool ice7162()
{
false && f7162();
false || f7162();
false && f7162(); // bug 4711
true && f7162();
return true;
}
static assert(ice7162());
/**************************************************
8857, only with -inline (creates an &&)
**************************************************/
struct Result8857 { char[] next; }
void bug8857()()
{
Result8857 r;
r.next = null;
if (true)
{
auto next = r.next;
}
}
static assert({
bug8857();
return true;
}());
/**************************************************
7527
**************************************************/
struct Bug7527
{
char[] data;
}
int bug7527()
{
auto app = Bug7527();
app.data.ptr[0 .. 1] = "x";
return 1;
}
static assert(!is(typeof(compiles!(bug7527()))));
/**************************************************
7527
**************************************************/
int bug7380;
static assert(!is(typeof( compiles!(
(){
return &bug7380;
}()
))));
/**************************************************
7165
**************************************************/
struct S7165
{
int* ptr;
bool f() const { return !!ptr; }
}
static assert(!S7165().f());
/**************************************************
7187
**************************************************/
int[] f7187() { return [0]; }
int[] f7187b(int n) { return [0]; }
int g7187(int[] r)
{
auto t = r[0 .. 0];
return 1;
}
static assert(g7187(f7187()));
static assert(g7187(f7187b(7)));
struct S7187 { const(int)[] field; }
const(int)[] f7187c()
{
auto s = S7187([0]);
return s.field;
}
bool g7187c(const(int)[] r)
{
auto t = r[0 .. 0];
return true;
}
static assert(g7187c(f7187c()));
/**************************************************
6933 struct destructors
**************************************************/
struct Bug6933
{
int x = 3;
~this() { }
}
int test6933()
{
Bug6933 q;
assert(q.x == 3);
return 3;
}
static assert(test6933());
/**************************************************
7197
**************************************************/
int foo7197(int[] x...)
{
return 1;
}
template bar7197(y...)
{
enum int bar7197 = foo7197(y);
}
enum int bug7197 = 7;
static assert(bar7197!(bug7197));
/**************************************************
Enum string compare
**************************************************/
enum EScmp : string { a = "aaa" }
bool testEScmp()
{
EScmp x = EScmp.a;
assert(x < "abc");
return true;
}
static assert(testEScmp());
/**************************************************
7667
**************************************************/
bool baz7667(int[] vars...)
{
return true;
}
struct S7667
{
static void his(int n)
{
static assert(baz7667(2));
}
}
bool bug7667()
{
S7667 unused;
unused.his(7);
return true;
}
enum e7667 = bug7667();
/**************************************************
7536
**************************************************/
bool bug7536(string expr)
{
return true;
}
void vop()
{
const string x7536 = "x";
static assert(bug7536(x7536));
}
/**************************************************
6681 unions
**************************************************/
struct S6681
{
this(int a, int b) { this.a = b; this.b = a; }
union
{
ulong g;
struct { int a, b; };
}
}
static immutable S6681 s6681 = S6681(0, 1);
bool bug6681(int test)
{
S6681 x = S6681(0, 1);
x.g = 5;
auto u = &x.g;
auto v = &x.a;
long w = *u;
int z;
assert(w == 5);
if (test == 4)
z = *v; // error
x.a = 2; // invalidate g, and hence u.
if (test == 1)
w = *u; // error
z = *v;
assert(z == 2);
x.g = 6;
w = *u;
assert(w == 6);
if (test == 3)
z = *v;
return true;
}
static assert(bug6681(2));
static assert(!is(typeof(compiles!(bug6681(1)))));
static assert(!is(typeof(compiles!(bug6681(3)))));
static assert(!is(typeof(compiles!(bug6681(4)))));
/**************************************************
9113 ICE with struct in union
**************************************************/
union U9113
{
struct M
{
int y;
}
int xx;
}
int bug9113(T)()
{
U9113 x;
x.M.y = 10; // error, need 'this'
return 1;
}
static assert(!is(typeof(compiles!(bug9113!(int)()))));
/**************************************************
Creation of unions
**************************************************/
union UnionTest1
{
int x;
float y;
}
int uniontest1()
{
UnionTest1 u = UnionTest1(1);
return 1;
}
static assert(uniontest1());
/**************************************************
6438 void
**************************************************/
struct S6438
{
int a;
int b = void;
}
void fill6438(int[] arr, int testnum)
{
if (testnum == 2)
{
auto u = arr[0];
}
foreach (ref x; arr)
x = 7;
auto r = arr[0];
S6438[2] s;
auto p = &s[0].b;
if (testnum == 3)
{
auto v = *p;
}
}
bool bug6438(int testnum)
{
int[4] stackSpace = void;
fill6438(stackSpace[], testnum);
assert(stackSpace == [7, 7, 7, 7]);
return true;
}
static assert( is(typeof(compiles!(bug6438(1)))));
static assert(!is(typeof(compiles!(bug6438(2)))));
static assert(!is(typeof(compiles!(bug6438(3)))));
/**************************************************
10994 void static array members
**************************************************/
struct Bug10994
{
ubyte[2] buf = void;
}
static bug10994 = Bug10994.init;
/**************************************************
10937 struct inside union
**************************************************/
struct S10937
{
union
{
ubyte[1] a;
struct
{
ubyte b;
}
}
this(ubyte B)
{
if (B > 6)
this.b = B;
else
this.a[0] = B;
}
}
enum test10937 = S10937(7);
enum west10937 = S10937(2);
/**************************************************
13831
**************************************************/
struct Vector13831()
{
}
struct Coord13831
{
union
{
struct { short x; }
Vector13831!() vector;
}
}
struct Chunk13831
{
this(Coord13831)
{
coord = coord;
}
Coord13831 coord;
static const Chunk13831* unknownChunk = new Chunk13831(Coord13831());
}
/**************************************************
7732
**************************************************/
struct AssociativeArray
{
int* impl;
int f()
{
if (impl !is null)
auto x = *impl;
return 1;
}
}
int test7732()
{
AssociativeArray aa;
return aa.f;
}
static assert(test7732());
/**************************************************
7784
**************************************************/
struct Foo7784
{
void bug()
{
tab["A"] = Bar7784(&this);
auto pbar = "A" in tab;
auto bar = *pbar;
}
Bar7784[string] tab;
}
struct Bar7784
{
Foo7784* foo;
int val;
}
bool ctfe7784()
{
auto foo = Foo7784();
foo.bug();
return true;
}
static assert(ctfe7784());
/**************************************************
7781
**************************************************/
static assert(({ return; }(), true));
/**************************************************
7785
**************************************************/
bool bug7785(int n)
{
int val = 7;
auto p = &val;
if (n == 2)
{
auto ary = p[0 .. 1];
}
auto x = p[0];
val = 6;
assert(x == 7);
if (n == 3)
p[0 .. 1] = 1;
return true;
}
static assert(bug7785(1));
static assert(!is(typeof(compiles!(bug7785(2)))));
static assert(!is(typeof(compiles!(bug7785(3)))));
/**************************************************
7987
**************************************************/
class C7987
{
int m;
}
struct S7987
{
int* p;
C7987 c;
}
bool bug7987()
{
int[7] q;
int[][2] b = q[0 .. 5];
assert(b == b);
assert(b is b);
C7987 c1 = new C7987;
C7987 c2 = new C7987;
S7987 s, t;
s.p = &q[0];
t.p = &q[1];
assert(s != t);
s.p = &q[1];
/*assert(s == t);*/ assert(s.p == t.p);
s.c = c1;
t.c = c2;
/*assert(s != t);*/ assert(s.c !is t.c);
assert(s !is t);
s.c = c2;
/*assert(s == t);*/ assert(s.p == t.p && s.c is t.c);
assert(s is t);
return true;
}
static assert(bug7987());
/**************************************************
10579 typeinfo.func() must not segfault
**************************************************/
static assert(!is(typeof(compiles!(typeid(int).toString.length))));
class Bug10579
{
int foo() { return 1; }
}
Bug10579 uninitialized10579;
static assert(!is(typeof(compiles!(uninitialized10579.foo()))));
/**************************************************
10804 mixin ArrayLiteralExp typed string
**************************************************/
void test10804()
{
String identity(String)(String a) { return a; }
string cfun()
{
char[] s;
s.length = 8 + 2 + (2) + 1 + 2;
s[] = "identity(`Ω`c)"c[];
return cast(string)s; // Return ArrayLiteralExp as the CTFE result
}
{
enum a1 = "identity(`Ω`c)"c;
enum a2 = cfun();
static assert(cast(ubyte[])mixin(a1) == [0xCE, 0xA9]);
static assert(cast(ubyte[])mixin(a2) == [0xCE, 0xA9]); // should pass
}
wstring wfun()
{
wchar[] s;
s.length = 8 + 2 + (2) + 1 + 2;
s[] = "identity(`\U0002083A`w)"w[];
return cast(wstring)s; // Return ArrayLiteralExp as the CTFE result
}
{
enum a1 = "identity(`\U0002083A`w)"w;
enum a2 = wfun();
static assert(cast(ushort[])mixin(a1) == [0xD842, 0xDC3A]);
static assert(cast(ushort[])mixin(a2) == [0xD842, 0xDC3A]);
}
dstring dfun()
{
dchar[] s;
s.length = 8 + 2 + (1) + 1 + 2;
s[] = "identity(`\U00101000`d)"d[];
return cast(dstring)s; // Return ArrayLiteralExp as the CTFE result
}
{
enum a1 = "identity(`\U00101000`d)"d;
enum a2 = dfun();
static assert(cast(uint[])mixin(a1) == [0x00101000]);
static assert(cast(uint[])mixin(a2) == [0x00101000]);
}
}
/******************************************************/
struct B73 {}
struct C73 { B73 b; }
C73 func73() { C73 b = void; b.b = B73(); return b; }
C73 test73 = func73();
/******************************************************/
struct S74
{
int n[1];
static S74 test(){ S74 ret = void; ret.n[0] = 0; return ret; }
}
enum Test74 = S74.test();
/******************************************************/
static bool bug8865()
in
{
int x = 0;
label:
foreach (i; (++x) .. 3)
{
if (i == 1)
continue label; // doesn't work.
else
break label; // doesn't work.
}
}
out
{
int x = 0;
label:
foreach (i; (++x) .. 3)
{
if (i == 1)
continue label; // doesn't work.
else
break label; // doesn't work.
}
}
body
{
int x = 0;
label:
foreach (i; (++x) .. 3)
{
if (i == 1)
continue label; // works.
else
break label; // works.
}
return true;
}
static assert(bug8865());
/******************************************************/
struct Test75
{
this(int) pure {}
}
static assert( __traits(compiles, { static shared(Test75*) t75 = new shared(Test75)(0); return t75; }));
static assert( __traits(compiles, { static shared(Test75)* t75 = new shared(Test75)(0); return t75; }));
static assert( __traits(compiles, { static __gshared Test75* t75 = new Test75(0); return t75; }));
static assert( __traits(compiles, { static const(Test75*) t75 = new const(Test75)(0); return t75; }));
static assert( __traits(compiles, { static immutable Test75* t75 = new immutable(Test75)(0); return t75; }));
static assert(!__traits(compiles, { static Test75* t75 = new Test75(0); return t75; }));
/+
static assert(!__traits(compiles, { enum t75 = new shared(Test75)(0); return t75; }));
static assert(!__traits(compiles, { enum t75 = new Test75(0); return t75; }));
static assert(!__traits(compiles, { enum shared(Test75)* t75 = new shared(Test75)(0); return t75; }));
static assert(!__traits(compiles, { enum Test75* t75 = new Test75(0); return t75; }));
static assert( __traits(compiles, { enum t75 = new const(Test75)(0); return t75;}));
static assert( __traits(compiles, { enum t75 = new immutable(Test75)(0); return t75;}));
static assert( __traits(compiles, { enum const(Test75)* t75 = new const(Test75)(0); return t75;}));
static assert( __traits(compiles, { enum immutable(Test75)* t75 = new immutable(Test75)(0); return t75;}));
+/
/******************************************************/
class Test76
{
this(int) pure {}
}
/+
static assert(!__traits(compiles, { enum t76 = new shared(Test76)(0); return t76;}));
static assert(!__traits(compiles, { enum t76 = new Test76(0); return t76;}));
static assert(!__traits(compiles, { enum shared(Test76) t76 = new shared(Test76)(0); return t76;}));
static assert(!__traits(compiles, { enum Test76 t76 = new Test76(0); return t76;}));
static assert( __traits(compiles, { enum t76 = new const(Test76)(0); return t76;}));
static assert( __traits(compiles, { enum t76 = new immutable(Test76)(0); return t76;}));
static assert( __traits(compiles, { enum const(Test76) t76 = new const(Test76)(0); return t76;}));
static assert( __traits(compiles, { enum immutable(Test76) t76 = new immutable(Test76)(0); return t76;}));
+/
/******************************************************/
static assert( __traits(compiles, { static shared Test76 t76 = new shared(Test76)(0); return t76; }));
static assert( __traits(compiles, { static shared(Test76) t76 = new shared(Test76)(0); return t76; }));
static assert( __traits(compiles, { static __gshared Test76 t76 = new Test76(0); return t76; }));
static assert( __traits(compiles, { static const Test76 t76 = new const(Test76)(0); return t76; }));
static assert( __traits(compiles, { static immutable Test76 t76 = new immutable Test76(0); return t76; }));
static assert(!__traits(compiles, { static Test76 t76 = new Test76(0); return t76; }));
/***** Bug 5678 *********************************/
struct Bug5678
{
this(int) {}
}
static assert(!__traits(compiles, { enum const(Bug5678)* b5678 = new const(Bug5678)(0); return b5678; }));
/**************************************************
10782 run semantic2 for class field
**************************************************/
enum e10782 = 0;
class C10782 { int x = e10782; }
string f10782()
{
auto c = new C10782();
return "";
}
mixin(f10782());
/**************************************************
10929 NRVO support in CTFE
**************************************************/
struct S10929
{
this(this)
{
postblitCount++;
}
~this()
{
dtorCount++;
}
int payload;
int dtorCount;
int postblitCount;
}
auto makeS10929()
{
auto s = S10929(42, 0, 0);
return s;
}
bool test10929()
{
auto s = makeS10929();
assert(s.postblitCount == 0);
assert(s.dtorCount == 0);
return true;
};
static assert(test10929());
/**************************************************
9245 - support postblit call on array assignments
**************************************************/
bool test9245()
{
int postblits = 0;
struct S
{
this(this)
{
++postblits;
}
}
S s;
S[2] a;
assert(postblits == 0);
{
S[2] arr = s;
assert(postblits == 2);
arr[] = s;
assert(postblits == 4);
postblits = 0;
S[2] arr2 = arr;
assert(postblits == 2);
arr2 = arr;
assert(postblits == 4);
postblits = 0;
const S[2] constArr = s;
assert(postblits == 2);
postblits = 0;
const S[2] constArr2 = arr;
assert(postblits == 2);
postblits = 0;
}
{
S[2][2] arr = s;
assert(postblits == 4);
arr[] = a;
assert(postblits == 8);
postblits = 0;
S[2][2] arr2 = arr;
assert(postblits == 4);
arr2 = arr;
assert(postblits == 8);
postblits = 0;
const S[2][2] constArr = s;
assert(postblits == 4);
postblits = 0;
const S[2][2] constArr2 = arr;
assert(postblits == 4);
postblits = 0;
}
return true;
}
static assert(test9245());
/**************************************************
12906 don't call postblit on blit initializing
**************************************************/
struct S12906 { this(this) { assert(0); } }
static assert({
S12906[1] arr;
return true;
}());
/**************************************************
11510 support overlapped field access in CTFE
**************************************************/
struct S11510
{
union
{
size_t x;
int* y; // pointer field
}
}
bool test11510()
{
S11510 s;
s.y = [1,2,3].ptr; // writing overlapped pointer field is OK
assert(s.y[0 .. 3] == [1,2,3]); // reading valid field is OK
s.x = 10;
assert(s.x == 10);
// There's no reinterpretation between S.x and S.y
return true;
}
static assert(test11510());
/**************************************************
11534 - subtitude inout
**************************************************/
struct MultiArray11534
{
this(size_t[] sizes...)
{
storage = new size_t[5];
}
@property auto raw_ptr() inout
{
return storage.ptr + 1;
}
size_t[] storage;
}
enum test11534 = () {
auto m = MultiArray11534(3,2,1);
auto start = m.raw_ptr; //this trigger the bug
//auto start = m.storage.ptr + 1; //this obviously works
return 0;
}();
/**************************************************
11941 - Regression of 11534 fix
**************************************************/
void takeConst11941(const string[]) {}
string[] identity11941(string[] x) { return x; }
bool test11941a()
{
struct S { string[] a; }
S s;
takeConst11941(identity11941(s.a));
s.a ~= [];
return true;
}
static assert(test11941a());
bool test11941b()
{
struct S { string[] a; }
S s;
takeConst11941(identity11941(s.a));
s.a ~= "foo"; /* Error refers to this line (15), */
string[] b = s.a[]; /* but only when this is here. */
return true;
}
static assert(test11941b());
/**************************************************
11535 - element-wise assignment from string to ubyte array literal
**************************************************/
struct Hash11535
{
ubyte[6] _buffer;
void put(scope const(ubyte)[] data...)
{
uint i = 0, index = 0;
auto inputLen = data.length;
(&_buffer[index])[0 .. inputLen - i] = (&data[i])[0 .. inputLen - i];
}
}
auto md5_digest11535(T...)(scope const T data)
{
Hash11535 hash;
hash.put(cast(const(ubyte[]))data[0]);
return hash._buffer;
}
static assert(md5_digest11535(`TEST`) == [84, 69, 83, 84, 0, 0]);
/**************************************************
11540 - goto label + try-catch-finally / with statement
**************************************************/
static assert(()
{
// enter to TryCatchStatement.body
{
bool c = false;
try
{
if (c) // need to bypass front-end optimization
throw new Exception("");
else
{
goto Lx;
L1:
c = true;
}
}
catch (Exception e) {}
Lx:
if (!c)
goto L1;
}
// jump inside TryCatchStatement.body
{
bool c = false;
try
{
if (c) // need to bypass front-end optimization
throw new Exception("");
else
goto L2;
L2:
;
}
catch (Exception e) {}
}
// exit from TryCatchStatement.body
{
bool c = false;
try
{
if (c) // need to bypass front-end optimization
throw new Exception("");
else
goto L3;
}
catch (Exception e) {}
c = true;
L3:
assert(!c);
}
return 1;
}());
static assert(()
{
// enter to TryCatchStatement.catches which has no exception variable
{
bool c = false;
goto L1;
try
{
c = true;
}
catch (Exception/* e*/)
{
L1:
;
}
assert(c == false);
}
// jump inside TryCatchStatement.catches
{
bool c = false;
try
{
throw new Exception("");
}
catch (Exception e)
{
goto L2;
c = true;
L2:
;
}
assert(c == false);
}
// exit from TryCatchStatement.catches
{
bool c = false;
try
{
throw new Exception("");
}
catch (Exception e)
{
goto L3;
c = true;
}
L3:
assert(c == false);
}
return 1;
}());
static assert(()
{
// enter forward to TryFinallyStatement.body
{
bool c = false;
goto L0;
c = true;
try
{
L0:
;
}
finally {}
assert(!c);
}
// enter back to TryFinallyStatement.body
{
bool c = false;
try
{
goto Lx;
L1:
c = true;
}
finally {
}
Lx:
if (!c)
goto L1;
}
// jump inside TryFinallyStatement.body
{
try
{
goto L2;
L2: ;
}
finally {}
}
// exit from TryFinallyStatement.body
{
bool c = false;
try
{
goto L3;
}
finally {}
c = true;
L3:
assert(!c);
}
// enter in / exit out from finally block is rejected in semantic analysis
// jump inside TryFinallyStatement.finalbody
{
bool c = false;
try
{
}
finally
{
goto L4;
c = true;
L4:
assert(c == false);
}
}
return 1;
}());
static assert(()
{
{
bool c = false;
with (Object.init)
{
goto L2;
c = true;
L2:
;
}
assert(c == false);
}
{
bool c = false;
with (Object.init)
{
goto L3;
c = true;
}
L3:
assert(c == false);
}
return 1;
}());
/**************************************************
11627 - cast dchar to char at compile time on AA assignment
**************************************************/
bool test11627()
{
char[ubyte] toCharTmp;
dchar letter = 'A';
//char c = cast(char)letter; // OK
toCharTmp[0] = cast(char)letter; // NG
return true;
}
static assert(test11627());
/**************************************************
11664 - ignore function local static variables
**************************************************/
bool test11664()
{
static int x;
static int y = 1;
return true;
}
static assert(test11664());
/**************************************************
12110 - operand of dereferencing does not need to be an lvalue
**************************************************/
struct SliceOverIndexed12110
{
Uint24Array12110* arr;
@property front(uint val)
{
arr.dupThisReference();
}
}
struct Uint24Array12110
{
ubyte[] data;
this(ubyte[] range)
{
data = range;
SliceOverIndexed12110(&this).front = 0;
assert(data.length == range.length * 2);
}
void dupThisReference()
{
auto new_data = new ubyte[data.length * 2];
data = new_data;
}
}
static m12110 = Uint24Array12110([0x80]);
/**************************************************
12310 - heap allocation for built-in sclar types
**************************************************/
bool test12310()
{
auto p1 = new int, p2 = p1;
assert(*p1 == 0);
assert(*p2 == 0);
*p1 = 10;
assert(*p1 == 10);
assert(*p2 == 10);
auto q1 = new int(3), q2 = q1;
assert(*q1 == 3);
assert(*q2 == 3);
*q1 = 20;
assert(*q1 == 20);
assert(*q2 == 20);
return true;
}
static assert(test12310());
/**************************************************
12499 - initialize TupleDeclaraion in CTFE
**************************************************/
auto f12499()
{
//Initialize 3 ints to 5.
TypeTuple!(int, int, int) a = 5;
return a[0]; //Error: variable _a_field_0 cannot be read at compile time
}
static assert(f12499() == 5);
/**************************************************
12602 - slice in struct literal members
**************************************************/
struct Result12602
{
uint[] source;
}
auto wrap12602a(uint[] r)
{
return Result12602(r);
}
auto wrap12602b(uint[] r)
{
Result12602 x;
x.source = r;
return x;
}
auto testWrap12602a()
{
uint[] dest = [1, 2, 3, 4];
auto ra = wrap12602a(dest[0 .. 2]);
auto rb = wrap12602a(dest[2 .. 4]);
foreach (i; 0 .. 2)
rb.source[i] = ra.source[i];
assert(ra.source == [1,2]);
assert(rb.source == [1,2]);
assert(&ra.source[0] == &dest[0]);
assert(&rb.source[0] == &dest[2]);
assert(dest == [1,2,1,2]);
return dest;
}
auto testWrap12602b()
{
uint[] dest = [1, 2, 3, 4];
auto ra = wrap12602b(dest[0 .. 2]);
auto rb = wrap12602b(dest[2 .. 4]);
foreach (i; 0 .. 2)
rb.source[i] = ra.source[i];
assert(ra.source == [1,2]);
assert(rb.source == [1,2]);
assert(&ra.source[0] == &dest[0]);
assert(&rb.source[0] == &dest[2]);
assert(dest == [1,2,1,2]);
return dest;
}
auto testWrap12602c()
{
uint[] dest = [1, 2, 3, 4];
auto ra = Result12602(dest[0 .. 2]);
auto rb = Result12602(dest[2 .. 4]);
foreach (i; 0 .. 2)
rb.source[i] = ra.source[i];
assert(ra.source == [1,2]);
assert(rb.source == [1,2]);
assert(&ra.source[0] == &dest[0]);
assert(&rb.source[0] == &dest[2]);
assert(dest == [1,2,1,2]);
return dest;
}
auto testWrap12602d()
{
uint[] dest = [1, 2, 3, 4];
Result12602 ra; ra.source = dest[0 .. 2];
Result12602 rb; rb.source = dest[2 .. 4];
foreach (i; 0 .. 2)
rb.source[i] = ra.source[i];
assert(ra.source == [1,2]);
assert(rb.source == [1,2]);
assert(&ra.source[0] == &dest[0]);
assert(&rb.source[0] == &dest[2]);
assert(dest == [1,2,1,2]);
return dest;
}
static assert(testWrap12602a() == [1,2,1,2]);
static assert(testWrap12602b() == [1,2,1,2]);
static assert(testWrap12602c() == [1,2,1,2]);
static assert(testWrap12602d() == [1,2,1,2]);
/**************************************************
12677 - class type initializing from DotVarExp
**************************************************/
final class C12677
{
TypeTuple!(Object, int[]) _test;
this()
{
auto t0 = _test[0]; //
auto t1 = _test[1]; //
assert(t0 is null);
assert(t1 is null);
}
}
struct S12677
{
auto f = new C12677();
}
/**************************************************
12851 - interpret function local const static array
**************************************************/
void test12851()
{
const int[5] arr;
alias staticZip = TypeTuple!(arr[0]);
}
/**************************************************
13630 - indexing and setting array element via pointer
**************************************************/
struct S13630(T)
{
T[3] arr;
this(A...)(auto ref in A args)
{
auto p = arr.ptr;
foreach (ref v; args)
{
*p = 0;
}
}
}
enum s13630 = S13630!float(1);
/**************************************************
13827
**************************************************/
struct Matrix13827(T, uint N)
{
private static defaultMatrix()
{
T arr[N];
return arr;
}
union
{
T[N] A = defaultMatrix;
T[N] flat;
}
this(A...)(auto ref in A args)
{
uint k;
foreach (ref v; args)
flat[k++] = cast(T)v;
}
}
enum m13827 = Matrix13827!(int, 3)(1, 2, 3);
/**************************************************
13847 - support DotTypeExp
**************************************************/
class B13847
{
int foo() { return 1; }
}
class C13847 : B13847
{
override int foo() { return 2; }
final void test(int n)
{
assert(foo() == n);
assert(B13847.foo() == 1);
assert(C13847.foo() == 2);
assert(this.B13847.foo() == 1);
assert(this.C13847.foo() == 2);
}
}
class D13847 : C13847
{
override int foo() { return 3; }
}
static assert({
C13847 c = new C13847();
c.test(2);
assert(c.B13847.foo() == 1);
assert(c.C13847.foo() == 2);
D13847 d = new D13847();
d.test(3);
assert(d.B13847.foo() == 1);
assert(d.C13847.foo() == 2);
assert(d.D13847.foo() == 3);
c = d;
c.test(3);
assert(c.B13847.foo() == 1);
assert(c.C13847.foo() == 2);
return true;
}());
/**************************************************
12495 - cast from string to immutable(ubyte)[]
**************************************************/
string getStr12495()
{
char[1] buf = void; // dummy starting point.
string s = cast(string)buf[0..0]; // empty slice, .ptr points mutable.
assert(buf.ptr == s.ptr);
s ~= 'a'; // this should allocate.
assert(buf.ptr != s.ptr);
return s.idup; // this should allocate again, and
// definitly point immutable memory.
}
auto indexOf12495(string s)
{
auto p1 = s.ptr;
auto p2 = (cast(immutable(ubyte)[])s).ptr;
assert(cast(void*)p1 == cast(void*)p2); // OK <- fails
return cast(void*)p2 - cast(void*)p1; // OK <- "cannot subtract pointers ..."
}
static assert(indexOf12495(getStr12495()) == 0);
/**************************************************
13992 - Repainting pointer arithmetic result
**************************************************/
enum hash13992 = hashOf13992("abcd".ptr);
@trusted hashOf13992(const void* buf)
{
auto data = cast(const(ubyte)*) buf;
size_t hash;
data += 2; // problematic pointer arithmetic
hash += *data; // CTFE internal issue was shown by the dereference
return hash;
}
/**************************************************
13739 - Precise copy for ArrayLiteralExp elements
**************************************************/
static assert(
{
int[] a1 = [13];
int[][] a2 = [a1];
assert(a2[0] is a1); // OK
assert(a2[0].ptr is a1.ptr); // OK <- NG
a1[0] = 1;
assert(a2[0][0] == 1); // OK <- NG
a2[0][0] = 2;
assert(a1[0] == 2); // OK <- NG
return 1;
}());
/**************************************************
14463 - ICE on slice assignment without postblit
**************************************************/
struct Boo14463
{
private int[1] c;
this(int[] x)
{
c = x;
}
}
immutable Boo14463 a14463 = Boo14463([1]);
/**************************************************
13295 - Don't copy struct literal in VarExp::interpret()
**************************************************/
struct S13295
{
int n;
}
void f13295(ref const S13295 s)
{
*cast(int*) &s.n = 1;
assert(s.n == 1); // OK <- fail
}
static assert(
{
S13295 s;
f13295(s);
return s.n == 1; // true <- false
}());
int foo14061(int[] a)
{
foreach (immutable x; a)
{
auto b = a ~ x;
return b == [1, 1];
}
return 0;
}
static assert(foo14061([1]));
/**************************************************
14024 - CTFE version
**************************************************/
bool test14024()
{
string op;
struct S
{
char x = 'x';
this(this) { op ~= x-0x20; } // upper case
~this() { op ~= x; } // lower case
}
S[4] mem;
ref S[2] slice(int a, int b) { return mem[a .. b][0 .. 2]; }
op = null;
mem[0].x = 'a';
mem[1].x = 'b';
mem[2].x = 'x';
mem[3].x = 'y';
slice(0, 2) = slice(2, 4); // [ab] = [xy]
assert(op == "XaYb", op);
op = null;
mem[0].x = 'x';
mem[1].x = 'y';
mem[2].x = 'a';
mem[3].x = 'b';
slice(2, 4) = slice(0, 2); // [ab] = [xy]
assert(op == "XaYb", op);
op = null;
mem[0].x = 'a';
mem[1].x = 'b';
mem[2].x = 'c';
slice(0, 2) = slice(1, 3); // [ab] = [bc]
assert(op == "BaCb", op);
op = null;
mem[0].x = 'x';
mem[1].x = 'y';
mem[2].x = 'z';
slice(1, 3) = slice(0, 2); // [yz] = [xy]
assert(op == "YzXy", op);
return true;
}
static assert(test14024());
/**************************************************
14304 - cache of static immutable value
**************************************************/
immutable struct Bug14304
{
string s_name;
alias s_name this;
string fun()()
{
return "fun";
}
}
class Buggy14304
{
static string fun(string str)()
{
return str;
}
static immutable val = immutable Bug14304("val");
}
void test14304()
{
enum kt = Buggy14304.fun!(Buggy14304.val);
static assert(kt == "val");
enum bt = Buggy14304.val.fun();
static assert(bt == "fun");
}
/**************************************************
14371 - evaluate BinAssignExp as lvalue
**************************************************/
int test14371()
{
int x;
++(x += 1);
return x;
}
static assert(test14371() == 2);
/**************************************************
7151 - [CTFE] cannot compare classes with ==
**************************************************/
bool test7151()
{
auto a = new Object;
return a == a && a != new Object;
}
static assert(test7151());
/**************************************************
12603 - [CTFE] goto does not correctly call dtors
**************************************************/
struct S12603
{
this(uint* dtorCalled)
{
*dtorCalled = 0;
this.dtorCalled = dtorCalled;
}
@disable this();
~this()
{
++*dtorCalled;
}
uint* dtorCalled;
}
auto numDtorCallsByGotoWithinScope()
{
uint dtorCalled;
{
S12603 s = S12603(&dtorCalled);
assert(dtorCalled == 0);
goto L_abc;
L_abc:
assert(dtorCalled == 0);
}
assert(dtorCalled == 1);
return dtorCalled;
}
static assert(numDtorCallsByGotoWithinScope() == 1);
auto numDtorCallsByGotoOutOfScope()
{
uint dtorCalled;
{
S12603 s = S12603(&dtorCalled);
assert(dtorCalled == 0);
goto L_abc;
}
L_abc:
assert(dtorCalled == 1);
return dtorCalled;
}
static assert(numDtorCallsByGotoOutOfScope() == 1);
uint numDtorCallsByGotoDifferentScopeAfter()
{
uint dtorCalled;
{
S12603 s = S12603(&dtorCalled);
assert(dtorCalled == 0);
}
assert(dtorCalled == 1);
goto L_abc;
L_abc:
assert(dtorCalled == 1);
return dtorCalled;
}
static assert(numDtorCallsByGotoDifferentScopeAfter() == 1);
auto numDtorCallsByGotoDifferentScopeBefore()
{
uint dtorCalled;
assert(dtorCalled == 0);
goto L_abc;
L_abc:
assert(dtorCalled == 0);
{
S12603 s = S12603(&dtorCalled);
assert(dtorCalled == 0);
}
assert(dtorCalled == 1);
return dtorCalled;
}
static assert(numDtorCallsByGotoDifferentScopeBefore() == 1);
struct S12603_2
{
~this()
{
dtorCalled = true;
}
bool dtorCalled = false;
}
auto structInCaseScope()
{
auto charsets = S12603_2();
switch(1)
{
case 0:
auto set = charsets;
break;
default:
break;
}
return charsets.dtorCalled;
}
static assert(!structInCaseScope());
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test9565.d 0000644 0001750 0001750 00000006152 13200164641 023370 0 ustar matthias matthias // REQUIRED_ARGS: -o-
// PERMUTE_ARGS:
template TypeTuple(T...) { alias TypeTuple = T; }
bool startsWith(string s, string m) { return s[0 .. m.length] == m; }
void main()
{
enum string castPrefix = "cast(" ~ size_t.stringof ~ ")";
// TypeSArray
static assert((int[10]).stringof == "int[10]", T.stringof);
int[] arr;
// IndexExp
{
// index == IntegerExp
static assert((arr[ 4 ]).stringof == "arr[4]");
static assert((arr[ 4U ]).stringof == "arr[4]");
static assert((arr[ 4L ]).stringof == "arr[4]");
static assert((arr[ 4LU]).stringof == "arr[4]");
// index == UAddExp
static assert((arr[+4 ]).stringof == "arr[4]");
static assert((arr[+4U ]).stringof == "arr[4]");
static assert((arr[+4L ]).stringof == "arr[4]");
static assert((arr[+4LU]).stringof == "arr[4]");
// index == NegExp
static assert((arr[-4 ]).stringof == "arr[" ~ castPrefix ~ "-4]");
static assert((arr[-4U ]).stringof == "arr[4294967292]");
static assert((arr[int.min] ).stringof == "arr[" ~ castPrefix ~ "-2147483648]");
static if (is(size_t == ulong))
{
static assert((arr[-4L ]).stringof == "arr[" ~ castPrefix ~ "-4L]");
static assert((arr[-4LU]).stringof == "arr[-4LU]");
// IntegerLiteral needs suffix if the value is greater than long.max
static assert((arr[long.max + 0]).stringof == "arr[9223372036854775807]");
static assert((arr[long.max + 1]).stringof == "arr[" ~ castPrefix ~ "(9223372036854775807L + 1L)]");
}
foreach (Int; TypeTuple!(byte, ubyte, short, ushort, int, uint, long, ulong))
{
enum Int p4 = +4;
enum string result1 = (arr[p4]).stringof;
static assert(result1 == "arr[4]");
enum string result2 = (arr[cast(Int)+4]).stringof;
static assert(result2 == "arr[4]");
}
foreach (Int; TypeTuple!(byte, short, int, long))
{
// keep "cast(Type)" in the string representation
enum Int m4 = -4;
static if (is(typeof({ size_t x = m4; })))
{
enum string result1 = (arr[m4]).stringof;
static assert(result1.startsWith("arr[" ~ castPrefix));
}
else
static assert(!__traits(compiles, arr[m4]));
enum string result2 = (arr[cast(Int)-4]).stringof;
static assert(result2.startsWith("arr[" ~ castPrefix));
}
}
// SliceExp
{
// lwr,upr == IntegerExp
static assert((arr[4 .. 8 ]).stringof == "arr[4..8]");
static assert((arr[4U .. 8U ]).stringof == "arr[4..8]");
static assert((arr[4L .. 8L ]).stringof == "arr[4..8]");
static assert((arr[4LU .. 8LU]).stringof == "arr[4..8]");
// lwr,upr == UAddExp
static assert((arr[+4 .. +8 ]).stringof == "arr[4..8]");
static assert((arr[+4U .. +8U ]).stringof == "arr[4..8]");
static assert((arr[+4L .. +8L ]).stringof == "arr[4..8]");
static assert((arr[+4LU .. +8LU]).stringof == "arr[4..8]");
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc9037.d 0000644 0001750 0001750 00000000346 13200164641 023313 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 9037
module ddoc9037;
/**
Example:
----
D d = d;
----
----
D d = d;
----
*/
void test9037()
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test14838.d 0000644 0001750 0001750 00000005533 13200164641 023451 0 ustar matthias matthias // PERMUTE_ARGS:
struct A(T) { ~this() {} }
class C { A!int[1] array; }
void test14838() pure nothrow @nogc @safe
{
C c;
c.__xdtor(); // C.~this() will also be inferred to
// pure nothrow @nogc @safe
A!int[1] array;
// scope destructor call does not cause attribute violation.
}
// ----
/*
* This is a reduced test case comes from std.container.Array template,
* to fix the semantic analysis order issue for correct destructor attribute inference.
*
* Before the bugfix:
* 1. StructDeclaration('Array!int')->semantic() instantiates
* RangeT!(Array!int) at the `alias Range = ...;`, but
* StructDeclaration('RangeT!(Array!int)')->semantic() exits
* with sizeok == SIZEOKfwd, because the size of _outer_ field is not yet determined.
* 2. StructDeclaration('Array!int')->semantic() succeeds to determine the size
* (sizeok = SIZEOKdone).
* 3. StructDeclaration('Array!int')->buildOpAssign() will generate opAssign because
* Array!int._data field has identity opAssign member function.
* 4. The semantic3 will get called for the generated opAssign, then
* 6-1. Array!int.~this() semantic3, and
* 6-2. RefCounted!(Array!int.Payload).~this() semantic3
* will also get called to infer their attributes.
* 5. In RefCounted!(Array!int.Payload).~this(), destroy(t) will be instantiated.
* At that, TemplateInstance::expandMembers() will invoke runDeferredSemantic()
* and it will re-run StructDeclaration('RangeT!(Array!int)')->semantic().
* 6. StructDeclaration('RangeT!(Array!int)')->semantic() determines the size
* (sizeok = SIZEOKdone). Then, it will generate identity opAssign and run its semantic3.
* It will need to infer RangeT!(Array!int).~this() attribute, then it requires the
* correct attribute of Array!int.~this().
*
* However, the Array!int.~this() attribute is not yet determined! [bug]
* -> it's wongly handled as impure/system/throwable/gc-able.
*
* -> then, the attribute inference results for
* RangeT!(Array!int).~this() and Array!int.~this() will be incorrect.
*
* After the bugfix:
* In 6, StructDeclaration('RangeT!(Array!int)')->semantic() will check that:
* all base struct types of the instance fields have completed addition of
* special functions (dtor, opAssign, etc).
* If not, it will defer the completion of its semantic pass.
*/
void destroy14838(S)(ref S s) if (is(S == struct))
{
s.__xdtor();
}
struct RefCounted14838(T)
{
~this()
{
T t;
.destroy14838(t);
}
void opAssign(typeof(this) rhs) {}
}
struct RangeT14838(A)
{
A[1] _outer_;
}
struct Array14838(T)
{
struct Payload
{
~this() {}
}
RefCounted14838!Payload _data;
alias Range = RangeT14838!Array14838;
}
class Test14838
{
Array14838!int[1] field;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test10186.d 0000644 0001750 0001750 00000000331 13200164641 023430 0 ustar matthias matthias struct S {
@disable this();
this(int i) {
}
}
class C {
this() {
s = S(1);
}
S s;
}
class CR
{
S s;
this() {
s = S(1);
}
}
void main() {
auto c = new C;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc13270.d 0000644 0001750 0001750 00000000715 13200164641 023365 0 ustar matthias matthias // PERMUTE_ARGS: -w
// REQUIRED_ARGS: -o- -D -Dd${RESULTS_DIR}/compilable
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 13270
module ddoc13270;
/**
* My overloaded function.
*
* Params:
* task = String description of stuff to do.
* tasks = Array of descriptions of stuff to do.
* maxJobs = Max parallel jobs to run while doing stuff.
*/
void doStuff(string task) {}
/// ditto
void doStuff(string[] tasks, int maxJobs) {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test8696.d 0000644 0001750 0001750 00000000213 13200164641 023364 0 ustar matthias matthias // REQUIRED_ARGS: -w
// 8696: incorrect dangling else with version():
version (all):
version (linux)
{
}
else version (OSX)
{
}
else
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/sw_transition_complex.d 0000644 0001750 0001750 00000014323 13200164641 026511 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -c -transition=complex
/*
TEST_OUTPUT:
---
compilable/sw_transition_complex.d(15): use of complex type 'creal' is scheduled for deprecation, use 'std.complex.Complex!(real)' instead
compilable/sw_transition_complex.d(16): use of complex type 'cdouble' is scheduled for deprecation, use 'std.complex.Complex!(double)' instead
compilable/sw_transition_complex.d(17): use of complex type 'cfloat' is scheduled for deprecation, use 'std.complex.Complex!(float)' instead
compilable/sw_transition_complex.d(19): use of imaginary type 'ireal' is scheduled for deprecation, use 'real' instead
compilable/sw_transition_complex.d(20): use of imaginary type 'idouble' is scheduled for deprecation, use 'double' instead
compilable/sw_transition_complex.d(21): use of imaginary type 'ifloat' is scheduled for deprecation, use 'float' instead
---
*/
creal c80value;
cdouble c64value;
cfloat c32value;
ireal i80value;
idouble i64value;
ifloat i32value;
/*
TEST_OUTPUT:
---
compilable/sw_transition_complex.d(34): use of complex type 'creal*' is scheduled for deprecation, use 'std.complex.Complex!(real)' instead
compilable/sw_transition_complex.d(35): use of complex type 'cdouble*' is scheduled for deprecation, use 'std.complex.Complex!(double)' instead
compilable/sw_transition_complex.d(36): use of complex type 'cfloat*' is scheduled for deprecation, use 'std.complex.Complex!(float)' instead
compilable/sw_transition_complex.d(38): use of imaginary type 'ireal*' is scheduled for deprecation, use 'real' instead
compilable/sw_transition_complex.d(39): use of imaginary type 'idouble*' is scheduled for deprecation, use 'double' instead
compilable/sw_transition_complex.d(40): use of imaginary type 'ifloat*' is scheduled for deprecation, use 'float' instead
---
*/
creal* c80pointer;
cdouble* c64pointer;
cfloat* c32pointer;
ireal* i80pointer;
idouble* i64pointer;
ifloat* i32pointer;
/*
TEST_OUTPUT:
---
compilable/sw_transition_complex.d(53): use of complex type 'creal[]*' is scheduled for deprecation, use 'std.complex.Complex!(real)' instead
compilable/sw_transition_complex.d(54): use of complex type 'cdouble[]*' is scheduled for deprecation, use 'std.complex.Complex!(double)' instead
compilable/sw_transition_complex.d(55): use of complex type 'cfloat[]*' is scheduled for deprecation, use 'std.complex.Complex!(float)' instead
compilable/sw_transition_complex.d(57): use of imaginary type 'ireal[]*' is scheduled for deprecation, use 'real' instead
compilable/sw_transition_complex.d(58): use of imaginary type 'idouble[]*' is scheduled for deprecation, use 'double' instead
compilable/sw_transition_complex.d(59): use of imaginary type 'ifloat[]*' is scheduled for deprecation, use 'float' instead
---
*/
creal[]* c80arrayp;
cdouble[]* d64arrayp;
cfloat[]* c32arrayp;
ireal[]* i80arrayp;
idouble[]* i64arrayp;
ifloat[]* i32arrayp;
/*
TEST_OUTPUT:
---
compilable/sw_transition_complex.d(72): use of complex type 'creal[4][]*' is scheduled for deprecation, use 'std.complex.Complex!(real)' instead
compilable/sw_transition_complex.d(73): use of complex type 'cdouble[4][]*' is scheduled for deprecation, use 'std.complex.Complex!(double)' instead
compilable/sw_transition_complex.d(74): use of complex type 'cfloat[4][]*' is scheduled for deprecation, use 'std.complex.Complex!(float)' instead
compilable/sw_transition_complex.d(76): use of imaginary type 'ireal[4][]*' is scheduled for deprecation, use 'real' instead
compilable/sw_transition_complex.d(77): use of imaginary type 'idouble[4][]*' is scheduled for deprecation, use 'double' instead
compilable/sw_transition_complex.d(78): use of imaginary type 'ifloat[4][]*' is scheduled for deprecation, use 'float' instead
---
*/
creal[4][]* c80sarrayp;
cdouble[4][]* c64sarrayp;
cfloat[4][]* c32sarrayp;
ireal[4][]* i80sarrayp;
idouble[4][]* i64sarrayp;
ifloat[4][]* i32sarrayp;
/*
TEST_OUTPUT:
---
compilable/sw_transition_complex.d(96): use of complex type 'creal' is scheduled for deprecation, use 'std.complex.Complex!(real)' instead
compilable/sw_transition_complex.d(97): use of complex type 'creal*' is scheduled for deprecation, use 'std.complex.Complex!(real)' instead
compilable/sw_transition_complex.d(98): use of complex type 'creal[]' is scheduled for deprecation, use 'std.complex.Complex!(real)' instead
compilable/sw_transition_complex.d(99): use of complex type 'creal[4]' is scheduled for deprecation, use 'std.complex.Complex!(real)' instead
compilable/sw_transition_complex.d(101): use of imaginary type 'ireal' is scheduled for deprecation, use 'real' instead
compilable/sw_transition_complex.d(102): use of imaginary type 'ireal*' is scheduled for deprecation, use 'real' instead
compilable/sw_transition_complex.d(103): use of imaginary type 'ireal[]' is scheduled for deprecation, use 'real' instead
compilable/sw_transition_complex.d(104): use of imaginary type 'ireal[4]' is scheduled for deprecation, use 'real' instead
---
*/
alias C14488 = creal;
alias I14488 = ireal;
C14488 calias1;
C14488* calias2;
C14488[] calias3;
C14488[4] calias4;
I14488 ialias1;
I14488* ialias2;
I14488[] ialias3;
I14488[4] ialias4;
/*
TEST_OUTPUT:
---
compilable/sw_transition_complex.d(115): use of complex type 'cdouble' is scheduled for deprecation, use 'std.complex.Complex!(double)' instead
compilable/sw_transition_complex.d(116): use of imaginary type 'idouble' is scheduled for deprecation, use 'double' instead
compilable/sw_transition_complex.d(117): use of complex type 'cdouble' is scheduled for deprecation, use 'std.complex.Complex!(double)' instead
compilable/sw_transition_complex.d(118): use of complex type 'cdouble[]' is scheduled for deprecation, use 'std.complex.Complex!(double)' instead
---
*/
auto cauto = 1 + 0i;
auto iauto = 1i;
size_t c64sizeof = (cdouble).sizeof;
TypeInfo c64ti = typeid(cdouble[]);
/*
TEST_OUTPUT:
---
compilable/sw_transition_complex.d(128): use of complex type 'creal*' is scheduled for deprecation, use 'std.complex.Complex!(real)' instead
compilable/sw_transition_complex.d(128): use of imaginary type 'ireal' is scheduled for deprecation, use 'real' instead
compilable/sw_transition_complex.d(132): use of complex type 'creal' is scheduled for deprecation, use 'std.complex.Complex!(real)' instead
---
*/
void test14488a(creal *p, real r, ireal i)
{
}
creal test14488b()
{
return 1 + 0i;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc13.d 0000644 0001750 0001750 00000000746 13200164641 023140 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 13
/// struct doc
struct Bug4107(T)
{
/// templated function doc
void foo(U)(U u) { }
}
/// alpha
struct Bug4107b(T) {
/// beta
struct B(U) {
/// gamma
struct C(V) {
/// delta
struct D(W) {
/// epsilon
B!W e(X)(C!V c, X[] x...) {}
}
}
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testparse.d 0000644 0001750 0001750 00000007570 13200164641 024077 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -o-
/***************************************************/
// 6719
pragma(msg, __traits(compiles, mixin("(const(A))[0..0]")));
/***************************************************/
// 9232
struct Foo9232
{
void bar(T)() {}
void baz() {}
}
void test9232()
{
Foo9232 foo;
(foo).bar!int(); // OK <- Error: found '!' when expecting ';' following statement
((foo)).bar!int(); // OK
foo.bar!int(); // OK
(foo).baz(); // OK
}
/***************************************************/
// 9401
struct S9401a
{
~this() nothrow pure @safe { }
}
struct S9401b
{
@safe ~this() pure nothrow { }
}
void test9401() nothrow pure @safe
{
S9401a s1;
S9401b s2;
}
/***************************************************/
// 9649
class Outer9649
{
class Inner
{
}
}
void test9649()
{
Outer9649 outer9649;
(outer9649).new Inner();
}
/***************************************************/
// 9679
void test9679(inout int = 0)
{
if ( auto n = 1) { static assert(is(typeof(n) == int)); }
if ( const n = 1) { static assert(is(typeof(n) == const int)); }
if ( immutable n = 1) { static assert(is(typeof(n) == immutable int)); }
if (shared n = 1) { static assert(is(typeof(n) == shared int)); }
if (shared const n = 1) { static assert(is(typeof(n) == shared const int)); }
if ( inout n = 1) { static assert(is(typeof(n) == inout int)); }
if (shared inout n = 1) { static assert(is(typeof(n) == shared inout int)); }
if ( const int n = 1) { static assert(is(typeof(n) == const int)); }
if ( immutable int n = 1) { static assert(is(typeof(n) == immutable int)); }
if (shared int n = 1) { static assert(is(typeof(n) == shared int)); }
if (shared const int n = 1) { static assert(is(typeof(n) == shared const int)); }
if ( inout int n = 1) { static assert(is(typeof(n) == inout int)); }
if (shared inout int n = 1) { static assert(is(typeof(n) == shared inout int)); }
if ( const(int) n = 1) { static assert(is(typeof(n) == const int)); }
if ( immutable(int) n = 1) { static assert(is(typeof(n) == immutable int)); }
if (shared (int) n = 1) { static assert(is(typeof(n) == shared int)); }
if (shared const(int) n = 1) { static assert(is(typeof(n) == shared const int)); }
if ( inout(int) n = 1) { static assert(is(typeof(n) == inout int)); }
if (shared inout(int) n = 1) { static assert(is(typeof(n) == shared inout int)); }
if (immutable(int)[] n = [1]) { static assert(is(typeof(n) == immutable(int)[])); }
}
/***************************************************/
// 9901
template isGood9901(T)
{
enum isGood9901 = true;
}
void test9901()
{
string foo(R)(R data) if (isGood9901!R)
{
return "";
}
foo(1);
}
/***************************************************/
// 10199
void test10199()
{
goto label;
label:
}
/***************************************************/
// 12460
void f12460(T)()
{
static if (is(T == int))
{
goto end;
}
end:
}
void test12460()
{
f12460!int();
}
/***************************************************/
// 11689
void test11689()
{
deprecated void foo() {}
}
/***************************************************/
// 11751
static assert(is(float == typeof(0x0.1p1F)));
/***************************************************/
// 11957
extern(C++) class C11957
{
void x() {}
}
void test11957()
{
extern(C++) class D : C11957
{
override void x() {}
}
}
/***************************************************/
// 13049
enum mangle13049(T) = T.mangleof;
alias FP13049 = void function(scope int); // OK
static assert(mangle13049!FP13049 == mangle13049!(void function(scope int))); // OK <- NG
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test14973.d 0000644 0001750 0001750 00000001753 13200164641 023451 0 ustar matthias matthias template map(fun...)
{
auto map(R)(R r)
{
return MapResult!(fun, R)(r);
}
}
struct MapResult(alias fun, R)
{
R _input;
@property bool empty() { return _input.length == 0; }
@property auto front() { return fun(_input[0]); }
void popFront() { _input = _input[1..$]; }
}
class Foo
{
int baz() { return 1; }
void bar()
{
auto s = [1].map!(i => baz()); // compiles
auto r = [1].map!(
// lambda1
i =>
[1].map!(
// lambda2
j =>
baz()
)
); // compiles <- error
}
}
class Bar
{
int baz;
void bar()
{
auto s = [1].map!(i => baz); // compiles
auto r = [1].map!(
// lambda1
i =>
[1].map!(
// lambda2
j =>
baz
)
); // compiles <- error
}
}
void main() {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice13874.d 0000644 0001750 0001750 00000000737 13200164641 023232 0 ustar matthias matthias // REQUIRED_ARGS: -o-
// PERMUTE_ARGS:
template FunctionTypeOf(func...)
if (func.length == 1)
{
static if (is(typeof(& func[0]) Fsym : Fsym*) && is(Fsym == function) || is(typeof(& func[0]) Fsym == delegate))
{
alias Fsym FunctionTypeOf;
}
else static if (is(typeof(& func[0].opCall) Fobj == delegate))
{
alias Fobj FunctionTypeOf;
}
else
static assert(0);
}
enum DummyEnum;
static assert(!is(FunctionTypeOf!DummyEnum));
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc5446b.d 0000644 0001750 0001750 00000000167 13200164641 023456 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
module ddoc5446b;
/** */
enum A_Enum_New { x }
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test11824.d 0000644 0001750 0001750 00000002331 13200164641 023432 0 ustar matthias matthias // REQUIRED_ARGS: -o-
// PERMUTE_ARGS:
struct Take(R)
{
public R source;
private size_t _maxAvailable;
alias R Source;
@property bool empty()
{
return _maxAvailable == 0 || source.empty;
}
@property auto ref front()
{
return source.front;
}
void popFront()
{
source.popFront();
--_maxAvailable;
}
@property size_t length() const
{
return _maxAvailable;
}
}
struct Repeat(T)
{
private T _value;
enum bool empty = false;
@property inout(T) front() inout { return _value; }
void popFront() {}
}
Take!(Repeat!T) repeat(T)(T value, size_t n)
{
return typeof(return)(Repeat!T(value), n);
}
auto array(Range)(Range r)
{
alias E = typeof(r.front);
//static if (hasLength!Range)
{
if (r.length == 0)
return null;
auto result = new E[](r.length);
size_t i;
static auto trustedGetAddr(T)(ref T t) @trusted nothrow pure
{
return &t;
}
foreach (e; r)
{
*trustedGetAddr(result[i]) = e;
++i;
}
return cast(E[])result;
}
}
enum r = [1].repeat(1).array;
static assert(r == [[1]]);
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/depsOutput9948.d 0000644 0001750 0001750 00000000451 13200164641 024566 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -deps=${RESULTS_DIR}/compilable/depsOutput9948.deps
// POST_SCRIPT: compilable/extra-files/depsOutput.sh
// EXTRA_SOURCES: /extra-files/depsOutput9948a.d
module depsOutput9948;
import depsOutput9948a;
void main()
{
templateFunc!("import std.string;")();
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testprofile.d 0000644 0001750 0001750 00000001022 13200164641 024407 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -profile
template LaLa(E...) {
class LaLa {
this() {
}
}
}
void main() {
// doesn't work
new LaLa!("lala", "lalalalala", "lala",
"lala", "lala", "lala", "lalalala",
"lala", "lala", "lala", "lalala",
"lala", "lala", "lala", "lala",
"lala", "lala", "lala", "lala",
"lala", "lala", "lala", "lala",
"lala", "lala", "lala", "lala");
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test9278a.d 0000644 0001750 0001750 00000000332 13200164641 023524 0 ustar matthias matthias // PREMUTE_ARGS:
// Works fine here
struct datum { float num = 0.0; }
datum emitOne()
{
datum t;
return t;
}
const dataArr = [emitOne()];
// A very bad day
//struct datum { float num = 0.0; }
void main(){}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ldc_github_247.d 0000644 0001750 0001750 00000000074 13200164641 024555 0 ustar matthias matthias import imports.ldc_github_247a;
class A { Value!double v; }
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test1.d 0000644 0001750 0001750 00000000253 13200164641 023114 0 ustar matthias matthias // PERMUTE_ARGS:
class File
{
import imports.test1imp;
static char[] read(char[] name)
{
DWORD size; // DWORD is defined in test1imp
return null;
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test68.d 0000644 0001750 0001750 00000000320 13200164641 023204 0 ustar matthias matthias // PERMUTE_ARGS:
// Bugzilla 4278
import imports.test68a;
class Foo : OtherModuleClass
{
override void foo()
{
super.foo();
}
}
void main()
{
new Foo();
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc11823.d 0000644 0001750 0001750 00000000407 13200164641 023365 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 11823
module ddoc11823;
/// file function name is _file, arg defaults to __FILE__ but not __something__
void file(string arg) { }
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc11.d 0000644 0001750 0001750 00000001715 13200164641 023133 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 11
/// The various floating point exceptions
enum
{
FE_INVALID = 1, ///
FE_DENORMAL = 2, ///
FE_DIVBYZERO = 4, ///
FE_OVERFLOW = 8, ///
FE_UNDERFLOW = 0x10, ///
FE_INEXACT = 0x20, ///
FE_ALL_EXCEPT = 0x3F, /// Mask of all the exceptions
}
alias int myint;
///
myint bar;
///
myint foo(myint x = myint.max)
{
return x;
}
///
class Foo
{
///
this(string s) { }
}
extern (C):
///
struct div_t { int quot,rem; }
///
struct ldiv_t { int quot,rem; }
///
struct lldiv_t { long quot,rem; }
div_t div(int,int); ///
ldiv_t ldiv(int,int); ///
lldiv_t lldiv(long, long); ///
void *calloc(size_t, size_t); ///
void *malloc(size_t); /// dittx
/**
Example:
---
private:
int i = 0;
---
*/
void test1()
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice13920.d 0000644 0001750 0001750 00000000712 13200164641 023213 0 ustar matthias matthias // REQUIRED_ARGS: -o-
// PERMUTE_ARGS:
class Foo
{
void foo()
{
foreach (f; __traits(getOverloads, typeof(this), "bar"))
{
auto dg = &f;
}
foreach (f; __traits(getVirtualMethods, typeof(this), "bar"))
{
auto dg = &f;
}
foreach (f; __traits(getVirtualFunctions, typeof(this), "bar"))
{
auto dg = &f;
}
}
uint bar() { return 0; }
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice13886.d 0000644 0001750 0001750 00000000264 13200164641 023230 0 ustar matthias matthias // REQUIRED__ARGS:
// PERMUTE_ARGS:
struct Y()
{
this() {}
~this() { this = null; }
ref opAssign(S)(S) { }
}
void main()
{
static if (is(typeof({ Y!(); }))) {}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/deprecate14283.d 0000644 0001750 0001750 00000000724 13200164641 024415 0 ustar matthias matthias // REQUIRED_ARGS: -dw
/*
TEST_OUTPUT:
---
compilable/deprecate14283.d(17): Deprecation: this is not an lvalue
compilable/deprecate14283.d(18): Deprecation: super is not an lvalue
---
*/
class C
{
void bug()
{
autoref(this); // suppress warning for auto ref
autoref(super); // suppress warning for auto ref
ref_(this); // still warns
ref_(super); // still warns
}
}
void autoref(T)(auto ref T t) {}
void ref_(T)(ref T) {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc5446.d 0000644 0001750 0001750 00000002032 13200164641 023305 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 5446
module ddoc5446;
import ddoc5446a;
private import ddoc5446b;
/** */
alias A_Foo This_Foo;
/** */
alias A_Foo_Alias This_Foo_Alias;
/** */
alias int This_Int;
/** */
alias A_Enum This_Enum;
/** */
deprecated alias ddoc5446b.A_Enum_New A_Enum_New;
struct Nested
{
}
/** */
struct Bar
{
/** */
alias A_Foo Bar_A_Foo;
/** */
alias A_Foo_Alias Bar_A_Foo_Alias;
/** */
alias A_Int Bar_A_Int;
/** */
alias This_Foo Bar_This_Foo;
/** */
alias This_Foo_Alias Bar_This_Foo_Alias;
/** */
alias This_Int Bar_This_Int;
/** */
alias Nested Nested_Alias;
/** */
alias .Nested Fake_Nested;
/** */
struct Nested
{
/** */
alias Bar Bar_Nested_Bar_Alias;
/** */
alias .Bar Bar_Alias;
/** */
struct Bar
{
}
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc4.d 0000644 0001750 0001750 00000000245 13200164641 023052 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 4
/**
a
*/
enum
{
ONE
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc9497b.d 0000644 0001750 0001750 00000000374 13200164641 023470 0 ustar matthias matthias // EXTRA_SOURCES: extra-files/ddoc9497b.ddoc
// PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 9497b
/**
foo function.
Args: $(XYZ arg1, arg2)
*/
void foo()
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/b1215.d 0000644 0001750 0001750 00000006550 13200164641 022614 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -o-
struct A(Args...)
{
enum i = 1;
// base use case.
Args[0].T mBase;
static assert(is(typeof(mBase) == B.T));
// chained types
Args[0].T.TT mChain;
static assert(is(typeof(mChain) == B.T.TT));
// chained packs
Args[1+1].FArgs[0] mChainPack;
static assert(is(typeof(mChainPack) == B));
// expr
enum mExpr = Args[1].i;
static assert(mExpr == B.i);
// Nested + index eval
Args[Args[0].i2].T mNested;
static assert(is(typeof(mNested) == B.T));
// index with constexpr
Args[i].T mCEIndex;
static assert(is(typeof(mCEIndex) == B.T));
// Nested + index with constexpr
Args[Args[i].i2].T mNestedCE;
static assert(is(typeof(mNestedCE) == B.T));
// alias, base use case
alias UBase = Args[0].T;
static assert(is(UBase == B.T));
// alias, chained types
alias UChain = Args[0].T.TT;
static assert(is(UChain == B.T.TT));
// alias, chained packs
alias UChainPack = Args[1+1].FArgs[0];
static assert(is(UChainPack == B));
// alias, expr
alias uExpr = Args[1].i;
static assert(uExpr == B.i);
// alias, Nested + index eval
alias UNested = Args[Args[0].i2].T;
static assert(is(UNested == B.T));
// alias, index with constexpr
alias UCEIndex = Args[i].T;
static assert(is(UCEIndex == B.T));
// alias, Nested + index with constexpr
alias UNextedCE = Args[Args[i].i2].T;
static assert(is(UNextedCE == B.T));
}
struct B
{
struct T
{
struct TT
{
}
}
enum i = 6;
enum i2 = 0;
}
struct C(Args...)
{
alias FArgs = Args;
}
alias Z = A!(B,B,C!(B,B));
/***************************************************/
// 14889
struct A14889(alias Exc)
{
alias ExceptionType = Exc;
}
alias TT14889(Args...) = Args;
alias X14889a = TT14889!(A14889!Throwable());
alias Y14889a = X14889a[0].ExceptionType;
alias X14889b = TT14889!(A14889!Throwable);
alias Y14889b = X14889b[0].ExceptionType;
/***************************************************/
// 14889
alias TypeTuple14900(T...) = T;
struct S14900
{
alias T = int;
alias U = TypeTuple14900!(long,string);
}
alias Types14900 = TypeTuple14900!(S14900, S14900);
Types14900[0].T a14900; // Types[0] == S, then typeof(a) == S.T == int
Types14900[0].U[1] b14900; // Types[0].U == S.U, then typeof(b) == S.U[1] == string
void test14900()
{
Types14900[0].T a; // Types[0] == S, then typeof(a) == S.T == int
Types14900[0].U[1] b; // Types[0].U == S.U, then typeof(b) == S.U[1] == string
}
/***************************************************/
// 14911
void test14911()
{
struct S {}
int* buf1 = new int[2].ptr; // OK
S* buf2 = (new S[2]).ptr; // OK
S* buf3 = new S[2].ptr; // OK <- broken
}
/***************************************************/
// 14986
alias Id14986(alias a) = a;
struct Foo14986
{
int tsize;
}
struct Bar14986
{
enum Foo14986[] arr = [Foo14986()];
}
Bar14986 test14986()
{
Foo14986[] types;
auto a1 = new void[types[0].tsize]; // TypeIdentifier::toExpression
auto a2 = new void[Id14986!types[0].tsize]; // TypeInstance::toExpression
Bar14986 bar;
auto a3 = Id14986!(typeof(bar).arr[0].tsize); // TypeTypeof::resolve
auto a4 = Id14986!(typeof(return).arr[0].tsize); // TypeReturn::resolve
return Bar14986();
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc12.d 0000644 0001750 0001750 00000000642 13200164641 023132 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 12
int ruhred; /// This documents correctly.
int rühred; /// This should too
/**
* BUG: The parameters are not listed under Params in the generated output
*
* Params:
* ü = first
* ÅŸ = second
* ÄŸ = third
*
*/
int foo(int ü, int ş, int ğ)
{
return ÄŸ;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ldc_github_821.d 0000644 0001750 0001750 00000000124 13200164641 024547 0 ustar matthias matthias // EXTRA_SOURCES: imports/ldc_github_821a.d
import imports.ldc_github_821a;
S* s;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test14666.d 0000644 0001750 0001750 00000000155 13200164641 023443 0 ustar matthias matthias // REQUIRED_ARGS: -o-
// PERMUTE_ARGS:
module test14666;
struct Location
{
import imports.test14666a;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ldc_github_739.d 0000644 0001750 0001750 00000000470 13200164641 024563 0 ustar matthias matthias // EXTRA_SOURCES: imports/ldc_github_739b.d
module ldc_github_739;
import imports.ldc_github_739a;
template map(fun...) {
auto map(Range)(Range) {
return MapResult!(fun, Range)();
}
}
struct MapResult(alias fun, R) {
R _input;
MapResult opSlice() {
return MapResult();
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test8922c.d 0000644 0001750 0001750 00000000453 13200164641 023525 0 ustar matthias matthias // PERMUTE_ARGS:
static import imports.bug8922;
void test()
{
static assert(!__traits(compiles, __traits(parent, imports)));
static assert(!__traits(compiles, __traits(parent, bug8922)));
enum x = __traits(parent, imports.bug8922).stringof;
static assert(x == "package imports");
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test14317.d 0000644 0001750 0001750 00000000363 13200164641 023435 0 ustar matthias matthias
// REQUIRED_ARGS: -O -profile -inline
struct Range {
private string s;
char charAt(int unused1) { return s[0]; }
}
bool count(Range* r, int* unused2)
{
*unused2 = 0;
int unused3;
char c = r.charAt(0);
return true;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testInference.d 0000644 0001750 0001750 00000052714 13200164641 024663 0 ustar matthias matthias
/***************************************************/
// 6265.
pure nothrow @safe int h6265() {
return 1;
}
int f6265a(alias g)() {
return g();
}
pure nothrow @safe int i6265a() {
return f6265a!h6265();
}
int f6265b()() {
return h6265();
}
pure nothrow @safe int i6265b() {
return f6265b();
}
pure nothrow @safe int i6265c() {
return {
return h6265();
}();
}
/***************************************************/
// Make sure a function is not infered as pure if it isn't.
int fNPa() {
return 1;
}
int gNPa()() {
return fNPa();
}
static assert( __traits(compiles, function int () { return gNPa(); }));
static assert(!__traits(compiles, function int () pure { return gNPa(); }));
static assert(!__traits(compiles, function int () nothrow { return gNPa(); }));
static assert(!__traits(compiles, function int () @safe { return gNPa(); }));
/***************************************************/
// Need to ensure the comment in Expression::checkPurity is not violated.
void fECPa() {
void g()() {
void h() {
}
h();
}
static assert( is(typeof(&g!()) == void delegate() pure nothrow @nogc @safe));
static assert(!is(typeof(&g!()) == void delegate()));
}
void fECPb() {
void g()() {
void h() {
}
fECPb();
}
static assert(!is(typeof(&g!()) == void delegate() pure));
static assert( is(typeof(&g!()) == void delegate()));
}
/***************************************************/
// 5635
pure bool foo5635(R = int)(string x)
{
bool result = false;
foreach (dchar d; x)
result = true;
return result;
}
void test5635()
{
foo5635("hi");
}
/***************************************************/
// 5936
auto bug5936c(R)(R i) @safe pure nothrow {
return true;
}
static assert( bug5936c(0) );
/***************************************************/
// 6351
void bug6351(alias dg)()
{
dg();
}
void test6351()
{
void delegate(int[] a...) deleg6351 = (int[] a...){};
alias bug6351!(deleg6351) baz6531;
}
/***************************************************/
// 6359
void impure6359() nothrow @safe @nogc {}
void throwable6359() pure @safe @nogc {}
void system6359() pure nothrow @nogc {}
void gcable6359() pure nothrow @safe {}
int global6359;
void f6359() pure nothrow @safe @nogc
{
static assert(!__traits(compiles, impure6359()));
static assert(!__traits(compiles, throwable6359()));
static assert(!__traits(compiles, system6359()));
static assert(!__traits(compiles, gcable6359()));
static assert(!__traits(compiles, global6359++));
static assert(!__traits(compiles, { impure6359(); }()));
static assert(!__traits(compiles, { throwable6359(); }()));
static assert(!__traits(compiles, { system6359(); }()));
static assert(!__traits(compiles, { gcable6359(); }()));
static assert(!__traits(compiles, { global6359++; }()));
}
void g6359()() pure nothrow @safe @nogc
{
static assert(!__traits(compiles, impure6359()));
static assert(!__traits(compiles, throwable6359()));
static assert(!__traits(compiles, system6359()));
static assert(!__traits(compiles, gcable6359()));
static assert(!__traits(compiles, global6359++));
static assert(!__traits(compiles, { impure6359(); }()));
static assert(!__traits(compiles, { throwable6359(); }()));
static assert(!__traits(compiles, { system6359(); }()));
static assert(!__traits(compiles, { gcable6359(); }()));
static assert(!__traits(compiles, { global6359++; }()));
}
// attribute inference is not affected by the expressions inside __traits(compiles)
void h6359()()
{
static assert( __traits(compiles, impure6359()));
static assert( __traits(compiles, throwable6359()));
static assert( __traits(compiles, system6359()));
static assert( __traits(compiles, gcable6359()));
static assert( __traits(compiles, global6359++));
static assert( __traits(compiles, { impure6359(); }()));
static assert( __traits(compiles, { throwable6359(); }()));
static assert( __traits(compiles, { system6359(); }()));
static assert( __traits(compiles, { gcable6359(); }()));
static assert( __traits(compiles, { global6359++; }()));
}
void test6359() pure nothrow @safe @nogc
{
f6359();
g6359();
h6359();
}
/***************************************************/
// 7017
template map7017(fun...) if (fun.length >= 1)
{
auto map7017()
{
struct Result {
this(int dummy){} // impure member function -> inferred to pure by fixing issue 10329
}
return Result(0); // impure call -> inferred to pure by fixing issue 10329
}
}
int foo7017(immutable int x) pure nothrow { return 1; }
void test7017a() pure
{
int bar7017(immutable int x) pure nothrow { return 1; }
static assert(__traits(compiles, map7017!((){})()));
static assert(__traits(compiles, map7017!q{ 1 }()));
static assert(__traits(compiles, map7017!foo7017()));
static assert(__traits(compiles, map7017!bar7017()));
}
/***************************************************/
// 7017 (little simpler cases)
auto map7017a(alias fun)() { return fun(); } // depends on purity of fun
auto map7017b(alias fun)() { return; } // always pure
auto map7017c(alias fun)() { return yyy7017(); } // always impure
int xxx7017() pure { return 1; }
int yyy7017() { return 1; }
void test7017b() pure
{
static assert( __traits(compiles, map7017a!xxx7017() ));
static assert(!__traits(compiles, map7017a!yyy7017() ));
static assert( __traits(compiles, map7017b!xxx7017() ));
static assert( __traits(compiles, map7017b!yyy7017() ));
static assert(!__traits(compiles, map7017c!xxx7017() ));
static assert(!__traits(compiles, map7017c!yyy7017() ));
}
/***************************************************/
// Test case from std.process
auto escapeArgumentImpl(alias allocator)()
{
return allocator();
}
auto escapeShellArgument(alias allocator)()
{
return escapeArgumentImpl!allocator();
}
pure string escapeShellArguments()
{
char[] allocator()
{
return new char[1];
}
/* Both escape!allocator and escapeImpl!allocator are impure,
* but they are nested template function that instantiated here.
* Then calling them from here doesn't break purity.
*/
return escapeShellArgument!allocator();
}
/***************************************************/
// 8234
void test8234()
{
immutable int x = 0;
alias FP = typeof({ enum e = x; return e; });
static assert(is(FP : int function()));
auto fp = { enum e = x; return e; };
static assert(is(typeof(fp) : int function()));
alias DG = typeof({ auto e = x; return e; });
static assert(is(DG : int delegate()));
auto dg = { auto e = x; return e; };
static assert(is(typeof(dg) : int delegate()));
}
/***************************************************/
// 8504
void foo8504()()
{
static assert(typeof(foo8504!()).stringof == "void()");
static assert(typeof(foo8504!()).mangleof == "FZv");
static assert(foo8504!().mangleof == "_D13testInference12__T7foo8504Z7foo8504FZv");
}
auto toDelegate8504a(F)(auto ref F fp) { return fp; }
F toDelegate8504b(F)(auto ref F fp) { return fp; }
extern(C) void testC8504() {}
void test8504()
{
static assert(typeof(foo8504!()).stringof == "pure nothrow @nogc @safe void()");
static assert(typeof(foo8504!()).mangleof == "FNaNbNiNfZv");
static assert(foo8504!().mangleof == "_D13testInference12__T7foo8504Z7foo8504FNaNbNiNfZv");
auto fp1 = toDelegate8504a(&testC8504);
auto fp2 = toDelegate8504b(&testC8504);
static assert(is(typeof(fp1) == typeof(fp2)));
static assert(typeof(fp1).stringof == "extern (C) void function()");
static assert(typeof(fp2).stringof == "extern (C) void function()");
static assert(typeof(fp1).mangleof == "PUZv");
static assert(typeof(fp2).mangleof == "PUZv");
}
/***************************************************/
// 8751
alias bool delegate(in int) pure Bar8751;
Bar8751 foo8751a(immutable int x) pure
{
return y => x > y; // OK
}
Bar8751 foo8751b(const int x) pure
{
return y => x > y; // error -> OK
}
/***************************************************/
// 8793
alias bool delegate(in int) pure Dg8793;
alias bool function(in int) pure Fp8793;
Dg8793 foo8793fp1(immutable Fp8793 f) pure { return x => (*f)(x); } // OK
Dg8793 foo8793fp2( const Fp8793 f) pure { return x => (*f)(x); } // OK
Dg8793 foo8793dg1(immutable Dg8793 f) pure { return x => f(x); } // OK
Dg8793 foo8793dg2( const Dg8793 f) pure { return x => f(x); } // OK <- error
Dg8793 foo8793pfp1(immutable Fp8793* f) pure { return x => (*f)(x); } // OK
Dg8793 foo8793pdg1(immutable Dg8793* f) pure { return x => (*f)(x); } // OK
Dg8793 foo8793pfp2(const Fp8793* f) pure { return x => (*f)(x); } // OK <- error
Dg8793 foo8793pdg2(const Dg8793* f) pure { return x => (*f)(x); } // OK <- error
// general case for the hasPointer type
Dg8793 foo8793ptr1(immutable int* p) pure { return x => *p == x; } // OK
Dg8793 foo8793ptr2(const int* p) pure { return x => *p == x; } // OK <- error
/***************************************************/
// 9072
struct A9072(T)
{
this(U)(U x) {}
~this() {}
}
void test9072()
{
A9072!int a = A9072!short();
}
/***************************************************/
// 5933 + Issue 8504 - Template attribute inferrence doesn't work
int foo5933()(int a) { return a*a; }
struct S5933
{
double foo()(double a) { return a * a; }
}
// outside function
static assert(typeof(foo5933!()).stringof == "pure nothrow @nogc @safe int(int a)");
static assert(typeof(S5933.init.foo!()).stringof == "pure nothrow @nogc @safe double(double a)");
void test5933()
{
// inside function
static assert(typeof(foo5933!()).stringof == "pure nothrow @nogc @safe int(int a)");
static assert(typeof(S5933.init.foo!()).stringof == "pure nothrow @nogc @safe double(double a)");
}
/***************************************************/
// 9148
void test9148a() pure
{
static int g;
int x;
void foo1() /+pure+/
{
static assert(!__traits(compiles, g++));
x++;
}
void foo2() pure
{
static assert(!__traits(compiles, g++));
x++;
}
foo1();
static assert(is(typeof(&foo1) == void delegate() pure));
foo2();
static assert(is(typeof(&foo2) == void delegate() pure));
void bar1() immutable /+pure+/
{
static assert(!__traits(compiles, g++));
static assert(!__traits(compiles, x++));
}
void bar2() immutable pure
{
static assert(!__traits(compiles, g++));
static assert(!__traits(compiles, x++));
}
bar1();
static assert(is(typeof(&bar1) == void delegate() pure immutable));
bar2();
static assert(is(typeof(&bar2) == void delegate() pure immutable));
struct S
{
void foo1() /+pure+/
{
static assert(!__traits(compiles, g++));
x++;
}
void foo2() pure
{
static assert(!__traits(compiles, g++));
x++;
}
void bar1() immutable /+pure+/
{
static assert(!__traits(compiles, g++));
static assert(!__traits(compiles, x++));
}
void bar2() immutable pure
{
static assert(!__traits(compiles, g++));
static assert(!__traits(compiles, x++));
}
}
S sm;
sm.foo1();
static assert(is(typeof(&sm.foo1) == void delegate() pure));
sm.foo2();
static assert(is(typeof(&sm.foo2) == void delegate() pure));
immutable S si;
si.bar1();
static assert(is(typeof(&si.bar1) == void delegate() pure immutable));
si.bar2();
static assert(is(typeof(&si.bar2) == void delegate() pure immutable));
}
// ----
// inheritance of pure and @safe
void test9148b() pure nothrow @nogc @safe
{
void nf() {}
static assert(is(typeof(&nf) == void delegate() @safe pure));
struct NS
{
void mf() {}
static void sf() {}
}
NS ns;
static assert(is(typeof(&ns.mf) == void delegate() @safe pure));
static assert(is(typeof(&NS.sf) == void function() @safe));
static void sf() {}
static assert(is(typeof(&sf) == void function() @safe));
static struct SS
{
void mf() {}
static void sf() {}
}
SS ss;
static assert(is(typeof(&ss.mf) == void delegate() @safe));
static assert(is(typeof(&SS.sf) == void function() @safe));
}
void impureSystem9148b() {}
void func9148b()()
{
void bar() // do not inherit PUREfwdref
{
static assert(is(typeof(&bar) == void delegate()));
impureSystem9148b();
}
static assert(is(typeof(&bar) == void delegate()));
}
static assert(is(typeof(&func9148b!()) == void function() pure nothrow @nogc @safe));
// ----
// from fail_compilation/fail283.d
pure int double_sqr9148c(int x)
{
int y = x;
void do_sqr() pure { y *= y; }
do_sqr();
return y;
}
void test9148c()
{
assert(double_sqr9148c(10) == 100);
}
// ----
// from fail_compilation/fail348.d
void test9148d() pure
{
void g() // implicitly marked as 'pure'
{
void h() pure
{
// i() and j() are implicitly marked as 'pure'
void i() { }
void j() { i(); g(); } // can call i() and g()
}
}
}
void test9148e()
{
int x;
static assert(is(typeof((int a){ return a + x; }) == int delegate(int) pure nothrow @nogc @safe));
auto dg = (int a){ return a + x; };
static assert(is(typeof(dg) == int delegate(int) pure nothrow @nogc @safe));
}
/***************************************************/
// 12912
struct S12912(alias fun)
{
void f() { fun(); }
}
class C12912
{
int n;
void f() pure
{
S12912!(() => n) s;
// Here lambda should be inferred to weak purity.
s.f();
// And this call will be a pure member function call.
}
}
/***************************************************/
// 10002
void impure10002() {}
void remove10002(alias pred, bool impure = false, Range)(Range range)
{
pred(range[0]);
static if (impure) impure10002();
}
class Node10002
{
Node10002 parent;
Node10002[] children;
void foo() pure
{
parent.children.remove10002!(n => n is parent)();
remove10002!(n => n is parent)(parent.children);
static assert(!__traits(compiles, parent.children.remove10002x!(n => n is parent, true)()));
static assert(!__traits(compiles, remove10002x!(n => n is parent, true)(parent.children)));
Node10002 p;
p.children.remove10002!(n => n is p)();
remove10002!(n => n is p)(p.children);
static assert(!__traits(compiles, p.children.remove10002x!(n => n is p, true)()));
static assert(!__traits(compiles, remove10002x!(n => n is p, true)(p.children)));
}
}
/***************************************************/
// 10148
void fa10148() {} // fa is @system
auto fb10148(T)()
{
struct A(S)
{
// [4] Parent function fb is already inferred to @safe, then
// fc is forcely marked @safe on default until 2.052.
// But fc should keep attribute inference ability
// by overriding the inherited @safe-ty from its parent.
void fc(T2)()
{
// [5] During semantic3 process, fc is not @safe on default.
static assert(is(typeof(&fc) == void delegate()));
fa10148();
}
// [1] this is now inferred to @safe by implementing issue 7511
this(S a) {}
}
// [2] A!int(0) is now calling @safe function, then fb!T also be inferred to @safe
return A!int(0);
}
void test10148()
{
fb10148!int.fc!int; // [0] instantiate fb
// [3] instantiate fc
// [6] Afer semantic3 done, fc!int is deduced to @system.
static assert(is(typeof(&fb10148!int.fc!int) == void delegate() @system));
}
/***************************************************/
// 10289
void test10289()
{
void foo(E)()
{
throw new E("");
}
void bar(E1, E2)()
{
throw new E1("");
throw new E2("");
}
void baz(E1, E2)(bool cond)
{
if (cond)
throw new E1("");
else
throw new E2("");
}
import core.exception;
static class MyException : Exception
{
this(string) @safe pure nothrow { super(""); }
}
static assert( __traits(compiles, () nothrow { foo!Error(); }));
static assert( __traits(compiles, () nothrow { foo!AssertError(); }));
static assert(!__traits(compiles, () nothrow { foo!Exception(); }));
static assert(!__traits(compiles, () nothrow { foo!MyException(); }));
static assert( __traits(compiles, () nothrow { bar!(Error, Exception)(); }));
static assert(!__traits(compiles, () nothrow { bar!(Exception, Error)(); }));
static assert(!__traits(compiles, () nothrow { baz!(Error, Exception)(); }));
static assert(!__traits(compiles, () nothrow { baz!(Exception, Error)(); }));
}
/***************************************************/
// 10296
void foo10296()()
{
int[3] a;
void bar()() { a[1] = 2; }
bar();
pragma(msg, typeof(bar!())); // nothrow @safe void()
}
pure void test10296()
{
foo10296();
}
/***************************************************/
// 12025
struct Foo12025
{
int[5] bar;
}
void test12025a() pure
{
enum n1 = typeof(Foo12025.bar).length; // OK
enum n2 = Foo12025.bar .length; // OK <- error
auto x1 = typeof(Foo12025.bar).length; // OK
auto x2 = Foo12025.bar .length; // OK <- error
}
void test12025b() pure
{
static int[5] bar;
enum n1 = typeof(bar).length; // OK
enum n2 = bar .length; // OK <- error
auto x1 = typeof(bar).length; // OK
auto x2 = bar .length; // OK <- error
}
/***************************************************/
// 12542
int logOf12542(T)(T n)
{
if (n)
return 1 + logOf12542(n/2);
return 0;
}
void test12542() @safe nothrow pure
{
int log = logOf12542(9);
}
/***************************************************/
// 12704
void foo12704() @system;
alias FP12704 = typeof(function() { foo12704(); });
static assert(is(FP12704 == void function() @system));
/***************************************************/
// 12970
@system { @safe void f12970a() {} }
@system { void f12970b() @safe {} }
static assert(is(typeof(&f12970a) == void function() @safe));
static assert(is(typeof(&f12970b) == void function() @safe));
@system { @trusted void f12970c() {} }
@system { void f12970d() @trusted {} }
static assert(is(typeof(&f12970c) == void function() @trusted));
static assert(is(typeof(&f12970d) == void function() @trusted));
@safe { @system void f12970e() {} }
@safe { void f12970f() @system {} }
static assert(is(typeof(&f12970e) == void function() @system));
static assert(is(typeof(&f12970f) == void function() @system));
@safe { @trusted void f12970g() {} }
@safe { void f12970h() @trusted {} }
static assert(is(typeof(&f12970g) == void function() @trusted));
static assert(is(typeof(&f12970h) == void function() @trusted));
@trusted { @safe void f12970i() {} }
@trusted { void f12970j() @safe {} }
static assert(is(typeof(&f12970i) == void function() @safe));
static assert(is(typeof(&f12970j) == void function() @safe));
@trusted { @system void f12970k() {} }
@trusted { void f12970l() @system {} }
static assert(is(typeof(&f12970k) == void function() @system));
static assert(is(typeof(&f12970l) == void function() @system));
/***************************************************/
// Parsing prefix STC_FUNCATTR for variable declaration
__gshared immutable pure nothrow @property @nogc @safe void function() prefix_qualified_fp1;
__gshared{immutable{pure{nothrow{@property{@nogc{@safe{void function() prefix_qualified_fp2;}}}}}}}
static assert(typeof(prefix_qualified_fp1).stringof == typeof(prefix_qualified_fp2).stringof);
static assert(typeof(prefix_qualified_fp1).stringof
== "immutable(void function() pure nothrow @nogc @property @safe)");
const pure nothrow @property @nogc @safe void function()[] prefix_qualified_fp_array1;
const{pure{nothrow{@property{@nogc{@safe{void function()[] prefix_qualified_fp_array2;}}}}}}
static assert(typeof(prefix_qualified_fp_array1).stringof == typeof(prefix_qualified_fp_array2).stringof);
static assert(typeof(prefix_qualified_fp_array1).stringof
== "const(void function() pure nothrow @nogc @property @safe[])");
/***************************************************/
// Parsing prefix, intermediate, or postfix @safe for alias declaration
@safe alias void function() AliasDecl_FP1;
alias @safe void function() AliasDecl_FP2; // is not @safe
alias void function() @safe AliasDecl_FP3;
static assert(AliasDecl_FP1.stringof == "void function() @safe");
static assert(AliasDecl_FP2.stringof == "void function()");
static assert(AliasDecl_FP3.stringof == "void function() @safe");
/***************************************************/
// 13217
void writeln13217(string) {}
nothrow void a13217(T)(T x)
{
try
{
() { writeln13217("a"); } ();
}
catch (Exception e) {}
}
void test13217()
{
a13217(1);
}
/***************************************************/
// 13840
struct Foo13840
{
int opApply(int delegate(int))
{
return 0;
}
}
void func13840()
{
}
void test13840() nothrow
{
try
{
foreach (i; Foo13840()) // generated delegate is throwable
{
func13840(); // throwable function call
}
}
catch
{}
}
// Add more tests regarding inferences later.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/defa.d 0000644 0001750 0001750 00000000317 13200164641 022754 0 ustar matthias matthias // PERMUTE_ARGS:
module defa;
private import imports.defaa;
public abstract class A
{
Display d;
int style;
this() {}
public this(A parent, int style)
{
this.style = style;
d = parent.d;
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test10695.d 0000644 0001750 0001750 00000000232 13200164641 023435 0 ustar matthias matthias // PERMUTE_ARGS:
module a;
void main()
{
mixin("string mod1 = __MODULE__;");
mixin("enum mod2 = __MODULE__;");
static assert(mod2 == "a");
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc10869.d 0000644 0001750 0001750 00000000625 13200164641 023400 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 10869
module ddoc10869;
///
class C
{
const
{
///
void c1Foo() const { }
///
void i1Foo() immutable { }
}
immutable
{
///
void c2Foo() const { }
///
void i2Foo() immutable { }
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice10486.d 0000644 0001750 0001750 00000000101 13200164641 023207 0 ustar matthias matthias void main()
{
typeof(null) null_;
int[1] sarr = null_;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testheader1i.d 0000644 0001750 0001750 00000000337 13200164641 024441 0 ustar matthias matthias // EXTRA_SOURCES: extra-files/header1.d
// REQUIRED_ARGS: -o- -H -Hf${RESULTS_DIR}/compilable/header1i.di -inline
// PERMUTE_ARGS: -d -dw
// POST_SCRIPT: compilable/extra-files/header-postscript.sh header1i
void main() {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ldc_github_841.d 0000644 0001750 0001750 00000000206 13200164641 024552 0 ustar matthias matthias struct Foo
{
static union Bar
{
bool b;
ulong l;
}
Bar bar;
}
static this()
{
Foo foo = Foo();
} ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/empty_file.d 0000644 0001750 0001750 00000000000 13200164641 024177 0 ustar matthias matthias ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testVRP.d 0000644 0001750 0001750 00000016126 13200164641 023431 0 ustar matthias matthias // PERMUTE_ARGS: -O -inline
// Test value-range propagation.
// See Bug 3147, Bug 6000, Bug 5225.
void add() {
byte x, y;
short a = x + y;
}
void leftShift() {
byte x, y;
short z = x << 1;
}
void leftShiftFail() {
ubyte x, y;
ushort z;
static assert(!__traits(compiles, z = x << y));
// 1 << 31 surely overflows the range of 'ushort'.
}
void rightShiftFail() {
short x;
byte y, z;
static assert(!__traits(compiles, z = x >> y));
// [this passes in 2.053.]
}
void rightShift() {
ushort x;
ubyte y = x >> 16;
}
void unsignedRightShiftFail() {
int x;
ubyte y;
static assert(!__traits(compiles, y = x >>> 2));
// [this passes in 2.053.]
}
void subtract() {
ubyte x, y;
short z = x - y;
}
void multiply() {
byte x, y;
short z = x * y;
}
void subMulFail() {
ubyte x, y;
ubyte z;
static assert(!__traits(compiles, z = x - y));
static assert(!__traits(compiles, z = x * y));
// [these pass in 2.053.]
}
void multiplyNeg1() {
byte b;
b = -1 + (b * -1);
static assert(!__traits(compiles, b = -1 + b * ulong.max));
}
void divide() {
short w;
byte y = w / 300;
}
void divideFail() {
short w;
byte y;
static assert(!__traits(compiles, y = w / -1));
}
void plus1Fail() {
byte u, v;
static assert(!__traits(compiles, v = u + 1));
// [these pass in 2.053.]
}
void modulus() {
int x;
byte u = x % 128;
}
void modulus_bug6000a() {
ulong t;
uint u = t % 16;
}
void modulus_bug6000b() {
long n = 10520;
ubyte b;
static assert(!__traits(compiles, b = n % 10));
}
void modulus2() {
short s;
byte b = byte.max;
byte c = s % b;
}
void modulus3() {
int i;
short s = short.max;
short t = i % s;
}
void modulus4() {
uint i;
ushort s;
short t;
static assert(!__traits(compiles, t = i % s));
}
void modulusFail() {
int i;
short s;
byte b;
static assert(!__traits(compiles, b = i % s));
static assert(!__traits(compiles, b = i % 257));
// [these pass in 2.053.]
}
void bitwise() {
ubyte a, b, c;
uint d;
c = a & b;
c = a | b;
c = a ^ b;
c = d & 0xff;
// [these pass in 2.053.]
}
void bitAnd() {
byte c;
int d;
c = (0x3ff_ffffU << (0&c)) & (0x4000_0000U << (0&c));
// the result of the above is always 0 :).
}
void bitOrFail() {
ubyte c;
static assert(!__traits(compiles, c = c | 0x100));
// [this passes in 2.053.]
}
void bitAndOr() {
ubyte c;
c = (c | 0x1000) & ~0x1000;
}
void bitAndFail() {
int d;
short s;
byte c;
static assert(!__traits(compiles, c = d & s));
static assert(!__traits(compiles, c = d & 256));
// [these pass in 2.053.]
}
void bitXor() {
ushort s;
ubyte c;
c = (0xffff << (s&0)) ^ 0xff00;
}
void bitComplement() {
int i;
ubyte b = ~(i | ~0xff);
}
void bitComplementFail() {
ubyte b;
static assert(!__traits(compiles, b = ~(b | 1)));
// [this passes in 2.053.]
}
void negation() {
int x;
byte b = -(x & 0x7);
}
void negationFail() {
int x;
byte b;
static assert(!__traits(compiles, b = -(x & 255)));
// [this passes in 2.053.]
}
short bug5225(short a) {
return a>>1;
}
short bug1977_comment5(byte i) {
byte t = 1;
short o = t - i;
return o;
}
void testDchar() {
dchar d;
uint i;
/+
static assert(!__traits(compiles, d = i));
static assert(!__traits(compiles, d = i & 0x1fffff));
+/
d = i % 0x110000;
}
void bug1977_comment11() {
uint a;
byte b = a & 1;
// [this passes in 2.053.]
}
void bug1977_comment20() {
long a;
int b = a % 1000;
}
/******************************************/
// 9617
void test9617()
{
void f1(int) {}
void f2(short) {}
void f3(byte) {}
// Why these calls are accepted?
static assert(!__traits(compiles, f1(ulong.max)));
static assert(!__traits(compiles, f2(ulong.max)));
static assert(!__traits(compiles, f3(ulong.max)));
// But, if argument is not constant value, compilation fails.
ulong x;
static assert(!__traits(compiles, f1(x))); // is not callable using argument types (ulong)
static assert(!__traits(compiles, f2(x))); // is not callable using argument types (ulong)
static assert(!__traits(compiles, f3(x))); // is not callable using argument types (ulong)
void f4(uint) {}
void f5(ushort) {}
void f6(ubyte) {}
// If parameter type is unsigned, it is collectly rejected
static assert(!__traits(compiles, f4(ulong.max))); // is not callable using argument types (ulong)
static assert(!__traits(compiles, f5(ulong.max))); // is not callable using argument types (ulong)
static assert(!__traits(compiles, f6(ulong.max))); // is not callable using argument types (ulong)
}
//import std.typetuple;
template TypeTuple(T...) { alias TypeTuple = T; }
template staticIota(size_t end)
{
static if (0 < end)
alias staticIota = TypeTuple!(staticIota!(end - 1), end - 1);
else
alias staticIota = TypeTuple!();
}
void test9617a()
{
alias Repr = TypeTuple!(
byte, "127", // T and literal representation of T.max
ubyte, "255",
short, "32767",
ushort, "65535",
int, "2147483647",
uint, "4294967295",
long, "9223372036854775807",
ulong, "18446744073709551615" // "" or "L" -> "signed integral overflow"
);
alias Indices = staticIota!(Repr.length / 2);
foreach (t; Indices)
{
alias T = Repr[t * 2];
void func(T)(T) {}
alias func!T f;
foreach (r; Indices)
{
alias S = Repr[r * 2];
S src = S.max;
enum x = Repr[r * 2 + 1];
foreach (repr; TypeTuple!(S.stringof~".max", x~"", x~"U", x~"L", x~"LU"))
{
static if (S.sizeof != T.sizeof)
static if (is(typeof(mixin(repr)) R))
{
// "Compilable" test should be equal, even if
// the given argument is either constant or runtime variable.
enum ct = __traits(compiles, f( mixin(repr) ));
enum rt = __traits(compiles, f( src ));
static assert(ct == rt);
//import std.string;
//enum msg = format("%6s.max to %-6s variable/constant = %d/%d, constant_repr = (%s) %s",
// S.stringof, T.stringof, rt, ct, R.stringof, repr);
//static if (ct != rt) pragma(msg, msg);
}
}
}
}
}
void test10018(ubyte value)
{
const int c = value;
ubyte b = c;
static assert(!__traits(compiles, b = c - 1));
static assert(!__traits(compiles, b = c + 1));
immutable int i = value;
b = i;
static assert(!__traits(compiles, b = i - 1));
static assert(!__traits(compiles, b = i + 1));
}
void test13001(bool unknown)
{
foreach (const i; 0..unknown?2:3)
{
ubyte b = i;
static assert(!__traits(compiles, b = i - 1));
b = i + 253;
static assert(!__traits(compiles, b = i + 254));
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test13281.d 0000644 0001750 0001750 00000002101 13200164641 023424 0 ustar matthias matthias // REQUIRED_ARGS: -o-
// PERMUTE_ARGS:
/*
TEST_OUTPUT:
---
123
123u
123L
123LU
123.4
123.4F
123.4L
123.4i
123.4Fi
123.4Li
(123.4+5.6i)
(123.4F+5.6Fi)
(123.4L+5.6Li)
---
*/
pragma(msg, 123);
pragma(msg, 123u);
pragma(msg, 123L);
pragma(msg, 123uL);
pragma(msg, 123.4);
pragma(msg, 123.4f);
pragma(msg, 123.4L);
pragma(msg, 123.4i);
pragma(msg, 123.4fi);
pragma(msg, 123.4Li);
pragma(msg, 123.4 +5.6i);
pragma(msg, 123.4f+5.6fi);
pragma(msg, 123.4L+5.6Li);
static assert((123 ).stringof == "123");
static assert((123u ).stringof == "123u");
static assert((123L ).stringof == "123L");
static assert((123uL).stringof == "123LU");
static assert((123.4 ).stringof == "123.4");
static assert((123.4f ).stringof == "123.4F");
static assert((123.4L ).stringof == "123.4L");
static assert((123.4i ).stringof == "123.4i");
static assert((123.4fi).stringof == "123.4Fi");
static assert((123.4Li).stringof == "123.4Li");
static assert((123.4 +5.6i ).stringof == "123.4 + 5.6i");
static assert((123.4f+5.6fi).stringof == "123.4F + 5.6Fi");
static assert((123.4L+5.6Li).stringof == "123.4L + 5.6Li");
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test9919.d 0000644 0001750 0001750 00000000160 13200164641 023364 0 ustar matthias matthias // REQUIRED_ARGS: -o-
module test9919;
public
{
import imports.test9919a;
import imports.test9919b;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/callconv.d 0000644 0001750 0001750 00000001473 13200164641 023662 0 ustar matthias matthias // PERMUTE_ARGS:
import core.stdc.stdarg;
struct ABC
{
int x[4];
}
ABC abc;
int x,y,z;
extern (Pascal):
ABC test1(int xx, int yy, int zz)
{
x = xx;
y = yy;
z = zz;
return abc;
}
extern (Pascal):
ABC test1v(int xx, int yy, int zz, ...)
{
x = xx;
y = yy;
z = zz;
return abc;
}
extern (C):
ABC test2v(int xx, int yy, int zz, ...)
{
x = xx;
y = yy;
z = zz;
return abc;
}
extern (C++):
ABC test3(int xx, int yy, int zz)
{
x = xx;
y = yy;
z = zz;
return abc;
}
ABC test3v(int xx, int yy, int zz, ...)
{
x = xx;
y = yy;
z = zz;
return abc;
}
extern (D):
ABC test4(int xx, int yy, int zz)
{
x = xx;
y = yy;
z = zz;
return abc;
}
ABC test4v(int xx, int yy, int zz, ...)
{
x = xx;
y = yy;
z = zz;
return abc;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test11914.d 0000644 0001750 0001750 00000004524 13200164641 023440 0 ustar matthias matthias // std.array
@property bool empty(T)(in T[] a) { return !a.length; }
@property ref T front(T)(T[] a) { return a[0]; }
void popFront(T)(ref T[] a) { a = a[1 .. $]; }
// std.typecons
struct Tuple(T...)
{
T field;
alias field this;
}
Tuple!T tuple(T...)(T args) { return typeof(return)(args); }
// std.range
template ElementType(R)
{
static if (is(typeof(R.init.front.init) T))
alias T ElementType;
else
alias void ElementType;
}
struct Repeat(T)
{
private T _value;
enum bool empty = false;
@property inout(T) front() inout { return _value; }
void popFront() {}
}
Repeat!T repeat(T)(T value) { return Repeat!T(value); }
struct Zip(R...)
{
//alias Tuple!(staticMap!(.ElementType, R)) ElementType;
static if (R.length == 3)
alias Tuple!(int, int, int) ElementType;
static if (R.length == 2)
alias Tuple!(int, int) ElementType;
R ranges;
this(R rs)
{
foreach (i, Unused; R)
{
ranges[i] = rs[i];
}
}
@property bool empty()
{
foreach (i, Unused; R)
{
if (ranges[i].empty)
return true;
}
return false;
}
@property ElementType front()
{
ElementType result;
return result;
}
void popFront()
{
foreach (i, Unused; R)
{
ranges[i].popFront();
}
}
ElementType opIndex(size_t n)
{
ElementType result;
return result;
}
}
auto zip(Rs...)(Rs ranges) { return Zip!Rs(ranges); }
// std.algorithm
template map(fun...)
{
auto map(Range)(Range r)
{
return MapResult!(fun, Range)(r);
}
}
private struct MapResult(alias fun, R)
{
R _input;
this(R input)
{
_input = input;
}
@property bool empty() { return _input.empty; }
@property auto ref front() { return fun(_input.front); }
void popFront() { _input.popFront(); }
}
auto cartesianProduct(R1, R2)(R1 range1, R2 range2)
{
return range2.map!((ElementType!R2 a) => zip(range1, repeat(a)));
}
auto cartesianProduct(R1, R2, RR...)(R1 range1, R2 range2, RR otherRanges)
{
return map!(a => tuple(a[0], a[1][0], a[1][1]))(
cartesianProduct(range1, cartesianProduct(range2, otherRanges))
);
}
// test
void main()
{
foreach (i, j, k; cartesianProduct([1], [1], [1])) {}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test9639.d 0000644 0001750 0001750 00000001053 13200164641 023365 0 ustar matthias matthias class A { this(A) {} }
class B {}
class C {}
// two sibling nested functions in main
typeof(null) foo(alias fn)(A a) { fn(a); return foo!fn(B.init); }
typeof(null) foo(alias fn)(B b) { return foo!fn(A.init); }
// three sibling nested functions in main
typeof(null) bar(alias fn)(A a) { fn(a); return bar!fn(B.init); }
typeof(null) bar(alias fn)(B b) { return bar!fn(C.init); }
typeof(null) bar(alias fn)(C c) { return bar!fn(A.init); }
void main()
{
A a;
foo!((stuff){ new A(a); })(a);
bar!((stuff){ new A(a); })(a);
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test7190.d 0000644 0001750 0001750 00000000243 13200164641 023353 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -c -Icompilable/extra-files
import example7190.controllers.HomeController;
import example7190.models.HomeModel;
void main(){}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test9209.d 0000644 0001750 0001750 00000000251 13200164641 023355 0 ustar matthias matthias // PERMUTE_ARGS:
// 9209
auto array(T)(T t){ return t; }
auto bar()(in int* x)
{
if (true) return 0;
return array(bar(x));
}
void main ()
{
bar(null);
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testDIP37.d 0000644 0001750 0001750 00000001261 13200164641 023542 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -c -Icompilable/extra-files
void test1()
{
import pkgDIP37.datetime;
def();
pkgDIP37.datetime.def();
pkgDIP37.datetime.common.def();
}
void test3()
{
import pkgDIP37.datetime.common;
def();
pkgDIP37.datetime.def();
pkgDIP37.datetime.common.def();
}
void test4()
{
import pkgDIP37.datetime : def;
def();
static assert(!__traits(compiles, pkgDIP37.datetime.def()));
static assert(!__traits(compiles, pkgDIP37.datetime.common.def()));
}
void test7()
{
static import pkgDIP37.datetime;
static assert(!__traits(compiles, def()));
pkgDIP37.datetime.def();
pkgDIP37.datetime.common.def();
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/aliasdecl.d 0000644 0001750 0001750 00000002307 13200164641 023777 0 ustar matthias matthias template Test(T){ alias Type = T; }
alias X1 = int;
static assert(is(X1 == int));
alias X2 = immutable(long)[], X3 = shared const double[int];
static assert(is(X2 == immutable(long)[]));
static assert(is(X3 == shared const double[int]));
alias X4 = void delegate() const, X5 = Test!int;
static assert(is(X4 == void delegate() const));
static assert(is(X5.Type == int));
alias FP5 = extern(C) pure nothrow @safe @nogc void function(),
DG5 = extern(D) pure nothrow @safe @nogc void delegate();
static assert(FP5.stringof == "extern (C) void function() pure nothrow " /* ~ "@safe " */ ~ "@nogc");
static assert(DG5.stringof == "void delegate() pure nothrow " /* ~ "@safe " */ ~ "@nogc");
void main()
{
alias Y1 = int;
static assert(is(Y1 == int));
alias Y2 = immutable(long)[], Y3 = shared const double[int];
static assert(is(Y2 == immutable(long)[]));
static assert(is(Y3 == shared const double[int]));
alias Y4 = void delegate() const, Y5 = Test!int;
static assert(is(Y4 == void delegate() const));
static assert(is(Y5.Type == int));
/+ struct S
{
int value;
alias this = value;
}
auto s = S(10);
int n = s;
assert(n == 10); +/
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice13245.d 0000644 0001750 0001750 00000000165 13200164641 023215 0 ustar matthias matthias // REQUIRED_ARGS: -o-
// PERMUTE_ARGS:
template T(alias f) {}
static assert(!is(T!( (int x){ return invalid; } )));
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc9764.sh 0000755 0001750 0001750 00000000442 13200164641 023511 0 ustar matthias matthias #!/usr/bin/env bash
name=`basename $0 .sh`
dir=${RESULTS_DIR}/compilable
output_file=${dir}/${name}.html
rm -f ${output_file}
$DMD -m${MODEL} -D -o- compilable/extra-files/ddoc9764.dd -Df${output_file}
compilable/extra-files/ddocAny-postscript.sh 9764 && touch ${dir}/`basename $0`.out
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testheader2i.d 0000644 0001750 0001750 00000000330 13200164641 024433 0 ustar matthias matthias // EXTRA_SOURCES: extra-files/header2.d
// REQUIRED_ARGS: -o- -H -Hf${RESULTS_DIR}/compilable/header2i.di -inline
// PERMUTE_ARGS:
// POST_SCRIPT: compilable/extra-files/header-postscript.sh header2i
void main() {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ldc_github_1308.d 0000644 0001750 0001750 00000000162 13200164641 024632 0 ustar matthias matthias interface Foo {
package @property bool baz() { return true; }
}
bool consumer(Foo f) {
return f.baz();
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc9369.d 0000644 0001750 0001750 00000000366 13200164641 023325 0 ustar matthias matthias // PERMUTE_ARGS:
// EXTRA_SOURCES: /extra-files/ddoc9369.ddoc
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 9369
/**
Sample:
---
a=1;
writeln(&a);
!
?
---
*/
void foo() { }
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test10981.d 0000644 0001750 0001750 00000000527 13200164641 023442 0 ustar matthias matthias void foo(int i)
in
{
class X1
{
void in_nested() pure
in { assert(i); } // OK <- NG
out { assert(i); } // OK <- NG
body {}
}
}
out
{
class X2
{
void out_nested() pure
in { assert(i); } // OK <- NG
out { assert(i); } // OK <- NG
body {}
}
}
body
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc5446a.d 0000644 0001750 0001750 00000000306 13200164641 023450 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
module ddoc5446a;
/** */
struct A_Foo { }
/** */
alias A_Foo A_Foo_Alias;
/** */
alias int A_Int;
/** */
enum A_Enum { x }
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test13193.d 0000644 0001750 0001750 00000004004 13200164641 023432 0 ustar matthias matthias // REQUIRED_ARGS: -O -inline -c
final class SharedLib {
void getSymbol() {return getSymbolImpl();}
void getSymbolImpl() {return getSymbol_();}
/* add more intermediate functions to go slower */
void getSymbol_() {}
}
void test13193()
{
SharedLib ssllib;
void bindFunc() {ssllib.getSymbol();}
bindFunc(); /* add more of these to go slower */
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc(); /* 10 */
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc(); /* 20 */
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc(); /* 30 */
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc(); /* 40 */
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc(); /* 50 */
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc(); /* 60 */
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc(); /* 70 */
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc(); /* 80 */
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc(); /* 90 */
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc();
bindFunc(); /* 100 */
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/testheader1.d 0000644 0001750 0001750 00000000337 13200164641 024270 0 ustar matthias matthias // EXTRA_SOURCES: extra-files/header1.d
// REQUIRED_ARGS: -o- -unittest -H -Hf${RESULTS_DIR}/compilable/header1.di
// PERMUTE_ARGS: -d -dw
// POST_SCRIPT: compilable/extra-files/header-postscript.sh header1
void main() {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/line.d 0000644 0001750 0001750 00000000623 13200164641 023004 0 ustar matthias matthias module line;
static assert(__LINE__ == 3);
int #line 10
x;
static assert(__LINE__ == 12);
version(Windows)
static assert(__FILE__ == "compilable\\line.d");
else
static assert(__FILE__ == "compilable/line.d");
#line 100 "newfile.d"
static assert(__LINE__ == 101);
static assert(__FILE__ == "newfile.d");
# line 200
static assert(__LINE__ == 201);
static assert(__FILE__ == "newfile.d");
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc10.d 0000644 0001750 0001750 00000005665 13200164641 023142 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 10
// 294
/// The foo
struct Foo(T) { }
/// ditto
struct Foo(T,U) { }
/** This basic case doesn't work very well. The template signature is
* documented twice, but the function signature (argument names and return
* type) is not documented at all. This comment is also repeated twice. */
int func1(T)(T x) {}
/** This comment is also repeated twice, and the second function signature is
* not very well documented. */
int func2(T,U)(T x, U y) {}
/// ditto
int func2(T)(T x) {}
/// Separate overload item.
int func2()() {}
///
template func3(T,U) {
/** This used to work adequately and documented both func3 templates
* simultaneously. Now, it documents the first template twice and
* no longer documents the function argument and return types.*/
int func3(T x, U y) {}
}
/// ditto
deprecated template func3(T, U=int, V:long) {
private int func3(T x) {}
}
/**
* blah
*/
void map(char rs)
{
}
/// Ditto
void map(int rs)
{
}
/**
* blah
*/
void map2()(char rs)
{
}
/// Ditto
void map2()(int rs)
{
}
/**
* blah http://www.map3.com map3
*/
void map3(char rs)
{
}
/**
* blah http://www.map.com map
*/
void map4(string s)(char rs)
{
}
/**
* blah http://www.map.com map
*/
template map5(string s)
{
}
/** blah */
struct bar6 {
int blah;
}
/** template bodies */
struct Foo7(T) {
/**Attempt one: Doc outside static if.*/
static if(is(T == uint)) {
/**Attempt two: Inside.*/
void bar() {}
}
else {
/**Attempt two: else.*/
void bar() {}
}
/** the abc function should be static */
static void abc() { }
}
/** show abstract */
abstract class Foo8 { }
/// a stray $(RPAREN) mustn't foul the macros
void bug4878(string a = ")") {}
/****
*/
struct S
{
/****
*/
this(long ticks) const pure nothrow { }
/****
*/
const pure nothrow this(this) { }
/****
*/
const pure nothrow ~this() { }
/****
*/
void foo(long ticks) const pure nothrow { }
}
/** Produces something in (a;b] */
float f10(float a, float b) { return (a+b)/2.0; }
/** Produces something in [a;b) */
float h10(float a, float b) { return (a+b)/2.0; }
///
void bug6090(string f="$(B b)", char g=')')(string h="$(", string i="$)") {}
/****
*/
struct T
{
/****
*/
this(A...)(A args) { }
///
this(int){}
}
// 14547
/// doc-comment
int x14547 = 1;
/// ditto
enum int y14547 = 2;
/// doc-comment
enum isInt14547(T) = is(T == int);
/// ditto
enum bool isString14547(T) = is(T == string);
/// ditto
static immutable typeName14547(T) = T.stringof;
/// ditto
int storageFor14547(T) = 0;
/// doc-comment
template foo14547(T)
{
enum int foo14547 = T.stringof.length;
}
/// ditto
template bar14547(T) if (is(T == int))
{
enum int bar14547 = T.stringof.length;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/art4769.d 0000644 0001750 0001750 00000000545 13200164641 023200 0 ustar matthias matthias // http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.bugs&article_id=4769
// EXTRA_SOURCES: imports/art4769a.d imports/art4769b.d
// PERMUTE_ARGS:
module art4769;
private import imports.art4769a;
struct Vector(T)
{
DataStreamability!(T).footype f;
static if (DataStreamability!(T).isStreamable)
void writeTo()
{
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test14275.d 0000644 0001750 0001750 00000000110 13200164641 023426 0 ustar matthias matthias // REQUIRED_ARGS: -o-
// PERMUTE_ARGS:
import protection.bug.bug14275;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test13008.d 0000644 0001750 0001750 00000000262 13200164641 023427 0 ustar matthias matthias // REQUIRED_ARGS: -o-
// PERMUTE_ARGS: -d -de -dw
/*
TEST_OUTPUT*
---
---
*/
deprecated class Dep { }
deprecated Dep depFunc1(); // error
deprecated void depFunc2(Dep); // error
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/ 0000755 0001750 0001750 00000000000 13200164642 023405 5 ustar matthias matthias ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/ice10598a.d 0000644 0001750 0001750 00000000311 13200164641 025054 0 ustar matthias matthias module imports.ice10598a;
template TypeTuple(TL...) { alias TL TypeTuple; }
alias TypeTuple!(__traits(getMember, imports.ice10598b, (__traits(allMembers, imports.ice10598b)[1])))[0] notImportedType;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/typecons4003.d 0000644 0001750 0001750 00000001004 13200164641 025717 0 ustar matthias matthias module imports.typecons4003;
struct Tuple(T...)
{
alias T Types;
Types field;
ref Tuple!(Types[from .. to]) slice(uint from, uint to)()
{
return *cast(typeof(return) *) &(field[from]);
}
void test() //unittest
{
.Tuple!(int, string, float, double) a;
a.field[1] = "abc";
a.field[2] = 4.5;
auto s = a.slice!(1, 3);
static assert(is(typeof(s) == Tuple!(string, float)));
//assert(s.field[0] == "abc" && s.field[1] == 4.5);
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/ice10598b.d 0000644 0001750 0001750 00000000057 13200164641 025064 0 ustar matthias matthias module imports.ice10598b;
struct LocalType {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test9919b.d 0000644 0001750 0001750 00000000343 13200164641 025226 0 ustar matthias matthias module imports.test9919b;
class Event
{
mixin genToString; // @BUG@
}
class MouseEvent : Event
{
enum Action { A, B }
}
mixin template genToString()
{
override string toString()
{
return "";
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test10375a.d 0000644 0001750 0001750 00000000117 13200164641 025270 0 ustar matthias matthias module imports.test10375a;
private template Pack(T...)
{
alias T tuple;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/art4769b.d 0000644 0001750 0001750 00000000174 13200164641 025035 0 ustar matthias matthias private import imports.art4769a;
private import art4769;
int main(char [][] args)
{
Vector!(wchar) str;
return 0;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test6013.d 0000644 0001750 0001750 00000000446 13200164641 025046 0 ustar matthias matthias module imports.test6013;
int value;
int func() { return 0; };
public alias value public_alias_value;
private alias value private_alias_value;
public alias func public_alias_func;
private alias func private_alias_func;
public alias int public_alias_type;
private alias int private_alias_type;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test66a.d 0000644 0001750 0001750 00000000075 13200164641 025047 0 ustar matthias matthias module imports.test66a;
import test66;
class A : Lexer
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test7491b.d 0000644 0001750 0001750 00000000032 13200164641 025212 0 ustar matthias matthias module imports.test7491b;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/jsonimport3.d 0000644 0001750 0001750 00000000074 13200164641 026041 0 ustar matthias matthias module imports.jsonimport3;
int target1, target2, target3;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test9436interp.d 0000644 0001750 0001750 00000000373 13200164641 026303 0 ustar matthias matthias module imports.test9436interp;
import imports.test9436type;
import imports.test9436aggr;
class ReferenceValueT(T)
{
void doCast()
{
auto x = Type.ConversionFlags.kAllowBaseClass;
}
}
class ClassValue : ReferenceValueT!Class
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/testcov1a.d 0000644 0001750 0001750 00000000116 13200164641 025460 0 ustar matthias matthias module testcov1a;
import testcov1b;
alias ArraySet!(int,3) IntegerSet;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test1imp.d 0000644 0001750 0001750 00000000027 13200164641 025316 0 ustar matthias matthias
alias uint DWORD;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test9436aggr.d 0000644 0001750 0001750 00000000150 13200164641 025713 0 ustar matthias matthias module imports.test9436aggr;
import imports.test9436type;
class Aggregate : Type
{
}
class Class
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/protectionimp.d 0000644 0001750 0001750 00000001043 13200164642 026444 0 ustar matthias matthias private
{
void privF() {}
class privC {}
struct privS {}
union privU {}
interface privI {}
enum privE { foo }
mixin template privMT() {}
void privTF(T)() {}
class privTC(T) {}
struct privTS(T) {}
union privTU(T) {}
interface privTI(T) {}
}
void publF(T)() {}
void publFA(alias A)() {}
private alias privC privA;
public mixin template publMT() {}
/***************************************************/
// 14169
template GetName14169(TemplateParam)
{
enum GetName14169 = TemplateParam.Name;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/imp12242a2.d 0000644 0001750 0001750 00000000241 13200164642 025152 0 ustar matthias matthias module imports.imp12242a2;
// std.algorithm.strip
auto stripA(R, E)(R range, E element)
{
return 2;
}
auto stripA(alias pred, R)(R range)
{
return 3;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test9276expr.d 0000644 0001750 0001750 00000000260 13200164642 025756 0 ustar matthias matthias module imports.test9276expr;
import imports.test9276parser;
import imports.test9276util;
class Node
{
mixin DownCastMethods!Declaration;
}
class Expression : Node
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test11225c.d 0000644 0001750 0001750 00000000044 13200164642 025265 0 ustar matthias matthias module imports.test11225c;
// empty
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test25b.d 0000644 0001750 0001750 00000000132 13200164642 025036 0 ustar matthias matthias module imports.test25b;
import imports.test25a;
import core.stdc.stdio;
class Bfoo
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/ldc_github_662d.d 0000644 0001750 0001750 00000000240 13200164642 026413 0 ustar matthias matthias module imports.ldc_github_662d;
template RCounted() {
void release() { this.destroy; }
}
struct RC(T) {
~this() { _rc_ptr.release; }
T _rc_ptr;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/b33a.d 0000644 0001750 0001750 00000000546 13200164642 024307 0 ustar matthias matthias module imports.b33a;
struct IsEqual( T )
{
bool opCall( char p1, char p2 )
{
return p1 == p2;
}
}
template find_( Elem, Pred = IsEqual!(Elem) )
{
size_t fn( char[] buf, Pred pred = Pred.init )
{
return 3;
}
}
template find()
{
size_t find( char[3] buf )
{
return find_!(char).fn( buf );
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/fwdref9514.d 0000644 0001750 0001750 00000000073 13200164642 025352 0 ustar matthias matthias bool find9514(alias pred, R)(R range)
{
return true;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test11225b.d 0000644 0001750 0001750 00000000531 13200164642 025265 0 ustar matthias matthias module imports.test11225b;
import test11225a;
interface J : I {} // remove this line to make it work
static assert(is(typeof({ import imports.test11225c; }))); // OK
pragma(msg, B!().result); // just instantiates the template
template B()
{
static assert(is(typeof({ import imports.test11225c; }))); // FAILS
enum result = "WORKS";
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test68a.d 0000644 0001750 0001750 00000000146 13200164642 025051 0 ustar matthias matthias module imports.test68a;
class OtherModuleClass
{
protected void foo()
{
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/b3682.d 0000644 0001750 0001750 00000000076 13200164642 024321 0 ustar matthias matthias module imports.b3682;
import a3682;
alias Tuple!(int) tint;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test9399a.d 0000644 0001750 0001750 00000000075 13200164642 025232 0 ustar matthias matthias module imports.test9399a;
void call(alias n)() {
n();
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/jsonimport4.d 0000644 0001750 0001750 00000000034 13200164642 026037 0 ustar matthias matthias module imports.jsonimport4;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test14666a.d 0000644 0001750 0001750 00000000166 13200164642 025304 0 ustar matthias matthias module imports.test14666a;
auto getNames()
{
import imports.test14666b;
return "";
}
enum Names = getNames;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test72a.d 0000644 0001750 0001750 00000000067 13200164642 025046 0 ustar matthias matthias module imports.test72a;
public import imports.test72b;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test9692b.d 0000644 0001750 0001750 00000000041 13200164642 025220 0 ustar matthias matthias module imports.test9692b;
int j;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test55a.d 0000644 0001750 0001750 00000000256 13200164642 025047 0 ustar matthias matthias module imports.test55a;
import test55;
class Arm {
alias int ListHead;
MessageQueue.ListHead mqueue;
}
class Arm2 {
alias int ListHead;
Queue2.ListHead mqueue;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/defad.d 0000644 0001750 0001750 00000000246 13200164642 024617 0 ustar matthias matthias
module imports.defad;
private import imports.defac;
private import imports.defab;
public class D : C
{
B [] tabList;
this() {}
this(D parent, int style){ }
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/testcov1b.d 0000644 0001750 0001750 00000000444 13200164642 025466 0 ustar matthias matthias module testcov1b;
class ArraySet(Key, int div = 1)
{
private Key[][div] polje;
public this(in ArraySet a)
{
foreach(Key k, uint i; a)
this.add(k);
}
public void add(Key elem)
{
}
int opApply(int delegate(ref Key x, ref uint y) dg) const
{
return 0;
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/jsonimport2.d 0000644 0001750 0001750 00000000063 13200164642 026037 0 ustar matthias matthias module imports.jsonimport2;
int target1, target2;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test9276hash.d 0000644 0001750 0001750 00000000035 13200164642 025723 0 ustar matthias matthias module imports.test9276hash;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/ldc_github_739b.d 0000644 0001750 0001750 00000000360 13200164642 026421 0 ustar matthias matthias module imports.ldc_github_739b;
import ldc_github_739;
import imports.ldc_github_739a;
struct MatchTree {
struct TerminalTag {}
TerminalTag[] m_terminalTags;
void print() {
m_terminalTags.map!(t => "").array;
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/ldc_github_247a.d 0000644 0001750 0001750 00000000504 13200164642 026412 0 ustar matthias matthias module imports.ldc_github_247a;
class ReadValue(T = int){
void get_value(){ if( ctrl.active ){} }
}
class Value(T) : ReadValue!(T) {
auto opAssign(T value){ // <<<=== change to Value!T to solve the ice
return this;
}
}
static Controller ctrl;
class Controller {
bool active;
Value!(int) pulse;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test4003a.d 0000644 0001750 0001750 00000000114 13200164642 025175 0 ustar matthias matthias module imports.test4003a;
import imports.typecons4003;
Tuple!(string) t;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/imp12242a1.d 0000644 0001750 0001750 00000000217 13200164642 025154 0 ustar matthias matthias module imports.imp12242a1;
// std.string.strip
int stripA(C)(C[] str) @safe pure
if (is(immutable C == immutable char))
{
return 1;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/defac.d 0000644 0001750 0001750 00000000241 13200164642 024611 0 ustar matthias matthias
module imports.defac;
private import imports.defab;
public abstract class C : B
{
private import imports.defad;
this() {}
this(D parent, int style) {}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/defab.d 0000644 0001750 0001750 00000000176 13200164642 024617 0 ustar matthias matthias
module imports.defab;
private import defa;
public class B : A
{
private import imports.defad;
D parent;
this() {}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test9436type.d 0000644 0001750 0001750 00000000247 13200164642 025764 0 ustar matthias matthias module imports.test9436type;
import imports.test9436node;
class Type
{
mixin ForwardCtor!();
enum ConversionFlags
{
kAllowBaseClass = 0
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test10752.d 0000644 0001750 0001750 00000000054 13200164642 025127 0 ustar matthias matthias module imports.test10752;
private int priv;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test59a.d 0000644 0001750 0001750 00000000064 13200164642 025050 0 ustar matthias matthias module imports.test59a;
import test59;
HRESULT h;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test11563std_array.d 0000644 0001750 0001750 00000000204 13200164642 027036 0 ustar matthias matthias module imports.test11563std_array;
void popFront(S)(ref S str)// @trusted pure nothrow
{
import imports.test11563core_bitop;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/a14528.d 0000644 0001750 0001750 00000000071 13200164642 024374 0 ustar matthias matthias module imports.a14528;
void foo(alias f)()
{
f();
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test11563std_traits.d 0000644 0001750 0001750 00000000540 13200164642 027231 0 ustar matthias matthias module imports.test11563std_traits;
import imports.test11563std_range;
bool startsWith(R1, R2)(R1 doesThisStart, R2 withThis)
if (isInputRange!R1)
{
return true;
}
template moduleName(alias T)
{
static if (T.stringof.startsWith("module "))
{
enum moduleName = "b";
}
else
{
pragma(msg, "--error--");
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test9276type.d 0000644 0001750 0001750 00000000221 13200164642 025756 0 ustar matthias matthias module imports.test9276type;
import imports.test9276parser;
class Type : Expression // <- note to Walter.
{
}
class BasicType : Type
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test25a.d 0000644 0001750 0001750 00000000214 13200164642 025036 0 ustar matthias matthias module imports.test25a;
import imports.test25b;
import core.stdc.stdio;
class Afoo
{
static this()
{
printf("Afoo()\n");
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test70.d 0000644 0001750 0001750 00000000047 13200164642 024701 0 ustar matthias matthias module imports.test70;
void foo()
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/imp12242b2.d 0000644 0001750 0001750 00000000241 13200164642 025153 0 ustar matthias matthias module imports.imp12242b2;
// std.algorithm.strip
auto stripB(R, E)(R range, E element)
{
return 2;
}
auto stripB(alias pred, R)(R range)
{
return 3;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/stdio4003.d 0000644 0001750 0001750 00000000070 13200164642 025200 0 ustar matthias matthias module imports.stdio4003;
import imports.typecons4003;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/a8392.d 0000644 0001750 0001750 00000000222 13200164642 024314 0 ustar matthias matthias module imports.a8392;
import ice8392;
class B
{
this(B);
}
void foob(A a, B b)
{
a.fooa!((arg){
return new B(b);
});
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test67a.d 0000644 0001750 0001750 00000000270 13200164642 025046 0 ustar matthias matthias module imports.test67a;
import test67;
class Base
{
I create() {
return null;
}
}
class Derived : Base
{
override SubI create() {
return null;
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/art4769a.d 0000644 0001750 0001750 00000000313 13200164642 025030 0 ustar matthias matthias module imports.art4769a;
import core.stdc.stdio;
template DataStreamability(T)
{
const int isStreamable = true;
alias T footype;
void write()
{
printf("hallo\n");
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test9276decl.d 0000644 0001750 0001750 00000000351 13200164642 025710 0 ustar matthias matthias module imports.test9276decl;
import imports.test9276sem, imports.test9276visitors, imports.test9276util;
class Declaration
{
mixin DownCastMethods!TemplateDecl;
}
class TemplateDecl : OverloadableDecl
{
mixin Visitors;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test72b.d 0000644 0001750 0001750 00000000076 13200164642 025047 0 ustar matthias matthias module imports.test72b;
private import imports.test72c : foo;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/ice13403a.d 0000644 0001750 0001750 00000000121 13200164642 025040 0 ustar matthias matthias module imports.ice13403a;
package(imports):
template BacktrackingMatcher()
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/a13226.d 0000644 0001750 0001750 00000000543 13200164642 024372 0 ustar matthias matthias module imports.a13226;
enum isFunction(alias f) = is(typeof(f) == function);
enum isIntField(alias f) = is(typeof(f) == int);
string t(alias cls, string method)()
{
static if (isFunction!(mixin("cls."~method)))
{}
return "";
}
string u(alias cls, string member)()
{
static if (isIntField!(mixin("cls."~member)))
{}
return "";
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test9276parser.d 0000644 0001750 0001750 00000000133 13200164642 026273 0 ustar matthias matthias module imports.test9276parser;
public import imports.test9276expr, imports.test9276decl;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/ldc_github_662c.d 0000644 0001750 0001750 00000000070 13200164642 026413 0 ustar matthias matthias module imports.ldc_github_662c;
import ldc_github_662;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/imp12242a.d 0000644 0001750 0001750 00000000437 13200164642 025077 0 ustar matthias matthias module imports.imp12242a;
public:
import imports.imp12242a1; // std.string
import imports.imp12242a2; // std.algorithm
private mixin template MixTmp(T, int x)
{
template foo(U) if (is(U == T))
{
enum foo = x;
}
}
mixin MixTmp!(int, 1);
mixin MixTmp!(long, 2);
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test9672a.d 0000644 0001750 0001750 00000000706 13200164642 025225 0 ustar matthias matthias module imports.test9672a; // interpret
import test9672; // node
class Type
{
mixin ForwardCtor!();
}
//BasicType only created for standard types associated with tokens
class BasicType : Type
{
static Type createType()
{
return null;
}
}
class ValueT(T)
{
Type getType()
{
return BasicType.createType();
}
}
class CharValue : ValueT!char
{
string toStr()
{
return null;
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/imp12242b.d 0000644 0001750 0001750 00000000441 13200164642 025073 0 ustar matthias matthias module imports.imp12242b;
public:
import imports.imp12242b1; // std.string
import imports.imp12242b2; // std.algorithm
private mixin template MixTmp(T, int x)
{
template foo(U) if (is(U == T))
{
enum foo = x;
}
}
mixin MixTmp!(float, 3);
mixin MixTmp!(real, 4);
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test14666b.d 0000644 0001750 0001750 00000000127 13200164642 025302 0 ustar matthias matthias module imports.test14666b;
import test14666;
struct Token
{
Location location;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test9919a.d 0000644 0001750 0001750 00000000065 13200164642 025227 0 ustar matthias matthias module imports.test9919a;
import imports.test9919c;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test72c.d 0000644 0001750 0001750 00000000050 13200164642 025040 0 ustar matthias matthias module imports.test72c;
void foo()
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/a12567.d 0000644 0001750 0001750 00000000143 13200164642 024375 0 ustar matthias matthias deprecated("This module will be removed in future release.")
module imports.a12567;
void foo() {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/bug8922.d 0000644 0001750 0001750 00000000030 13200164642 024645 0 ustar matthias matthias module imports.bug8922;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test9276util.d 0000644 0001750 0001750 00000000270 13200164642 025756 0 ustar matthias matthias module imports.test9276util;
string _dgliteral(T...)()
{
foreach (t; T)
return t.stringof;
assert(0);
}
template DownCastMethods(T...)
{
enum x = _dgliteral!T;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test7491a.d 0000644 0001750 0001750 00000000032 13200164642 025212 0 ustar matthias matthias module imports.test7491a;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test9436node.d 0000644 0001750 0001750 00000000127 13200164642 025725 0 ustar matthias matthias module imports.test9436node;
import imports.test9436aggr;
template ForwardCtor()
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test11563std_range.d 0000644 0001750 0001750 00000000315 13200164642 027017 0 ustar matthias matthias module imports.test11563std_range;
public import imports.test11563std_array;
template isInputRange(R)
{
enum bool isInputRange = is(typeof(
{
R r = void;
r.popFront();
}));
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test63a.d 0000644 0001750 0001750 00000000125 13200164642 025041 0 ustar matthias matthias module imports.test63a;
private import test63;
struct s {
char a[ SIZE ];
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test9276sem.d 0000644 0001750 0001750 00000000366 13200164642 025573 0 ustar matthias matthias module imports.test9276sem;
class Declaration
{
mixin Visitors;
}
template Semantic(T)
{
private:
struct
{
import imports.test9276hash;
}
}
import imports.test9276visitors;
class OverloadableDecl : Declaration
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/fwdref12201a.d 0000644 0001750 0001750 00000000020 13200164642 025546 0 ustar matthias matthias alias int FILE;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test59b.d 0000644 0001750 0001750 00000000054 13200164642 025050 0 ustar matthias matthias module imports.test59b;
alias int HRESULT;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/ldc_github_739a.d 0000644 0001750 0001750 00000000076 13200164642 026424 0 ustar matthias matthias module imports.ldc_github_739a;
void array(Range)(Range r) {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/ldc_github_662b.d 0000644 0001750 0001750 00000000452 13200164642 026416 0 ustar matthias matthias module imports.ldc_github_662b;
import imports.ldc_github_662c;
import imports.ldc_github_662d;
import std.range;
class Font {
mixin RCounted;
auto makeTextData(string s) {
// split text by spaces
auto arr = s.splitter.array;
}
}
class Engine {
RC!Font font;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/udamodule2a.d 0000644 0001750 0001750 00000000067 13200164642 025757 0 ustar matthias matthias module imports.udamodule2a;
struct UDA
{
int a;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test9276visitors.d 0000644 0001750 0001750 00000000345 13200164642 026666 0 ustar matthias matthias module imports.test9276visitors;
template Visitors()
{
mixin Semantic!(typeof(this));
mixin DeepDup!(typeof(this));
}
import imports.test9276type;
template DeepDup(T) if (is(T : BasicType))
{}
template DeepDup(T)
{}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/ldc_github_821a.d 0000755 0001750 0001750 00000000055 13200164642 026414 0 ustar matthias matthias module imports.ldc_github_821a;
struct S {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/imp12242b1.d 0000644 0001750 0001750 00000000217 13200164642 025155 0 ustar matthias matthias module imports.imp12242b1;
// std.string.strip
int stripB(C)(C[] str) @safe pure
if (is(immutable C == immutable char))
{
return 1;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test50a.d 0000644 0001750 0001750 00000000101 13200164642 025027 0 ustar matthias matthias module imports.test50a;
class Foo {
protected int a;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/defaa.d 0000644 0001750 0001750 00000000154 13200164642 024612 0 ustar matthias matthias
module imports.defaa;
class Display
{
private import imports.defab;
B lastHittestB;
this() { }
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/udamodule2.d 0000644 0001750 0001750 00000000130 13200164642 025605 0 ustar matthias matthias @UDA(1) @UDA(2) module imports.udamodule2;
import imports.udamodule2a;
void foo()
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/ice11054a.d 0000644 0001750 0001750 00000000511 13200164642 025043 0 ustar matthias matthias template Tuple()
{
string injectNamedFields()
{
formatNthX();
return "";
}
}
Tuple!T tuple(T...)()
{
}
void formatNthX(A...)(A)
{
static gencode(size_t count)()
{
result ~= ""; // comment out this line will remove the ICE
return "";
}
mixin(gencode!(A.length)());
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test71.d 0000644 0001750 0001750 00000000100 13200164642 024670 0 ustar matthias matthias module imports_test71;
import imports = object;
void foo()
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test11563core_bitop.d 0000644 0001750 0001750 00000000034 13200164642 027174 0 ustar matthias matthias module test11563core_bitop;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test9919c.d 0000644 0001750 0001750 00000000107 13200164642 025226 0 ustar matthias matthias module imports.test9919c;
import test9919;
MouseEvent.Action action;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/a12506.d 0000644 0001750 0001750 00000000104 13200164642 024363 0 ustar matthias matthias module imports.a12506;
auto f12506(alias fun)() { return fun(1); }
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/udamodule1.d 0000644 0001750 0001750 00000000140 13200164642 025605 0 ustar matthias matthias @(1) deprecated("This module will be removed.") @(2) module imports.udamodule1;
void foo()
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test61a.d 0000644 0001750 0001750 00000000101 13200164642 025031 0 ustar matthias matthias module imports.test61a;
enum FooA { fooA };
void bar(FooA x) {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/jsonimport1.d 0000644 0001750 0001750 00000000063 13200164642 026036 0 ustar matthias matthias module imports.jsonimport1;
int target1, target2;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/imports/test62a.d 0000644 0001750 0001750 00000000173 13200164642 025043 0 ustar matthias matthias module imports.test62a;
import test62;
struct T()
{
struct Nested
{
S member;
}
}
alias T!() instance;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test9057.d 0000644 0001750 0001750 00000000353 13200164642 023362 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -c -Icompilable/extra-files
struct Bug9057(T)
{
T x;
}
void test9507() {
import imp9057;
Bug9057!(BugInt) xxx;
}
void test9507_2() {
import imp9057_2;
Bug9057!(BugInt) xxx;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ice6538.d 0000644 0001750 0001750 00000001236 13200164642 023145 0 ustar matthias matthias
/**************************************/
// 6538
template allSatisfy(alias F, T...) { enum bool allSatisfy = true; }
template isIntegral(T) { enum bool isIntegral = true; }
void foo(I...)(I sizes)
if (allSatisfy!(isIntegral, sizes)) {}
void test6538a()
{
foo(42, 86);
}
void bar(T1, T2)(T1 t1, T2 t2)
if (allSatisfy!(isIntegral, t1, t2)) {}
void test6538b()
{
bar(42, 86);
}
/**************************************/
// 9361
template Sym(alias A)
{
enum Sym = true;
}
struct S
{
void foo()() if (Sym!(this)) {}
void bar()() { static assert(Sym!(this)); } // OK
}
void test9361a()
{
S s;
s.foo(); // fail
s.bar(); // OK
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ldc_github_1211.d 0000644 0001750 0001750 00000000172 13200164642 024625 0 ustar matthias matthias struct Foo
{
long baz;
}
Foo foo(long x)
{
struct Bar
{
long y;
}
return cast(Foo)Bar(x);
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/diag4596.d 0000644 0001750 0001750 00000000741 13200164642 023313 0 ustar matthias matthias /*
TEST_OUTPUT:
---
compilable/diag4596.d(15): Deprecation: this is not an lvalue
compilable/diag4596.d(16): Deprecation: 1 ? this : this is not an lvalue
compilable/diag4596.d(18): Deprecation: super is not an lvalue
compilable/diag4596.d(19): Deprecation: 1 ? super : super is not an lvalue
---
*/
class NoGo4596
{
void fun()
{
this = new NoGo4596;
(1?this:this) = new NoGo4596;
super = new Object;
(1?super:super) = new Object;
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc10334.d 0000644 0001750 0001750 00000002547 13200164642 023371 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 10334
module ddoc10334;
template Foo10334(T) if (Bar10334!()) {} ///
template Foo10334(T) if (Bar10334!100) {} ///
template Foo10334(T) if (Bar10334!3.14) {} ///
template Foo10334(T) if (Bar10334!"str") {} ///
template Foo10334(T) if (Bar10334!1.4i) {} ///
template Foo10334(T) if (Bar10334!null) {} ///
template Foo10334(T) if (Bar10334!true) {} ///
template Foo10334(T) if (Bar10334!false) {} ///
template Foo10334(T) if (Bar10334!'A') {} ///
template Foo10334(T) if (Bar10334!int) {} ///
template Foo10334(T) if (Bar10334!string) {} ///
template Foo10334(T) if (Bar10334!([1,2,3])) {} ///
template Foo10334(T) if (Bar10334!(Baz10334!())) {} ///
template Foo10334(T) if (Bar10334!(Baz10334!T)) {} ///
template Foo10334(T) if (Bar10334!(Baz10334!100)) {} ///
template Foo10334(T) if (Bar10334!(.foo)) {} ///
template Foo10334(T) if (Bar10334!(const int)) {} ///
template Foo10334(T) if (Bar10334!(shared T)) {} ///
template Test10334(T...) {} ///
mixin Test10334!int a; ///
mixin Test10334!(int,long) b; ///
mixin Test10334!"str" c; ///
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test10312.d 0000644 0001750 0001750 00000000215 13200164642 023421 0 ustar matthias matthias
version(D_SIMD)
{
const __vector(float[4]) si = [1f, 1f, 1f, 1f];
void main()
{
auto arr = si;
return;
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ldc_github_378.d 0000644 0001750 0001750 00000001044 13200164642 024561 0 ustar matthias matthias string find(alias pred)(string haystack) {
for (; !pred(haystack); ) {}
return haystack;
}
bool any(alias pred)() if (is(typeof(find!pred("")))) {
return !find!pred("");
}
struct StaticRegex(Char) {
bool function(BacktrackingMatcher!Char) MatchFn;
}
struct BacktrackingMatcher(Char) {
StaticRegex!Char re;
size_t lastState = 0;
}
auto match(RegEx)(RegEx ) {
return "";
}
auto match(RegEx)(RegEx ) if(is(RegEx == StaticRegex!(typeof({})))) {}
void applyNoRemoveRegex() {
if (any!((a){return !match(a);})()){}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test13226.d 0000644 0001750 0001750 00000001322 13200164642 023430 0 ustar matthias matthias // REQUIRED_ARGS: -o-
// PERMUTE_ARGS: -version=bug
import imports.a13226;
class C
{
// class C member m is not accessible
version(bug) mixin(t!(typeof(this), "f")); else {}
version(bug) mixin(u!(typeof(this), "v")); else {}
void f() {}
int v;
// here is ok
version(bug) {} else mixin(t!(typeof(this), "f"));
version(bug) {} else mixin(u!(typeof(this), "v"));
}
struct S
{
// struct S member m is not accessible
version(bug) mixin(t!(typeof(this), "f")); else {}
version(bug) mixin(u!(typeof(this), "v")); else {}
void f() {}
int v;
// here is ok
version(bug) {} else mixin(t!(typeof(this), "f"));
version(bug) {} else mixin(u!(typeof(this), "v"));
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc9475.d 0000644 0001750 0001750 00000000566 13200164642 023326 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -w -o- -c -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 9475
module ddoc9475;
/// foo
void foo() { }
///
unittest
{
// comment 1
foreach (i; 0 .. 10)
{
// comment 2
documentedFunction();
}
}
/// bar
void bar() { }
///
unittest
{
// bar comment
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ldc_github_662.d 0000644 0001750 0001750 00000000040 13200164642 024550 0 ustar matthias matthias import imports.ldc_github_662b;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc10236b.d 0000644 0001750 0001750 00000002530 13200164642 023524 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -w -o-
/*
TEST_OUTPUT:
---
compilable/ddoc10236b.d(43): Warning: Ddoc: parameter count mismatch
compilable/ddoc10236b.d(55): Warning: Ddoc: function declaration has no parameter 'y'
compilable/ddoc10236b.d(67): Warning: Ddoc: function declaration has no parameter 'y'
compilable/ddoc10236b.d(67): Warning: Ddoc: parameter count mismatch
---
*/
/***********************************
* foo_good does this.
* Params:
* x = is for this
* and not for that
* y = is for that
*/
void foo_good(int x)(int y)
{
}
/***********************************
* foo_good2 does this.
* Params:
* y = is for that
*/
void foo_good2(int x)(int y)
{
}
/***********************************
* foo_count_mismatch does this.
* Params:
* x = is for this
* and not for that
*/
void foo_count_mismatch(int x)(int y) // Warning: Ddoc: parameter count mismatch
{
}
/***********************************
* foo_no_param_y does this.
* Params:
* x = is for this
* and not for that
* y = is for that
*/
void foo_no_param_y(int x)(int z) // Warning: Ddoc: function declaration has no parameter 'y'
{
}
/***********************************
* foo_count_mismatch_no_param_y does this.
* Params:
* x = is for this
* and not for that
* y = is for that
*/
void foo_count_mismatch_no_param_y(int x)()
{
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc11511.d 0000644 0001750 0001750 00000000534 13200164642 023361 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -w -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 11511
module ddoc11511;
/**
Params:
abcd = none1
bcdef = none23
... = doo
*/
void foo(int abcd, int bcdef, ...);
/**
Params:
abcd = none1
bcdef = none23
arr = doo
*/
void foo(int abcd, int bcdef, int[] arr...);
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test9276.d 0000644 0001750 0001750 00000000165 13200164642 023366 0 ustar matthias matthias // REQUIRED_ARGS: compilable/imports/test9276parser.d
// This is a dummy module for compilable test
void main()
{}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test14894.sh 0000755 0001750 0001750 00000000605 13200164642 023641 0 ustar matthias matthias #!/usr/bin/env bash
name=`basename $0 .sh`
dir=${RESULTS_DIR}/compilable
src=compilable/extra-files
$DMD -c -m${MODEL} -of${dir}/${name}a${OBJ} -I${src} ${src}/${name}a.d || exit 1
$DMD -unittest -m${MODEL} -od${dir} -I${src} ${src}/${name}main.d ${dir}/${name}a${OBJ} || exit 1
rm -f ${dir}/{${name}a${OBJ} ${name}main${EXE} ${name}main${OBJ}}
echo Success >${dir}/`basename $0`.out
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test13600.d 0000644 0001750 0001750 00000000244 13200164642 023426 0 ustar matthias matthias // REQUIRED_ARGS: -g
class Retry
{
alias bool delegate ( lazy void ) SuccessDecider;
SuccessDecider success_decide;
void on_retry ( )
{
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/forward1.d 0000644 0001750 0001750 00000000155 13200164642 023603 0 ustar matthias matthias // REQUIRED_ARGS: -g
// 104. fails only with -g
Foofunc f;
alias int Foo;
alias int function(Foo) Foofunc;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/debuginfo.d 0000644 0001750 0001750 00000000270 13200164642 024016 0 ustar matthias matthias // REQUIRED_ARGS: -g
struct Bug7127a {
const(Bug7127a)* self;
}
struct Bug7127b {
void function(const(Bug7127b) self) foo;
}
void main() {
Bug7127a a;
Bug7127b b;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test8959.d 0000644 0001750 0001750 00000003221 13200164642 023371 0 ustar matthias matthias /*
TEST_OUTPUT:
---
U1 = int
U2 = int
V1 = long, K1 = string
V2 = long, K2 = string
TL1 = (int, string)
TL2 = (int, string)
U3 = int
U4 = int
V3 = long, K3 = string
V4 = long, K4 = string
TL3 = (int, string)
TL4 = (int, string)
---
*/
static if (is(int* == U1*, U1)) { pragma(msg, "U1 = ", U1); }
static if (is(int* : U2*, U2)) { pragma(msg, "U2 = ", U2); }
static assert(is(int* == U*, U));
static assert(is(int* : U*, U));
alias AA = long[string];
static if (is(AA == V1[K1], V1, K1)) { pragma(msg, "V1 = ", V1, ", K1 = ", K1); }
static if (is(AA : V2[K2], V2, K2)) { pragma(msg, "V2 = ", V2, ", K2 = ", K2); }
static assert(is(AA == V[K], V, K));
static assert(is(AA : V[K], V, K));
class B(TL...) {}
class C(TL...) : B!TL {}
alias X = C!(int, string);
static if (is(X == C!TL1, TL1...)) { pragma(msg, "TL1 = ", TL1); }
static if (is(X : B!TL2, TL2...)) { pragma(msg, "TL2 = ", TL2); }
static assert(is(X == C!TL, TL...));
static assert(is(X : B!TL, TL...));
void test8959()
{
static if (is(int* == U3*, U3)) { pragma(msg, "U3 = ", U3); }
static if (is(int* : U4*, U4)) { pragma(msg, "U4 = ", U4); }
static assert(is(int* == U*, U));
static assert(is(int* : U*, U));
static if (is(AA == V3[K3], V3, K3)) { pragma(msg, "V3 = ", V3, ", K3 = ", K3); }
static if (is(AA : V4[K4], V4, K4)) { pragma(msg, "V4 = ", V4, ", K4 = ", K4); }
static assert(is(AA == V[K], V, K));
static assert(is(AA : V[K], V, K));
static if (is(X == C!TL3, TL3...)) { pragma(msg, "TL3 = ", TL3); }
static if (is(X : B!TL4, TL4...)) { pragma(msg, "TL4 = ", TL4); }
static assert(is(X == C!TL, TL...));
static assert(is(X : B!TL, TL...));
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ddoc14.d 0000644 0001750 0001750 00000006402 13200164642 023135 0 ustar matthias matthias // PERMUTE_ARGS:
// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -o-
// POST_SCRIPT: compilable/extra-files/ddocAny-postscript.sh 14
alias void V;
alias double* P;
/// -1
struct Structure {
public P variable; /// 0
V mNone(lazy P p) {} /// 1
pure nothrow V mPrefix(lazy P p) {} /// 2
V mSuffix(lazy P p) pure nothrow {} /// 3
// pure nothrow V mPrefixTemplate(T)(lazy P p, T[] t...) {} /// 4
V mSuffixTemplate(T)(lazy P p, T[] t...) pure nothrow {} /// 5
pure nothrow {
V mScoped(lazy P p) {} /// 6
}
pure nothrow auto mAutoPrefix(ref P p) { return p; } /// 7
// pure nothrow auto mAutoTemplatePrefix(alias T)(ref T t) { return p; } /// 8
auto mAutoTemplateSuffix(alias T)(ref T t) pure nothrow { return p; } /// 9
pure nothrow:
V mColon(lazy P p) {} /// 10
}
/// -1
class Class {
public P variable; /// 0
V mNone(lazy P p) {} /// 1
pure nothrow V mPrefix(lazy P p) {} /// 2
V mSuffix(lazy P p) pure nothrow {} /// 3
// pure nothrow V mPrefixTemplate(T)(lazy P p, T[] t...) {} /// 4
V mSuffixTemplate(T)(lazy P p, T[] t...) pure nothrow {} /// 5
pure nothrow {
V mScoped(lazy P p) {} /// 6
}
pure nothrow auto mAutoPrefix(ref P p) { return p; } /// 7
// pure nothrow auto mAutoTemplatePrefix(alias T)(ref T t) { return p; } /// 8
auto mAutoTemplateSuffix(alias T)(ref T t) pure nothrow { return p; } /// 9
pure nothrow:
V mColon(lazy P p) {} /// 10
}
/+
/// -1
struct StructTemplate() {
public P variable; /// 0
V mNone(lazy P p) {} /// 1
pure nothrow V mPrefix(lazy P p) {} /// 2
V mSuffix(lazy P p) pure nothrow {} /// 3
// pure nothrow V mPrefixTemplate(T)(lazy P p, T[] t...) {} /// 4
V mSuffixTemplate(T)(lazy P p, T[] t...) pure nothrow {} /// 5
pure nothrow {
V mScoped(lazy P p) {} /// 6
}
pure nothrow auto mAutoPrefix(ref P p) { return p; } /// 7
// pure nothrow auto mAutoTemplatePrefix(alias T)(ref T t) { return p; } /// 8
auto mAutoTemplateSuffix(alias T)(ref T t) pure nothrow { return p; } /// 9
pure nothrow:
V mColon(lazy P p) {} /// 10
}
/// -1
interface Interface {
V mNone(lazy P p) ; /// 1
pure nothrow V mPrefix(lazy P p) ; /// 2
V mSuffix(lazy P p) pure nothrow ; /// 3
// pure nothrow V mPrefixTemplate(T)(lazy P p, T[] t...) ; /// 4
V mSuffixTemplate(T)(lazy P p, T[] t...) pure nothrow ; /// 5
pure nothrow {
V mScoped(lazy P p) ; /// 6
}
// pure nothrow auto mAutoTemplatePrefix(alias T)(ref T t) { return p; } /// 8
auto mAutoTemplateSuffix(alias T)(ref T t) pure nothrow { return p; } /// 9
pure nothrow:
V mColon(lazy P p) ; /// 10
}
+/
public P variable; /// 0
V mNone(lazy P p) {} /// 1
pure nothrow V mPrefix(lazy P p) {} /// 2
V mSuffix(lazy P p) pure nothrow {} /// 3
// pure nothrow V mPrefixTemplate(T)(lazy P p, T[] t...) {} /// 4
V mSuffixTemplate(T)(lazy P p, T[] t...) pure nothrow {} /// 5
pure nothrow {
V mScoped(lazy P p) {} /// 6
}
pure nothrow auto mAutoPrefix(ref P p) { return p; } /// 7
// pure nothrow auto mAutoTemplatePrefix(alias T)(ref T t) { return p; } /// 8
auto mAutoTemplateSuffix(alias T)(ref T t) pure nothrow { return p; } /// 9
pure nothrow:
V mColon(lazy P p) {} /// 10
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/test10993.d 0000644 0001750 0001750 00000001030 13200164642 023434 0 ustar matthias matthias module test10993;
auto foo(T)(T a)
{
static immutable typeof(a) q;
// pragma(msg, "foo: " ~ typeof(q).mangleof);
return q;
}
struct test(alias fn)
{
bool ini = true;
void* p;
}
auto fun()
{
auto x = foo!()(test!(a=>a)());
// pragma(msg, "fun: " ~ typeof(x).mangleof);
return x;
}
void main()
{
const x = fun();
enum mangle_x = typeof(x).mangleof;
// pragma(msg, "x : " ~ mangle_x);
auto y = cast()x;
enum mangle_y = typeof(y).mangleof;
// pragma(msg, "y : " ~ mangle_y);
static assert (mangle_y == mangle_x[1..$]);
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/ldc_github_965.d 0000644 0001750 0001750 00000000103 13200164642 024556 0 ustar matthias matthias class A{}
void fun() {
A a;
auto b=a?typeid(a):typeid(a);
} ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ 0000755 0001750 0001750 00000000000 13200164642 024133 5 ustar matthias matthias ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc11479.html 0000644 0001750 0001750 00000002647 13200164642 026351 0 ustar matthias matthias
ddoc11479
ddoc11479
- struct S1(T);
- int a;
- int b;
- int c;
- struct S2(T);
- int a;
- int b;
- int c;
- int d;
- struct S3(T);
- int a;
- int b;
- int c;
- int d;
- int e;
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc7656.html 0000644 0001750 0001750 00000001506 13200164642 026264 0 ustar matthias matthias
ddoc7656
ddoc7656
- void main();
int x; // This is a $ comment (and here is some
int y; // more information about that comment)
- int add(int a, int b);
- (Regression check)
Example:
assert(add(1, 1) == 2);
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc8271.html 0000644 0001750 0001750 00000000617 13200164642 026260 0 ustar matthias matthias
ddoc8271
ddoc8271
- void ddoc8271();
- Macro
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc13645.html 0000644 0001750 0001750 00000000511 13200164642 026332 0 ustar matthias matthias
ddoc13645
ddoc13645
Documentation comment on module
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc8.html 0000644 0001750 0001750 00000000603 13200164642 026021 0 ustar matthias matthias
ddoc8
ddoc8
- class Foo(T): Bar;
- foo
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/testheaderudamodule.di 0000644 0001750 0001750 00000000115 13200164642 030476 0 ustar matthias matthias @(1, UDA(2))
module testheaderudamodule;
struct UDA
{
int a;
}
void main();
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc10325.html 0000644 0001750 0001750 00000001020 13200164642 026316 0 ustar matthias matthias
ddoc10325
ddoc10325
- template templ(T...) if (someConstraint!T)
- void foo(T)(T t) if (someConstraint!T);
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc6491.html 0000644 0001750 0001750 00000000717 13200164642 026263 0 ustar matthias matthias
ddoc6491
ddoc6491
- void bug6491a(int a = ddoc6491.c6491, string b = core.cpuid.vendor);
- test
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/header12567b.di 0000644 0001750 0001750 00000000070 13200164642 026445 0 ustar matthias matthias deprecated("message") module header12567b;
void main();
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/pkgDIP37_10354/ 0000755 0001750 0001750 00000000000 13200164642 026157 5 ustar matthias matthias ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/pkgDIP37_10354/mbar.d 0000644 0001750 0001750 00000000055 13200164642 027245 0 ustar matthias matthias module pkgDIP37_10354.mbar;
void bar(T)() {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/pkgDIP37_10354/mfoo.d 0000644 0001750 0001750 00000000055 13200164642 027264 0 ustar matthias matthias module pkgDIP37_10354.mfoo;
void foo(T)() {}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/pkgDIP37_10354/package.d 0000644 0001750 0001750 00000000135 13200164642 027716 0 ustar matthias matthias module pkgDIP37_10354;
public import pkgDIP37_10354.mfoo;
public import pkgDIP37_10354.mbar;
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/header2.di 0000644 0001750 0001750 00000002463 13200164642 025770 0 ustar matthias matthias class C
{
}
void foo(const C c, const(char)[] s, const int* q, const(int*) p);
void bar(in void* p);
void f(void function() f2);
class C2;
void foo2(const C2 c);
struct Foo3
{
int k;
~this();
this(this);
}
class C3
{
@property int get();
}
T foo3(T)()
{
}
struct S4A(T)
{
T x;
}
struct S4B(T) if (1)
{
T x;
}
union U4A(T)
{
T x;
}
union U4B(T) if (2 * 4 == 8)
{
T x;
}
class C4A(T)
{
T x;
}
class C4B(T) if (true)
{
T x;
}
class C4C(T) if (!false) : C4A!int
{
T x;
}
class C4D(T) if (!false) : C4B!long, C4C!(int[])
{
T x;
}
interface I4(T) if ((int[1]).length == 1)
{
T x;
}
template MyClass4(T) if (is(typeof(T.subtype)))
{
alias HelperSymbol = T.subtype;
class MyClass4
{
}
}
enum isInt(T) = is(T == int);
enum bool isString(T) = is(T == string);
static immutable typeName(T) = T.stringof;
int storageFor(T) = 0;
enum int templateVariableFoo(T) = T.stringof.length;
template templateVariableBar(T) if (is(T == int))
{
enum int templateVariableBar = T.stringof.length;
}
auto flit = 3 / 2.00000;
void foo11217()(const int[] arr)
{
}
void foo11217()(immutable int[] arr)
{
}
void foo11217()(ref int[] arr)
{
}
void foo11217()(lazy int[] arr)
{
}
void foo11217()(auto ref int[] arr)
{
}
void foo11217()(scope int[] arr)
{
}
void foo11217()(in int[] arr)
{
}
void foo11217()(inout int[] arr)
{
}
void test13275();
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/depsOutput9948a.d 0000644 0001750 0001750 00000000125 13200164642 027151 0 ustar matthias matthias module depsOutput9948a;
void templateFunc(string myImport)()
{
mixin(myImport);
} ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/header1.d 0000644 0001750 0001750 00000016662 13200164642 025624 0 ustar matthias matthias module foo.bar;
import core.vararg;
import std.stdio;
pragma(lib, "test");
pragma(msg, "Hello World");
static assert(true, "message");
alias double mydbl;
int testmain()
in
{
assert(1+(2+3) == -(1 - 2*3));
}
out (result)
{
assert(result == 0);
}
body
{
float f = float.infinity;
int i = cast(int) f;
writeln((i,1),2);
writeln(cast(int)float.max);
assert(i == cast(int)float.max);
assert(i == 0x80000000);
return 0;
}
struct S { int m, n; }
template Foo(T, int V)
{
void foo(...)
{
static if (is(Object _ : X!TL, alias X, TL...)) {} // Bugzilla 10044
auto x = __traits(hasMember, Object, "noMember");
auto y = is(Object : X!TL, alias X, TL...);
assert(!x && !y, "message");
S s = { 1,2 };
auto a = [1, 2, 3];
auto aa = [1:1, 2:2, 3:3];
int n,m;
}
int bar(double d, int x)
{
if (d)
{ d++;
}
else
d--;
asm
{ naked ;
mov EAX, 3;
}
for (;;)
{
d = d + 1;
}
for (int i = 0; i < 10; i++)
{
d = i ? d + 1 : 5;
}
char[] s;
foreach (char c; s)
{
d *= 2;
if (d)
break;
else
continue;
}
switch (V)
{
case 1:
case 2: break;
case 3: goto case 1;
case 4: goto default;
default:
d /= 8;
break;
}
enum Label { A, B, C };
void fswitch(Label l)
{
final switch (l)
{
case A: break;
case B: break;
case C: break;
}
}
loop:
while (x)
{
x--;
if (x)
break loop;
else
continue loop;
}
do
{
x++;
} while (x < 10);
try
{
bar(1, 2);
}
catch (Object o)
{
x++;
}
finally
{
x--;
}
Object o;
synchronized (o)
{
x = ~x;
}
synchronized
{
x = x < 3;
}
with (o)
{
toString();
}
}
}
static this()
{
}
static ~this()
{
}
pure nothrow @safe @nogc static this() {}
pure nothrow @safe @nogc static ~this() {}
static this() pure nothrow @safe @nogc {}
static ~this() pure nothrow @safe @nogc {}
pure nothrow @safe @nogc shared static this() {}
pure nothrow @safe @nogc shared static ~this() {}
shared static this() pure nothrow @safe @nogc {}
shared static ~this() pure nothrow @safe @nogc {}
interface iFoo{}
class xFoo: iFoo{}
interface iFoo2{}
class xFoo2: iFoo, iFoo2{}
class Foo3
{
this(int a, ...){}
this(int* a){}
}
alias int myint;
static notquit = 1;
class Test
{
void a() {}
void b() {}
void c() {}
void d() {}
void e() {}
void f() {}
void g() {}
void h() {}
void i() {}
void j() {}
void k() {}
void l() {}
void m() {}
void n() {}
void o() {}
void p() {}
void q() {}
void r() {}
void s() {}
void t() {}
void u() {}
void v() {}
void w() {}
void x() {}
void y() {}
void z() {}
void aa() {}
void bb() {}
void cc() {}
void dd() {}
void ee() {} // Try adding or removing some functions here to see the effect.
template A(T) { }
alias A!(uint) getHUint;
alias A!(int) getHInt;
alias A!(float) getHFloat;
alias A!(ulong) getHUlong;
alias A!(long) getHLong;
alias A!(double) getHDouble;
alias A!(byte) getHByte;
alias A!(ubyte) getHUbyte;
alias A!(short) getHShort;
alias A!(ushort) getHUShort;
alias A!(real) getHReal;
alias void F();
pure nothrow @safe @nogc unittest {}
pure nothrow @safe @nogc invariant {}
pure nothrow @safe @nogc new (size_t sz) { return null; }
pure nothrow @safe @nogc delete (void* p) { }
}
template templ( T )
{
void templ( T val )
{
pragma( msg, "Invalid destination type." );
}
}
static char[] charArray = [ '\"', '\'' ];
class Point
{
auto x = 10;
uint y = 20;
}
template Foo2(bool bar)
{
void test()
{
static if(bar)
{
int i;
}
else
{
}
static if(!bar)
{
}
else
{
}
}
}
template Foo4()
{
void bar()
{
}
}
template Foo4x( T... ) {}
class Baz4
{
mixin Foo4 foo;
mixin Foo4x!(int, "str") foox;
alias foo.bar baz;
}
int test(T)(T t)
{
if (auto o = cast(Object)t) return 1;
return 0;
}
enum x6 = 1;
bool foo6(int a, int b, int c, int d)
{
return (a < b) != (c < d);
}
auto foo7(int x)
{
return 5;
}
class D8{}
void func8()
{
scope a= new D8();
}
T func9(T)() if (true)
{
T i;
scope(exit) i= 1;
scope(success) i = 2;
scope(failure) i = 3;
return i;
}
template V10(T)
{
void func()
{
for(int i,j=4; i<3;i++)
{
}
}
}
int foo11(int function() fn)
{
return fn();
}
int bar11(T)()
{
return foo11(function int (){ return 0; });
}
struct S6360
{
@property long weeks1() const pure nothrow { return 0; }
@property const pure nothrow long weeks2() { return 0; }
}
struct S12
{
/// postfix storage class and constructor
this(int n) nothrow{}
/// prefix storage class (==StorageClassDeclaration) and constructor
nothrow this(string s){}
}
/// dummy
struct T12
{
/// postfix storage class and template constructor
this()(int args) immutable { }
/// prefix storage class (==StorageClassDeclaration) and template constructor
immutable this(A...)(A args){ }
}
// 6591
import std.stdio : writeln, F = File;
void foo6591()()
{
import std.stdio : writeln, F = File;
}
// 8081
version(unittest) {
pure nothrow unittest {}
pure nothrow unittest {}
public unittest {}
extern(C) unittest {}
align unittest {}
}
// 10334
template Foo10334(T) if (Bar10334!()) {} ///
template Foo10334(T) if (Bar10334!100) {} ///
template Foo10334(T) if (Bar10334!3.14) {} ///
template Foo10334(T) if (Bar10334!"str") {} ///
template Foo10334(T) if (Bar10334!1.4i) {} ///
template Foo10334(T) if (Bar10334!null) {} ///
template Foo10334(T) if (Bar10334!true) {} ///
template Foo10334(T) if (Bar10334!false) {} ///
template Foo10334(T) if (Bar10334!'A') {} ///
template Foo10334(T) if (Bar10334!int) {} ///
template Foo10334(T) if (Bar10334!string) {} ///
template Foo10334(T) if (Bar10334!wstring) {} ///
template Foo10334(T) if (Bar10334!dstring) {} ///
template Foo10334(T) if (Bar10334!this) {} ///
template Foo10334(T) if (Bar10334!([1,2,3])) {} ///
template Foo10334(T) if (Bar10334!(Baz10334!())) {} ///
template Foo10334(T) if (Bar10334!(Baz10334!T)) {} ///
template Foo10334(T) if (Bar10334!(Baz10334!100)) {} ///
template Foo10334(T) if (Bar10334!(.foo)) {} ///
template Foo10334(T) if (Bar10334!(const int)) {} ///
template Foo10334(T) if (Bar10334!(shared T)) {} ///
template Test10334(T...) {} ///
mixin Test10334!int a; ///
mixin Test10334!(int,long) b; ///
mixin Test10334!"str" c; ///
// 12266
auto clamp12266a(T1, T2, T3)(T1 x, T2 min_val, T3 max_val)
{
return 0;
}
pure clamp12266b(T1, T2, T3)(T1 x, T2 min_val, T3 max_val)
{
return 0;
}
@disable pure clamp12266c(T1, T2, T3)(T1 x, T2 min_val, T3 max_val)
{
return 0;
}
// 13832
alias Dg13832 = ref int delegate();
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc2.html 0000644 0001750 0001750 00000002340 13200164642 026013 0 ustar matthias matthias
std.test
std.test
Summary
Description1
Description2
Description3
See Also:
Things to see also.
And more things.
- class StreamException: object.Exception;
- A base class for stream exceptions.
- this(string msg, int foo);
- Construct a StreamException with given error message msg.
Params:
string msg |
the red blue green yellow. |
int foo |
next parameter which is a much longer
message spanning multiple
lines. |
- int stars;
- stars
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddocunittest.html 0000644 0001750 0001750 00000024225 13200164642 027537 0 ustar matthias matthias
ddocunittest
ddocunittest
- int foo(int a, int b);
- foo function - 1 example
Examples:
assert(foo(1, 1) == 2);
- bool bar();
- bar function - 1 example
Examples:
// documented
assert(bar());
Examples:
placeholder
- void doo();
- doo function - no examples
- int add(int a, int b);
- add function - 3 examples
Examples:
assert(add(1, 1) == 2);
Examples:
// documented
assert(add(3, 3) == 6);
assert(add(4, 4) == 8);
Examples:
// documented
assert(add(5, 5) == 10);
assert(add(6, 6) == 12);
- class Foo;
- class Foo
Examples:
Foo foo = new Foo;
- class SomeClass;
- some class - 1 example
Examples:
SomeClass sc = new SomeClass;
- class Outer;
- Outer - 1 example
Examples:
Outer outer = new Outer;
- class Inner;
- Inner
Examples:
Inner inner = new Inner;
- void foobar();
- foobar - no examples
- void foo(int x);
- func - 4 examples
Examples:
foo(1);
Examples:
foo(2);
Examples:
foo(2);
Examples:
foo(4);
- void fooImport();
- Examples:
test
fooImport();
- void fooStaticImport();
- Examples:
test
fooStaticImport();
- void fooPublicImport();
- Examples:
test
fooPublicImport();
- void fooSelectiveImport();
- Examples:
test
fooSelectiveImport();
- void fooRenamedImport();
- Examples:
test
fooRenamedImport();
- void fooConditionalDecl1a();
- Examples:
int x1a;
- void fooConditionalDecl1b();
- Examples:
int x1b;
- void fooConditionalDecl3a();
- void fooConditionalDecl3b();
- void barConditionalDecl4a();
- Examples:
int x4a;
- void barConditionalDecl4b();
- Examples:
int x4b;
- void barConditionalDecl6a();
- Examples:
int x6a;
- void barConditionalDecl6b();
- Examples:
int x6b;
- void foo9474();
- Examples:
Example
foo9474();
- void bar9474();
- doc
Examples:
Example
bar9474();
- struct S9474;
- Examples:
S9474 s;
- int autovar9474;
- Examples:
int v = autovar9474;
- auto autofun9474();
- Examples:
int n = autofun9474();
- template Template9474()
- Examples:
alias Template9474!() T;
- void foo();
- Shouldn't link following unittest to here
- void fooNoDescription();
- Examples:
fooNoDescription();
Examples:
if (true) {fooNoDescription(); } /* comment */
- void foo9757();
void bar9757();
void baz9757();
- test for bugzilla 9757
Examples:
foo9757(); bar9757();
Examples:
bar9757(); foo9757();
- auto redBlackTree(E)(E[] elems...);
auto redBlackTree(bool allowDuplicates, E)(E[] elems...);
auto redBlackTree(alias less, E)(E[] elems...);
- with template functions
Examples:
auto rbt1 = redBlackTree(0, 1, 5, 7);
auto rbt2 = redBlackTree!string("hello", "world");
auto rbt3 = redBlackTree!true(0, 1, 5, 7, 5);
auto rbt4 = redBlackTree!"a > b"(0, 1, 5, 7);
- void foo();
- test
Examples:
- bool balancedParens10519(string, char, char);
- Examples:
auto s = "1 + (2 * (3 + 1 / 2)";
assert(!balancedParens10519(s, '(', ')'));
- struct S12097;
void f12097();
struct T12097(T);
- declaration
Examples:
ddoc code 1
int a = 1;
Examples:
ddoc code 2
int[] arr;
- void foo();
- method
- void fun14594a()();
- testA
Examples:
fun14594a();
- void fun14594b()();
void fun14594b(T)(T);
- testB
Examples:
fun14594b(); fun14594b(1);
- void fun14594c()();
void fun14594c(T)(T);
- testC
Examples:
fun14594c(); fun14594c(1);
- void fun14594d()();
void fun14594d(T)(T);
- testD
Examples:
fun14594d();
Examples:
fun14594d(1);
- void fun14594e()();
- testE
concatenated doc-comment fun14594e
Examples:
doc-unittest fun14594e
fun14594e();
- void fun14594f()();
void fun14594f(T)(T);
- testF
concatenated doc-comment fun14594f
Examples:
doc-unittest fun14594f
fun14594f();
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc13.html 0000644 0001750 0001750 00000002060 13200164642 026074 0 ustar matthias matthias
ddoc13
ddoc13
- struct Bug4107(T);
- struct doc
- void foo(U)(U u);
- templated function doc
- struct Bug4107b(T);
- alpha
- struct B(U);
- beta
- struct C(V);
- gamma
- struct D(W);
- delta
- B!W e(X)(C!V c, X[] x...);
- epsilon
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc5446.html 0000644 0001750 0001750 00000004313 13200164642 026256 0 ustar matthias matthias
ddoc5446
ddoc5446
- alias This_Foo = ddoc5446a.A_Foo;
- alias This_Foo_Alias = ddoc5446a.A_Foo;
- alias This_Int = int;
- alias This_Enum = ddoc5446a.A_Enum;
- deprecated alias A_Enum_New = ddoc5446b.A_Enum_New;
- struct Bar;
- alias Bar_A_Foo = ddoc5446a.A_Foo;
- alias Bar_A_Foo_Alias = ddoc5446a.A_Foo;
- alias Bar_A_Int = int;
- alias Bar_This_Foo = ddoc5446a.A_Foo;
- alias Bar_This_Foo_Alias = ddoc5446a.A_Foo;
- alias Bar_This_Int = int;
- alias Nested_Alias = Nested;
- alias Fake_Nested = .Nested;
- struct Nested;
- alias Bar_Nested_Bar_Alias = Bar;
- alias Bar_Alias = .Bar;
- struct Bar;
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc9676a.html 0000644 0001750 0001750 00000000626 13200164642 026433 0 ustar matthias matthias
ddoc9676a
ddoc9676a
deprecated void foo();
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc7.html 0000644 0001750 0001750 00000003577 13200164642 026035 0 ustar matthias matthias
ddoc7
ddoc7
- enum E1: int;
- my enum
- A
- element a
- B
- element b
- enum E2: int;
- my enum
- A
- element a
- B
- element b
- enum E3: int;
- my enum
- A
- element a
- B
- element b
- enum E4: int;
- my enum
- A
- element a
- B
- element b
- enum E5: int;
- my enum
- A
- element a
- B
- element b
- void foo();
- Some doc
- alias bar = foo;
- More doc
- abstract class C;
- asdf
- abstract void foo();
- Some doc
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc9497b.ddoc 0000644 0001750 0001750 00000000046 13200164642 026376 0 ustar matthias matthias DDOC_UNDEFINED_MACRO=$(DOLLAR)($1 $+)
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc12706.html 0000644 0001750 0001750 00000000654 13200164642 026337 0 ustar matthias matthias
ddoc12706
ddoc12706
- void test()(string[] args) if (args[$]);
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/test6461/ 0000755 0001750 0001750 00000000000 13200164642 025433 5 ustar matthias matthias ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/test6461/main.d 0000644 0001750 0001750 00000000132 13200164642 026520 0 ustar matthias matthias import a, b;
void main() {
auto t1 = a.fun();
auto t2 = b.fun();
assert(t1 != t2);
} ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/test6461/a.d 0000644 0001750 0001750 00000000106 13200164642 026015 0 ustar matthias matthias module a;
import tmpl;
TypeInfo fun() { return typeid(Tmpl!int()); }
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/test6461/b.d 0000644 0001750 0001750 00000000107 13200164642 026017 0 ustar matthias matthias module b;
import tmpl;
TypeInfo fun() { return typeid(Tmpl!long()); }
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/test6461/tmpl.d 0000644 0001750 0001750 00000000047 13200164642 026555 0 ustar matthias matthias module tmpl;
struct Tmpl(T) {
T a;
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc7715.html 0000644 0001750 0001750 00000001103 13200164642 026251 0 ustar matthias matthias
ddoc7656
ddoc7656
- void foo();
- $1 $2
string s = "$1$2 $ $4";
- void test(string a = ")");
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc9.html 0000644 0001750 0001750 00000001633 13200164642 026026 0 ustar matthias matthias
ddoc9
ddoc9
- template Template(T)
- Template Documentation (OK)
- void Function(T)(T x);
- Function Documentation (Not included at all by DDoc)
- class Class(T);
- Class Documentation (OK)
- struct Struct(T);
- Struct Documentation
- union Union(T);
- Union Documentation
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddocbackticks.html 0000644 0001750 0001750 00000002352 13200164642 027613 0 ustar matthias matthias
ddocbackticks
ddocbackticks
Closely related to std.datetime is core.time
,
and some of the time types used in std.datetime come from there - such as
, , and
.
core.time is publically imported into std.datetime, it isn't necessary
to import it separately.
- void test();
- This should produce
inline code
.
- void test2();
- But `this should NOT be inline'
However, restarting on a new line should be inline again
.
- void foo();
- This
int foo;
should show highlight on foo, but not int.
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc3.ddoc 0000644 0001750 0001750 00000000034 13200164642 025757 0 ustar matthias matthias HELLO = world
UNUSED=unused ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc4.html 0000644 0001750 0001750 00000000441 13200164642 026015 0 ustar matthias matthias
ddoc4
ddoc4
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc9789.html 0000644 0001750 0001750 00000000706 13200164642 026276 0 ustar matthias matthias
ddoc9789
ddoc9789
- struct S;
- alias A = S;
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc11511.html 0000644 0001750 0001750 00000001604 13200164642 026324 0 ustar matthias matthias
ddoc11511
ddoc11511
- void foo(int abcd, int bcdef, ...);
- Params:
int abcd |
none1 |
int bcdef |
none23 |
... |
doo |
- void foo(int abcd, int bcdef, int[] arr...);
- Params:
int abcd |
none1 |
int bcdef |
none23 |
int[] arr |
doo |
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc10869.html 0000644 0001750 0001750 00000001365 13200164642 026347 0 ustar matthias matthias
ddoc10869
ddoc10869
- class C;
- const void c1Foo();
- immutable void i1Foo();
- immutable void c2Foo();
- immutable void i2Foo();
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/test14894a.d 0000644 0001750 0001750 00000000223 13200164642 026027 0 ustar matthias matthias module imports.test14894a;
mixin template Protocol()
{
void onReceive() {}
}
struct Foo
{
mixin Protocol!();
unittest
{
}
}
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc9369.html 0000644 0001750 0001750 00000000741 13200164642 026267 0 ustar matthias matthias
ddoc9369
ddoc9369
- void foo();
- Sample:
a=1;
writeln(AddressOf!a);
Exclamation
QuestionMark
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc6.html 0000644 0001750 0001750 00000000605 13200164642 026021 0 ustar matthias matthias
ddoc6
ddoc6
- struct MyStruct(T);
Page generated by Ddoc.
ldc-0.17.5-src/tests/d2/dmd-testsuite/compilable/extra-files/ddoc9497a.ddoc 0000644 0001750 0001750 00000000056 13200164642 026376 0 ustar matthias matthias DDOC_UNDEFINED_MACRO=