From: Iain Buclaw Date: Sun, 29 Mar 2020 11:27:22 +0000 (+0200) Subject: testsuite: Move C++ tests in gdc.test into own subdirectory. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=afd9da8b8ad01268478fca6db3f63ca4c51b1900;p=gcc.git testsuite: Move C++ tests in gdc.test into own subdirectory. Tests have been moved into runnable_cxx as part of upstream dmd 3e10e2dd2. The extra flags required for tests that mix C++ and D are now limited to only a small subset of tests, rather than applied to all tests across gdc.dg and gdc.test. Reviewed-on: https://github.com/dlang/dmd/pull/10980 gcc/testsuite/ChangeLog: * gdc.test/runnable_cxx/runnable_cxx.exp: New file. * lib/gdc-utils.exp (gdc-do-test): Add case for runnable_cxx. * lib/gdc.exp (gdc_include_flags): Only add flags for libstdc++-v3 if GDC_INCLUDE_CXX_FLAGS is true. (gdc_link_flags): Likewise. (gdc_init): Move setting of default gdc test flags to... (gdc_target_compile): ...here. --- diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index a421448a287..7f0140708c6 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -d1a606599e7c2bea8fda8bf5e3ddceb486ae69ac +3e10e2dd29e583f1d94d84de5e4bd858e0303669 The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cd57ba6f5d3..498c2a9e062 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2020-03-29 Iain Buclaw + + * gdc.test/runnable_cxx/runnable_cxx.exp: New file. + * lib/gdc-utils.exp (gdc-do-test): Add case for runnable_cxx. + * lib/gdc.exp (gdc_include_flags): Only add flags for libstdc++-v3 if + GDC_INCLUDE_CXX_FLAGS is true. + (gdc_link_flags): Likewise. + (gdc_init): Move setting of default gdc test flags to... + (gdc_target_compile): ...here. + 2020-03-29 Iain Buclaw * gdc.test/compilable/compilable.exp: New file. diff --git a/gcc/testsuite/gdc.test/runnable/cabi1.d b/gcc/testsuite/gdc.test/runnable/cabi1.d deleted file mode 100644 index 3a914cd0e57..00000000000 --- a/gcc/testsuite/gdc.test/runnable/cabi1.d +++ /dev/null @@ -1,262 +0,0 @@ - -// EXTRA_CPP_SOURCES: cabi2.cpp - -import core.stdc.stdio; -import core.stdc.config; - -struct Foo1 { char c; } -struct Foo2 { short s; } -struct Foo3 { char c; short s; } -struct Foo4 { int i; } -struct Foo5 { int i, j; } -struct Foo6 { int i, j, k; } -struct S7 { float a, b; } - -extern (C) Foo1 ctest1(); -extern (C) Foo2 ctest2(); -extern (C) Foo3 ctest3(); -extern (C) Foo4 ctest4(); -extern (C) Foo5 ctest5(); -extern (C) Foo6 ctest6(); -extern (C) S7 ctest10(); - -version(Windows) - version = Windows_or_32bit; -else version(X86) - version = Windows_or_32bit; - - -void test1() -{ - Foo1 f1 = ctest1(); - assert(f1.c == 3); - - Foo2 f2 = ctest2(); - assert(f2.s == 0x1234); - - Foo3 f3 = ctest3(); - assert(f3.s == 0x5678); - - Foo4 f4 = ctest4(); - assert(f4.i == 0x12345678); - - Foo5 f5 = ctest5(); - assert(f5.i == 0x12345678); - assert(f5.j == 0x21436587); - -version(Windows_or_32bit) -{ - Foo6 f6 = ctest6(); - assert(f6.i == 0x12345678); - assert(f6.j == 0x21463587); - assert(f6.k == 0x24163857); -} - - S7 s7 = ctest10(); - assert(s7.a == 2.5); - assert(s7.b == 1.5); -} - -/*******************************************/ - -extern (C) -{ - char ctest7(char); - ubyte ctest8(ubyte); - byte ctest9(byte); -} - -void test2() -{ - assert(ctest7('a') == 'b'); - assert(ctest8(7) == 8); - assert(ctest9(3) == 4); -} - -/******************************************/ - -extern (C) -{ - void ctestrir(int x1, int x2, int x3, int x4, int x5, int x6, c_long_double a, int b, c_long_double c); -} - -void test3() -{ - ctestrir(1,2,3,4,5,6, c_long_double(100.0), 67, c_long_double(200.0)); -} - -/******************************************/ - -extern (C) void dtestrir(int x1, int x2, int x3, int x4, int x5, int x6, c_long_double a, int b, c_long_double c) -{ - assert(a == 300.0); - assert(b == 68); - assert(c == 401.0); -} - -extern (C) void test4(); - -/******************************************/ - -struct S11 { ubyte a, b, c; } - -extern (C) S11 ctest11(ubyte x, S11, ubyte y); - -void test11() -{ - version (X86) - { - S11 t; - assert(S11.sizeof == 3); - t.a = 2; - t.b = 3; - t.c = 4; - auto s = ctest11(1, t, 5); - assert(s.a == 2); - assert(s.b == 3); - assert(s.c == 4); - } -} - -/******************************************/ - -struct S12 { char a,d; char b,e; ubyte c; } - -extern (C) S12 ctest12(ubyte x, S12, ubyte y); - -void test12() -{ - version (X86) - { - S12 t; - printf("D sz = %d\n", cast(int)S12.sizeof); -// assert(S12.sizeof == 5); - t.a = 2; - t.b = 3; - t.c = 4; - auto s = ctest12(1, t, 5); - assert(s.a == 2); - assert(s.b == 3); - assert(s.c == 4); - } -} - -/******************************************/ - -struct S13 { ushort a, b, c; } - -extern (C) S13 ctest13(ubyte x, S13, ubyte y); - -void test13() -{ - version (X86) - { - S13 t; - assert(S13.sizeof == 6); - t.a = 2; - t.b = 3; - t.c = 4; - auto s = ctest13(1, t, 5); - assert(s.a == 2); - assert(s.b == 3); - assert(s.c == 4); - } -} - -/******************************************/ - -struct S14 { char a,d,e,f; char b,g; ubyte c; } - -extern (C) S14 ctest14(ubyte x, S14, ubyte y); - -void test14() -{ - version (X86) - { - S14 t; - assert(S14.sizeof == 7); - t.a = 2; - t.b = 3; - t.c = 4; - auto s = ctest14(1, t, 5); - assert(s.a == 2); - assert(s.b == 3); - assert(s.c == 4); - } -} - -/******************************************/ - -struct S15 { char a,d,e,f; char b,g,h,i; ubyte c; } - -extern (C) S15 ctest15(ubyte x, S15, ubyte y); - -void test15() -{ - version (X86) - { - S15 t; - assert(S15.sizeof == 9); - t.a = 2; - t.b = 3; - t.c = 4; - auto s = ctest15(1, t, 5); - assert(s.a == 2); - assert(s.b == 3); - assert(s.c == 4); - } -} - -/******************************************/ - -// see https://issues.dlang.org/show_bug.cgi?id=17277 -struct S16 { - char[5] a; - struct { - char b; - align(1) int c; - } -} - -extern (C) S16 ctest16(ubyte x, S16, ubyte y); - -void test16() -{ - version (X86) // misaligned field - { - S16 t; - assert(S16.sizeof == 10); - assert(S16.alignof == 1); - t.a = "hello"; - t.b = 3; - t.c = 0x11223344; - auto s = ctest16(1, t, 5); - assert(s.a == "hello"); - assert(s.b == 3); - assert(s.c == 0x11223344); - } -} - -/******************************************/ - -int main() -{ - test1(); - test2(); - test3(); -version (Win64) -{ -} -else -{ - test4(); -} - test11(); - test12(); - test13(); - test14(); - test15(); - test16(); - - return 0; -} diff --git a/gcc/testsuite/gdc.test/runnable/cpp_abi_tests.d b/gcc/testsuite/gdc.test/runnable/cpp_abi_tests.d deleted file mode 100644 index 83e1cff10d9..00000000000 --- a/gcc/testsuite/gdc.test/runnable/cpp_abi_tests.d +++ /dev/null @@ -1,157 +0,0 @@ -// EXTRA_CPP_SOURCES: cpp_abi_tests.cpp - -extern(C++) { - -struct S -{ - float a = 1; -} - -bool passthrough(bool value); -byte passthrough(byte value); -ubyte passthrough(ubyte value); -char passthrough(char value); -dchar passthrough(dchar value); -short passthrough(short value); -ushort passthrough(ushort value); -int passthrough(int value); -uint passthrough(uint value); -long passthrough(long value); -ulong passthrough(ulong value); -float passthrough(float value); -double passthrough(double value); -S passthrough(S value); - -bool passthrough_ptr(bool *value); -byte passthrough_ptr(byte *value); -ubyte passthrough_ptr(ubyte *value); -char passthrough_ptr(char *value); -dchar passthrough_ptr(dchar *value); -short passthrough_ptr(short *value); -ushort passthrough_ptr(ushort *value); -int passthrough_ptr(int *value); -uint passthrough_ptr(uint *value); -long passthrough_ptr(long *value); -ulong passthrough_ptr(ulong *value); -float passthrough_ptr(float *value); -double passthrough_ptr(double *value); -S passthrough_ptr(S *value); - -bool passthrough_ref(ref bool value); -byte passthrough_ref(ref byte value); -ubyte passthrough_ref(ref ubyte value); -char passthrough_ref(ref char value); -dchar passthrough_ref(ref dchar value); -short passthrough_ref(ref short value); -ushort passthrough_ref(ref ushort value); -int passthrough_ref(ref int value); -uint passthrough_ref(ref uint value); -long passthrough_ref(ref long value); -ulong passthrough_ref(ref ulong value); -float passthrough_ref(ref float value); -double passthrough_ref(ref double value); -S passthrough_ref(ref S value); -} - -template IsSigned(T) -{ - enum IsSigned = is(T==byte) || - is(T==short) || - is(T==int) || - is(T==long); -} - -template IsUnsigned(T) -{ - enum IsUnsigned = is(T==ubyte) || - is(T==ushort) || - is(T==uint) || - is(T==ulong); -} - -template IsIntegral(T) -{ - enum IsIntegral = IsSigned!T || IsUnsigned!T; -} - -template IsFloatingPoint(T) -{ - enum IsFloatingPoint = is(T==float) || is(T==double) || is(T==real); -} - -template IsBoolean(T) -{ - enum IsBoolean = is(T==bool); -} - -template IsSomeChar(T) -{ - enum IsSomeChar = is(T==char) || is(T==dchar); -} - -void check(T)(T actual, T expected) -{ - assert(actual is expected); -} - -void check(T)(T value) -{ - check(passthrough(value), value); - check(passthrough_ptr(&value), value); - check(passthrough_ref(value), value); -} - -T[] values(T)() -{ - T[] values; - static if(IsBoolean!T) - { - values ~= true; - values ~= false; - } - else static if(IsSomeChar!T) - { - values ~= T.init; - values ~= T('a'); - values ~= T('z'); - } - else - { - values ~= T(0); - values ~= T(1); - static if(IsIntegral!T) - { - static if(IsSigned!T) values ~= T.min; - values ~= T.max; - } - else static if(IsFloatingPoint!T) - { - values ~= T.nan; - values ~= T.min_normal; - values ~= T.max; - } - else - { - assert(0); - } - } - return values; -} - -void main() -{ - foreach(bool val; values!bool()) check(val); - foreach(byte val; values!byte()) check(val); - foreach(ubyte val; values!ubyte()) check(val); - foreach(char val; values!char()) check(val); - foreach(dchar val; values!dchar()) check(val); - foreach(short val; values!short()) check(val); - foreach(ushort val; values!ushort()) check(val); - foreach(int val; values!int()) check(val); - foreach(uint val; values!uint()) check(val); - foreach(long val; values!long()) check(val); - foreach(ulong val; values!ulong()) check(val); - foreach(float val; values!float()) check(val); - foreach(double val; values!double()) check(val); - check(S()); -} diff --git a/gcc/testsuite/gdc.test/runnable/cppa.d b/gcc/testsuite/gdc.test/runnable/cppa.d deleted file mode 100644 index b9b4832991e..00000000000 --- a/gcc/testsuite/gdc.test/runnable/cppa.d +++ /dev/null @@ -1,1282 +0,0 @@ -// PERMUTE_ARGS: -g -// EXTRA_CPP_SOURCES: cppb.cpp - -import core.stdc.stdio; -import core.stdc.stdarg; -import core.stdc.config; - -extern (C++) - int foob(int i, int j, int k); - -class C -{ - extern (C++) int bar(int i, int j, int k) - { - printf("this = %p\n", this); - printf("i = %d\n", i); - printf("j = %d\n", j); - printf("k = %d\n", k); - return 1; - } -} - - -extern (C++) - int foo(int i, int j, int k) -{ - printf("i = %d\n", i); - printf("j = %d\n", j); - printf("k = %d\n", k); - assert(i == 1); - assert(j == 2); - assert(k == 3); - return 1; -} - -void test1() -{ - foo(1, 2, 3); - - auto i = foob(1, 2, 3); - assert(i == 7); - - C c = new C(); - c.bar(4, 5, 6); -} - -/****************************************/ - -extern (C++) interface D -{ - int bar(int i, int j, int k); -} - -extern (C++) D getD(); - -void test2() -{ - D d = getD(); - int i = d.bar(9,10,11); - assert(i == 8); -} - -/****************************************/ - -extern (C++) int callE(E); - -extern (C++) interface E -{ - int bar(int i, int j, int k); -} - -class F : E -{ - extern (C++) int bar(int i, int j, int k) - { - printf("F.bar: i = %d\n", i); - printf("F.bar: j = %d\n", j); - printf("F.bar: k = %d\n", k); - assert(i == 11); - assert(j == 12); - assert(k == 13); - return 8; - } -} - -void test3() -{ - F f = new F(); - int i = callE(f); - assert(i == 8); -} - -/****************************************/ - -extern (C++) void foo4(char* p); - -void test4() -{ - foo4(null); -} - -/****************************************/ - -extern(C++) -{ - struct foo5 { int i; int j; void* p; } - - interface bar5{ - foo5 getFoo(int i); - } - - bar5 newBar(); -} - -void test5() -{ - bar5 b = newBar(); - foo5 f = b.getFoo(4); - printf("f.p = %p, b = %p\n", f.p, cast(void*)b); - assert(f.p == cast(void*)b); -} - - -/****************************************/ - -extern(C++) -{ - struct S6 - { - int i; - double d; - } - - union S6_2 - { - int i; - double d; - } - - enum S6_3 - { - A, B - } - - S6 foo6(); - S6_2 foo6_2(); - S6_3 foo6_3(); -} - -extern (C) int foosize6(); - -void test6() -{ - S6 f = foo6(); - printf("%d %d\n", foosize6(), S6.sizeof); - assert(foosize6() == S6.sizeof); -version (X86) -{ - assert(f.i == 42); - printf("f.d = %g\n", f.d); - assert(f.d == 2.5); - assert(foo6_2().i == 42); - assert(foo6_3() == S6_3.A); -} -} - -/****************************************/ - -extern (C) int foo7(); - -struct S -{ - int i; - long l; -} - -void test7() -{ - printf("%d %d\n", foo7(), S.sizeof); - assert(foo7() == S.sizeof); -} - -/****************************************/ - -extern (C++) void foo8(const(char)*); - -void test8() -{ - char c; - foo8(&c); -} - -/****************************************/ -// 4059 - -struct elem9 { } - -extern(C++) void foobar9(elem9*, elem9*); - -void test9() -{ - elem9 *a; - foobar9(a, a); -} - -/****************************************/ - - -struct A11802; -struct B11802; - -extern(C++) class C11802 -{ - int x; - void fun(A11802*) { x += 2; } - void fun(B11802*) { x *= 2; } -} - -extern(C++) class D11802 : C11802 -{ - override void fun(A11802*) { x += 3; } - override void fun(B11802*) { x *= 3; } -} - -extern(C++) void test11802x(D11802); - -void test11802() -{ - auto x = new D11802(); - x.x = 0; - test11802x(x); - assert(x.x == 9); -} - - -/****************************************/ - -struct S13956 -{ -} - -extern(C++) void func13956(S13956 arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6); - -extern(C++) void check13956(S13956 arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) -{ - assert(arg0 == S13956()); - assert(arg1 == 1); - assert(arg2 == 2); - assert(arg3 == 3); - assert(arg4 == 4); - assert(arg5 == 5); - version (OSX) - { - version (D_LP64) - assert(arg6 == 6); - // fails on OSX 32-bit - } - else - assert(arg6 == 6); -} - -void test13956() -{ - func13956(S13956(), 1, 2, 3, 4, 5, 6); -} - -/****************************************/ -// 5148 - -extern (C++) -{ - void foo10(const(char)*, const(char)*); - void foo10(const int, const int); - void foo10(const char, const char); - void foo10(bool, bool); - - struct MyStructType { } - void foo10(const MyStructType s, const MyStructType t); - - enum MyEnumType { onemember } - void foo10(const MyEnumType s, const MyEnumType t); -} - -void test10() -{ - char* p; - foo10(p, p); - foo10(1,2); - foo10('c','d'); - MyStructType s; - foo10(s,s); - MyEnumType e; - foo10(e,e); -} - -/****************************************/ - -extern (C++, N11.M) { void bar11(); } - -extern (C++, A11.B) { extern (C++, C) { void bar(); }} - -void test11() -{ - bar11(); - A11.B.C.bar(); -} -/****************************************/ - -struct Struct10071 -{ - void *p; - c_long_double r; -} - -extern(C++) size_t offset10071(); -void test10071() -{ - assert(offset10071() == Struct10071.r.offsetof); -} - -/****************************************/ - -char[100] valistbuffer; - -extern(C++) void myvprintfx(const(char)* format, va_list va) -{ - vsprintf(valistbuffer.ptr, format, va); -} -extern(C++) void myvprintf(const(char)*, va_list); -extern(C++) void myprintf(const(char)* format, ...) -{ - va_list ap; - va_start(ap, format); - myvprintf(format, ap); - va_end(ap); -} - -void testvalist() -{ - myprintf("hello %d", 999); - assert(valistbuffer[0..9] == "hello 999"); -} - -/****************************************/ -// 12825 - -extern(C++) class C12825 -{ - uint a = 0x12345678; -} - -void test12825() -{ - auto c = new C12825(); -} - -/****************************************/ - -struct S13955a -{ - float a; - double b; -} - -struct S13955b -{ - double a; - float b; -} - -struct S13955c -{ - float a; - float b; -} - -struct S13955d -{ - double a; - double b; -} - -extern(C++) void check13955(S13955a a, S13955b b, S13955c c, S13955d d) -{ - assert(a.a == 2); - assert(a.b == 4); - assert(b.a == 8); - assert(b.b == 16); - assert(c.a == 32); - assert(c.b == 64); - assert(d.a == 128); - assert(d.b == 256); -} - -extern(C++) void func13955(S13955a a, S13955b b, S13955c c, S13955d d); - -void test13955() -{ - func13955(S13955a(2, 4), S13955b(8, 16), S13955c(32, 64), S13955d(128, 256)); -} - -/****************************************/ - -extern(C++) class C13161 -{ - void dummyfunc(); - long val_5; - uint val_9; -} - -extern(C++) class Test : C13161 -{ - uint val_0; - long val_1; -} - -extern(C++) size_t getoffset13161(); - -extern(C++) class C13161a -{ - void dummyfunc(); - c_long_double val_5; - uint val_9; -} - -extern(C++) class Testa : C13161a -{ - bool val_0; -} - -extern(C++) size_t getoffset13161a(); - -void test13161() -{ - assert(getoffset13161() == Test.val_0.offsetof); - assert(getoffset13161a() == Testa.val_0.offsetof); -} - -/****************************************/ - -version (linux) -{ - extern(C++, __gnu_cxx) - { - struct new_allocator(T) - { - alias size_type = size_t; - static if (is(T : char)) - void deallocate(T*, size_type) { } - else - void deallocate(T*, size_type); - } - } -} - -extern (C++, std) -{ - struct allocator(T) - { - version (linux) - { - alias size_type = size_t; - void deallocate(T* p, size_type sz) - { (cast(__gnu_cxx.new_allocator!T*)&this).deallocate(p, sz); } - } - } - - version (linux) - { - class vector(T, A = allocator!T) - { - final void push_back(ref const T); - } - - struct char_traits(T) - { - } - - // https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html - version (none) - { - extern (C++, __cxx11) - { - struct basic_string(T, C = char_traits!T, A = allocator!T) - { - } - } - } - else - { - struct basic_string(T, C = char_traits!T, A = allocator!T) - { - } - } - - struct basic_istream(T, C = char_traits!T) - { - } - - struct basic_ostream(T, C = char_traits!T) - { - } - - struct basic_iostream(T, C = char_traits!T) - { - } - } - - class exception { } - - // 14956 - extern(C++, N14956) - { - struct S14956 { } - } -} - -extern (C++) -{ - version (linux) - { - void foo14(std.vector!(int) p); - void foo14a(std.basic_string!(char) *p); - void foo14b(std.basic_string!(int) *p); - void foo14c(std.basic_istream!(char) *p); - void foo14d(std.basic_ostream!(char) *p); - void foo14e(std.basic_iostream!(char) *p); - - void foo14f(std.char_traits!char* x, std.basic_string!char* p, std.basic_string!char* q); - } -} - -void test14() -{ - version (linux) - { - std.vector!int p; - foo14(p); - - foo14a(null); - foo14b(null); - foo14c(null); - foo14d(null); - foo14e(null); - foo14f(null, null, null); - } -} - -version (linux) -{ - void test14a(std.allocator!int * pa) - { - pa.deallocate(null, 0); - } - - void gun(std.vector!int pa) - { - int x = 42; - pa.push_back(x); - } -} - -void test13289() -{ - assert(f13289_cpp_wchar_t('a') == 'A'); - assert(f13289_cpp_wchar_t('B') == 'B'); - assert(f13289_d_wchar('c') == 'C'); - assert(f13289_d_wchar('D') == 'D'); - assert(f13289_d_dchar('e') == 'E'); - assert(f13289_d_dchar('F') == 'F'); - assert(f13289_cpp_test()); -} - -extern(C++) -{ - bool f13289_cpp_test(); - - version(Posix) - { - dchar f13289_cpp_wchar_t(dchar); - } - else version(Windows) - { - wchar f13289_cpp_wchar_t(wchar); - } - - wchar f13289_d_wchar(wchar ch) - { - if (ch <= 'z' && ch >= 'a') - { - return cast(wchar)(ch - ('a' - 'A')); - } - else - { - return ch; - } - } - dchar f13289_d_dchar(dchar ch) - { - if (ch <= 'z' && ch >= 'a') - { - return ch - ('a' - 'A'); - } - else - { - return ch; - } - } -} - -/****************************************/ - -version (CRuntime_Microsoft) -{ - enum __c_long_double : double; - alias __c_long_double myld; -} -else - alias c_long_double myld; - -extern (C++) myld testld(myld); -extern (C++) myld testldld(myld, myld); - - -void test15() -{ - myld ld = 5.0; - ld = testld(ld); - assert(ld == 6.0); - - myld ld2 = 5.0; - ld2 = testldld(ld2, ld2); - assert(ld2 == 6.0); -} - -/****************************************/ - -version( Windows ) -{ - alias int x_long; - alias uint x_ulong; -} -else -{ - static if( (void*).sizeof > int.sizeof ) - { - alias long x_long; - alias ulong x_ulong; - } - else - { - alias int x_long; - alias uint x_ulong; - } -} - -enum __c_long : x_long; -enum __c_ulong : x_ulong; -alias __c_long mylong; -alias __c_ulong myulong; - -extern (C++) mylong testl(mylong); -extern (C++) myulong testul(myulong); - - -void test16() -{ - { - mylong ld = 5; - ld = testl(ld); - assert(ld == 5 + mylong.sizeof); - } - { - myulong ld = 5; - ld = testul(ld); - assert(ld == 5 + myulong.sizeof); - } - - static if (__c_long.sizeof == long.sizeof) - { - static assert(__c_long.max == long.max); - static assert(__c_long.min == long.min); - static assert(__c_long.init == long.init); - static assert(__c_ulong.max == ulong.max); - static assert(__c_ulong.min == ulong.min); - static assert(__c_ulong.init == ulong.init); - __c_long cl = 0; - cl = cl + 1; - long l = cl; - cl = l; - __c_ulong cul = 0; - cul = cul + 1; - ulong ul = cul; - cul = ul; - } - else static if (__c_long.sizeof == int.sizeof) - { - static assert(__c_long.max == int.max); - static assert(__c_long.min == int.min); - static assert(__c_long.init == int.init); - static assert(__c_ulong.max == uint.max); - static assert(__c_ulong.min == uint.min); - static assert(__c_ulong.init == uint.init); - __c_long cl = 0; - cl = cl + 1; - int i = cl; - cl = i; - __c_ulong cul = 0; - cul = cul + 1; - uint u = cul; - cul = u; - } - else - static assert(0); -} - -/****************************************/ - -struct S13707 -{ - void* a; - void* b; - this(void* a, void* b) - { - this.a = a; - this.b = b; - } -} - -extern(C++) S13707 func13707(); - -void test13707() -{ - auto p = func13707(); - assert(p.a == null); - assert(p.b == null); -} - -/****************************************/ - -struct S13932(int x) -{ - int member; -} - -extern(C++) void func13932(S13932!(-1) s); - -/****************************************/ - -extern(C++, N13337.M13337) -{ - struct S13337{} - void foo13337(S13337 s); -} - -/****************************************/ -// 14195 - -struct Delegate1(T) {} -struct Delegate2(T1, T2) {} - -template Signature(T) -{ - alias Signature = typeof(*(T.init)); -} - -extern(C++) -{ - alias del1_t = Delegate1!(Signature!(void function())); - alias del2_t = Delegate2!(Signature!(int function(float, double)), Signature!(int function(float, double))); - void test14195a(del1_t); - void test14195b(del2_t); -} - -void test14195() -{ - test14195a(del1_t()); - test14195b(del2_t()); -} - - -/****************************************/ -// 14200 - -template Tuple14200(T...) -{ - alias Tuple14200 = T; -} - -extern(C++) void test14200a(Tuple14200!(int)); -extern(C++) void test14200b(float, Tuple14200!(int, double)); - -void test14200() -{ - test14200a(1); - test14200b(1.0f, 1, 1.0); -} - -/****************************************/ -// 14956 - -extern(C++) void test14956(S14956 s); - -/****************************************/ -// check order of overloads in vtable - -extern (C++) class Statement {} -extern (C++) class ErrorStatement {} -extern (C++) class PeelStatement {} -extern (C++) class ExpStatement {} -extern (C++) class DtorExpStatement {} - -extern (C++) class Visitor -{ -public: - int visit(Statement) { return 1; } - int visit(ErrorStatement) { return 2; } - int visit(PeelStatement) { return 3; } -} - -extern (C++) class Visitor2 : Visitor -{ - int visit2(ExpStatement) { return 4; } - int visit2(DtorExpStatement) { return 5; } -} - -extern(C++) bool testVtableCpp(Visitor2 sv); -extern(C++) Visitor2 getVisitor2(); - -bool testVtableD(Visitor2 sv) -{ - Statement s1; - ErrorStatement s2; - PeelStatement s3; - ExpStatement s4; - DtorExpStatement s5; - - if (sv.visit(s1) != 1) return false; - if (sv.visit(s2) != 2) return false; - if (sv.visit(s3) != 3) return false; - if (sv.visit2(s4) != 4) return false; - if (sv.visit2(s5) != 5) return false; - return true; -} - -void testVtable() -{ - Visitor2 dinst = new Visitor2; - if (!testVtableCpp(dinst)) - assert(0); - - Visitor2 cppinst = getVisitor2(); - if (!testVtableD(cppinst)) - assert(0); -} - -/****************************************/ -/* problems detected by fuzzer */ -extern(C++) void fuzz1_cppvararg(long arg10, long arg11, bool arg12); -extern(C++) void fuzz1_dvararg(long arg10, long arg11, bool arg12) -{ - fuzz1_checkValues(arg10, arg11, arg12); -} - -extern(C++) void fuzz1_checkValues(long arg10, long arg11, bool arg12) -{ - assert(arg10 == 103); - assert(arg11 == 104); - assert(arg12 == false); -} - -void fuzz1() -{ - long arg10 = 103; - long arg11 = 104; - bool arg12 = false; - fuzz1_dvararg(arg10, arg11, arg12); - fuzz1_cppvararg(arg10, arg11, arg12); -} - -//////// -extern(C++) void fuzz2_cppvararg(ulong arg10, ulong arg11, bool arg12); -extern(C++) void fuzz2_dvararg(ulong arg10, ulong arg11, bool arg12) -{ - fuzz2_checkValues(arg10, arg11, arg12); -} - -extern(C++) void fuzz2_checkValues(ulong arg10, ulong arg11, bool arg12) -{ - assert(arg10 == 103); - assert(arg11 == 104); - assert(arg12 == false); -} - -void fuzz2() -{ - ulong arg10 = 103; - ulong arg11 = 104; - bool arg12 = false; - fuzz2_dvararg(arg10, arg11, arg12); - fuzz2_cppvararg(arg10, arg11, arg12); -} - -//////// -extern(C++) void fuzz3_cppvararg(wchar arg10, wchar arg11, bool arg12); -extern(C++) void fuzz3_dvararg(wchar arg10, wchar arg11, bool arg12) -{ - fuzz2_checkValues(arg10, arg11, arg12); -} - -extern(C++) void fuzz3_checkValues(wchar arg10, wchar arg11, bool arg12) -{ - assert(arg10 == 103); - assert(arg11 == 104); - assert(arg12 == false); -} - -void fuzz3() -{ - wchar arg10 = 103; - wchar arg11 = 104; - bool arg12 = false; - fuzz3_dvararg(arg10, arg11, arg12); - fuzz3_cppvararg(arg10, arg11, arg12); -} - -void fuzz() -{ - fuzz1(); - fuzz2(); - fuzz3(); -} - -/****************************************/ - -extern (C++) -{ - void throwit(); -} - -void testeh() -{ - printf("testeh()\n"); - version (linux) - { - version (X86_64) - { - bool caught; - try - { - throwit(); - } - catch (std.exception e) - { - caught = true; - } - assert(caught); - } - } -} - -/****************************************/ - -version (linux) -{ - version (X86_64) - { - bool raii_works = false; - struct RAIITest - { - ~this() - { - raii_works = true; - } - } - - void dFunction() - { - RAIITest rt; - throwit(); - } - - void testeh2() - { - printf("testeh2()\n"); - try - { - dFunction(); - } - catch(std.exception e) - { - assert(raii_works); - } - } - } - else - void testeh2() { } -} -else - void testeh2() { } - -/****************************************/ - -extern (C++) { void throwle(); void throwpe(); } - -void testeh3() -{ - printf("testeh3()\n"); - version (linux) - { - version (X86_64) - { - bool caught = false; - try - { - throwle(); - } - catch (std.exception e) //polymorphism test. - { - caught = true; - } - assert(caught); - } - } -} - -/****************************************/ -// 15576 - -extern (C++, ns15576) -{ - extern __gshared int global15576; - - extern (C++, ns) - { - extern __gshared int n_global15576; - } -} - -void test15576() -{ - global15576 = n_global15576 = 123; -} - -/****************************************/ -// 15579 - -extern (C++) -{ - class Base - { - //~this() {} - void based() { } - ubyte x = 4; - } - - interface Interface - { - int MethodCPP(); - int MethodD(); - } - - class Derived : Base, Interface - { - short y = 5; - int MethodCPP(); - int MethodD() { - printf("Derived.MethodD(): this = %p, x = %d, y = %d\n", this, x, y); - Derived p = this; - //p = cast(Derived)(cast(void*)p - 16); - assert(p.x == 4 || p.x == 7); - assert(p.y == 5 || p.y == 8); - return 3; - } - int Method() { return 6; } - } - - Derived cppfoo(Derived); - Interface cppfooi(Interface); -} - -void test15579() -{ - Derived d = new Derived(); - printf("d = %p\n", d); - assert(d.x == 4); - assert(d.y == 5); - assert((cast(Interface)d).MethodCPP() == 30); - assert((cast(Interface)d).MethodD() == 3); - assert(d.MethodCPP() == 30); - assert(d.MethodD() == 3); - assert(d.Method() == 6); - - d = cppfoo(d); - assert(d.x == 7); - assert(d.y == 8); - - printf("d2 = %p\n", d); - - /* Casting to an interface involves thunks in the vtbl[]. - * g++ puts the thunks for MethodD in the same COMDAT as MethodD. - * But D doesn't, so when the linker "picks one" of the D generated MethodD - * or the g++ generated MethodD, it may wind up with a messed up thunk, - * resulting in a seg fault. The solution is to not expect objects of the same - * type to be constructed on both sides of the D/C++ divide if the same member - * function (in this case, MethodD) is also defined on both sides. - */ - version (Windows) - { - assert((cast(Interface)d).MethodD() == 3); - } - assert((cast(Interface)d).MethodCPP() == 30); - - assert(d.Method() == 6); - - printf("d = %p, i = %p\n", d, cast(Interface)d); - version (Windows) - { - Interface i = cppfooi(d); - printf("i2: %p\n", i); - assert(i.MethodD() == 3); - assert(i.MethodCPP() == 30); - } - printf("test15579() done\n"); -} - -/****************************************/ -// 15610 - -extern(C++) class Base2 -{ - int i; - void baser() { } -} - -extern(C++) interface Interface2 { abstract void f(); } - -extern(C++) class Derived2 : Base2, Interface2 -{ - final - override void f(); -} - - -void test15610() -{ - auto c = new Derived2(); - printf("test15610(): c = %p\n", c); - c.i = 3; - c.f(); -} - -/******************************************/ -// 15455 - -struct X6 -{ - ushort a; - ushort b; - ubyte c; - ubyte d; -} - -static assert(X6.sizeof == 6); - -struct X8 -{ - ushort a; - X6 b; -} - -static assert(X8.sizeof == 8); - -void test15455a(X8 s) -{ - assert(s.a == 1); - assert(s.b.a == 2); - assert(s.b.b == 3); - assert(s.b.c == 4); - assert(s.b.d == 5); -} - -extern (C++) void test15455b(X8 s); - -void test15455() -{ - X8 s; - - s.a = 1; - s.b.a = 2; - s.b.b = 3; - s.b.c = 4; - s.b.d = 5; - test15455a(s); - test15455b(s); -} - -/****************************************/ -// 15372 - -extern(C++) int foo15372(T)(T v); - -void test15372() -{ - version(Windows){} - else - assert(foo15372!int(1) == 1); -} - -/****************************************/ -// 15802 - -extern(C++) { - template Foo15802(T) { - static int boo(T v); - } -} - -void test15802() -{ - version(Windows){} - else - assert(Foo15802!(int).boo(1) == 1); -} - -/****************************************/ -// 16536 - mangling mismatch on OSX - -version(OSX) extern(C++) ulong pass16536(ulong); - -void test16536() -{ - version(OSX) assert(pass16536(123) == 123); -} - -/****************************************/ - -void main() -{ - test1(); - test2(); - test3(); - test4(); - test13956(); - test5(); - test6(); - test10071(); - test7(); - test8(); - test11802(); - test9(); - test10(); - test13955(); - test11(); - testvalist(); - test12825(); - test13161(); - test14(); - test13289(); - test15(); - test16(); - func13707(); - func13932(S13932!(-1)(0)); - foo13337(S13337()); - test14195(); - test14200(); - test14956(S14956()); - testVtable(); - fuzz(); - testeh(); - testeh2(); - testeh3(); - test15576(); - test15579(); - test15610(); - test15455(); - test15372(); - test15802(); - test16536(); - - printf("Success\n"); -} diff --git a/gcc/testsuite/gdc.test/runnable/externmangle.d b/gcc/testsuite/gdc.test/runnable/externmangle.d deleted file mode 100644 index 9099f94f2d0..00000000000 --- a/gcc/testsuite/gdc.test/runnable/externmangle.d +++ /dev/null @@ -1,314 +0,0 @@ -// EXTRA_CPP_SOURCES: externmangle.cpp - -extern(C++): - -struct Foo(X) -{ - X* v; -} - - -struct Boo(X) -{ - X* v; -} - - -void test1(Foo!int arg1); -void test2(int* arg2, Boo!(int*) arg1); - - -struct Test3(int X, int Y) -{ -} - -void test3(Test3!(3,3) arg1); - -void test4(Foo!(int*) arg1, Boo!(int*) arg2, Boo!(int*) arg3, int*, Foo!(double)); - -void test5(Foo!(int*) arg1, Boo!(int*) arg2, Boo!(int*) arg3); - - -struct Goo -{ - struct Foo(X) - { - X* v; - } - - struct Boo(X) - { - struct Xoo(Y) - { - Y* v; - }; - X* v; - } - - - void test6(Foo!(Boo!(Foo!(void))) arg1); - void test7(Boo!(void).Xoo!(int) arg1); -} - -struct P1 -{ - struct Mem(T) - { - } -} - -struct P2 -{ - struct Mem(T) - { - } -} - -void test8(P1.Mem!int, P2.Mem!int); -void test9(Foo!(int**), Foo!(int*), int**, int*); - - -interface Test10 -{ - private final void test10(); - public final void test11(); - protected final void test12(); - public final void test13() const; - - private void test14(); - public void test15(); - protected void test16(); - - private static void test17(); - public static void test18(); - protected static void test19(); -}; - -Test10 Test10Ctor(); -void Test10Dtor(ref Test10 ptr); - -struct Test20 -{ - __gshared: - private extern int test20; - protected extern int test21; - public extern int test22; -}; - - -int test23(Test10*, Test10, Test10**, const(Test10)); -int test23b(const Test10*, const Test10, Test10); - -void test24(int function(int,int)); - -void test25(int[291][6][5]* arr); -int test26(int[291][6]* arr); - -void test27(int, ...); -void test28(int); - -void test29(float); -void test30(const float); - -struct Array(T) -{ - int dim; -} - - -interface Module -{ - public static void imports(Module); - public static int dim(Array!Module*); -}; - -ulong testlongmangle(int a, uint b, long c, ulong d); - -__gshared extern int[2][2][2] test31; -__gshared extern int* test32; - - -alias int function(Expression , void* ) apply_fp_t; - -interface Expression -{ - public final int apply(apply_fp_t fp, apply_fp_t fp2, void* param); - public final int getType(); - public static Expression create(int); - public static void dispose(ref Expression); -} - -//int test34(int[0][0]*); -version(CRuntime_Microsoft){} -else -{ - int test35(real arg); -} - -const(char)* test36(const(char)*); - -final class Test37 -{ - static Test37 create() - { - return new Test37; - } - - bool test() - { - return true; - } -} - -bool test37(); - -interface Test38 -{ - final int test(int, ...); - public static Test38 create(); - public static void dispose(ref Test38); -} - -extern(C++) int test39cpp(C2!char, S2!(int)*); - -extern(C++, class) -struct S1 -{ - private int val; - static S1* init(int); - int value(); -} - -extern(C++, class) -struct S2(T) -{ - private T val; - static S2!T* init(int); - T value(); -} - -extern(C++, struct) -class C1 -{ - const(char)* data; - - static C1 init(const(char)* p); - const(char)* getDataCPP(); - extern(C++) const(char)* getDataD() - { - return data; - } -} - -extern(C++, struct) -class C2(T) -{ - const(T)* data; - - static C2!T init(const(T)* p); - const(T)* getData(); -} - -void test39() -{ - S1* s1 = S1.init(42); - assert(s1.value == 42); - assert(S2!int.init(43).value == 43); - const(char)* ptr = "test".ptr; - C1 c1 = C1.init(ptr); - assert(c1.getDataCPP() == ptr); - assert(c1.getDataD() == ptr); - C2!char c2 = C2!char.init(ptr); - assert(c2.getData() == ptr); - auto result = test39cpp(c2, S2!int.init(43)); - assert(result == 0); -} - - -void main() -{ - test1(Foo!int()); - test2(null, Boo!(int*)()); - test3(Test3!(3,3)()); - test4(Foo!(int*)(), Boo!(int*)(), Boo!(int*)(), null, Foo!(double)()); - test5(Foo!(int*)(), Boo!(int*)(), Boo!(int*)()); - Goo goo; - goo.test6(Goo.Foo!(Goo.Boo!(Goo.Foo!(void)))()); - goo.test7(Goo.Boo!(void).Xoo!(int)()); - - test8(P1.Mem!int(), P2.Mem!int()); - test9(Foo!(int**)(), Foo!(int*)(), null, null); - - auto t10 = Test10Ctor(); - scope(exit) Test10Dtor(t10); - - t10.test10(); - t10.test11(); - t10.test12(); - t10.test13(); - t10.test14(); - t10.test15(); - t10.test16(); - t10.test17(); - t10.test18(); - t10.test19(); - - assert(Test20.test20 == 20); - assert(Test20.test21 == 21); - assert(Test20.test22 == 22); - - assert(test23(null, null, null, null) == 1); - assert(test23b(null, null, null) == 1); - - extern(C++) static int cb(int a, int b){return a+b;} - - test24(&cb); - int[291][6][5] arr; - arr[1][1][1] = 42; - test25(&arr); - assert(test26(&arr[0]) == 42); - - test27(3,4,5); - test28(3); - - test29(3.14f); - test30(3.14f); - - auto t32 = &Module.imports; - Array!Module arr2; - arr2.dim = 20; - assert(Module.dim(&arr2) == 20); - - assert(testlongmangle(1, 2, 3, 4) == 10); - assert(test31 == [[[1, 1], [1, 1]], [[1, 1], [1, 1]]]); - assert(test32 == null); - - auto ee = Expression.create(42); - extern(C++) static int efun(Expression e, void* p) - { - return cast(int)(cast(size_t)p ^ e.getType()); - } - - extern(C++) static int efun2(Expression e, void* p) - { - return cast(int)(cast(size_t)p * e.getType()); - } - - auto test33 = ee.apply(&efun, &efun2, cast(void*)&Expression.create); - assert(test33 == cast(int)(cast(size_t)cast(void*)&Expression.create ^ 42) * cast(int)(cast(size_t)cast(void*)&Expression.create * 42)); - Expression.dispose(ee); - assert(ee is null); - //assert(test34(null) == 0); - version(CRuntime_Microsoft){} - else - { - assert(test35(3.14L) == 3); - } - const char* hello = "hello"; - assert(test36(hello) == hello); - assert(test37()); - auto t38 = Test38.create(); - assert(t38.test(1, 2, 3) == 1); - Test38.dispose(t38); - test39(); -} diff --git a/gcc/testsuite/gdc.test/runnable/externmangle2.d b/gcc/testsuite/gdc.test/runnable/externmangle2.d deleted file mode 100644 index 74beb2581f0..00000000000 --- a/gcc/testsuite/gdc.test/runnable/externmangle2.d +++ /dev/null @@ -1,164 +0,0 @@ -// EXTRA_CPP_SOURCES: externmangle2.cpp - -version(Windows) -{ - void main() - { - } -} -else -{ - extern(C++): - - struct Test32NS1 - { - struct Foo(X) - { - X *v; - } - - - struct Bar(X) - { - X *v; - } - - }; - - struct Test32NS2 - { - struct Foo(X) - { - X *v; - } - }; - - struct Test32(alias Y, alias Z) - { - Y!(int)* field; - }; - - - void test32a(Test32!(Test32NS1.Foo, Test32NS1.Foo) arg); - void test32b(Test32!(Test32NS1.Foo, Test32NS1.Bar) arg); - void test32c(Test32!(Test32NS1.Foo, Test32NS2.Foo) arg); - void test32d(Test32!(Test32NS1.Foo, Test32NS2.Foo) arg1, Test32!(Test32NS2.Foo, Test32NS1.Foo) arg2); - - interface XXX - { - } - - void test33a(XXX, XXX*); - - - struct Test33(alias A, alias B) - { - } - - /* - void test33(XXX, Test33!(test33a, test33a) arg, XXX); - - - struct Test34(alias A) - { - }; - - struct Test34A - { - static void foo(int); - }; - - - void test34(Test34!(Test34A.foo) arg); - */ - - __gshared extern int test36; - - /* - struct Test37(alias A) - { - }; - - struct Test37A - { - __gshared extern int t38; - }; - - void test37(Test37!(test36) arg); - void test38(Test37!(Test37A.t38) arg); - */ - - struct Test39 - { - struct T39A(X) - { - } - } - - struct T39A - { - } - - void test39(Test39.T39A!(.T39A)); - - version(none) - { - version(Posix) //Only for g++ with -std=c++0x and Visual Studio 2013+ - { - - struct Test40(T, V...) - { - - } - - void test40(Test40!(int, double, void)) - { - } - } - else version(Win64) //Only for g++ with -std=c++0x and Visual Studio 2013+ - { - - struct Test40(T, V...) - { - - } - - void test40(Test40!(int, double, void)) - { - } - } - } - - - __gshared extern const XXX test41; - struct Test42 - { - __gshared extern const XXX test42; - } - __gshared extern int[4] test43; - const(XXX) test44(); - - void main() - { - test32a(Test32!(Test32NS1.Foo, Test32NS1.Foo)()); - test32b(Test32!(Test32NS1.Foo, Test32NS1.Bar)()); - test32c(Test32!(Test32NS1.Foo, Test32NS2.Foo)()); - test32d(Test32!(Test32NS1.Foo, Test32NS2.Foo)(), Test32!(Test32NS2.Foo, Test32NS1.Foo)()); - - //test33a(null, null); - //test33(null, Test33!(test33a, test33a)(), null); - - //test34(Test34!(Test34A.foo)()); - - assert(test36 == 36); - - //test37(Test37!(test36)()); - //test38(Test37!(Test37A.t38)()); - test39(Test39.T39A!(.T39A)()); - - assert(test41 is null); - assert(Test42.test42 is null); - assert(test43 == [1, 2, 3, 4]); - auto ptr = &test44; - } -} diff --git a/gcc/testsuite/gdc.test/runnable/extra-files/cabi2.cpp b/gcc/testsuite/gdc.test/runnable/extra-files/cabi2.cpp deleted file mode 100644 index 31e5286cbc4..00000000000 --- a/gcc/testsuite/gdc.test/runnable/extra-files/cabi2.cpp +++ /dev/null @@ -1,255 +0,0 @@ - -#include -#include -#include - -#if __cplusplus -extern "C" { -#endif - -struct Foo1 { char c; }; - -struct Foo1 ctest1() -{ - struct Foo1 f; - - f.c = 3; - return f; -} - -struct Foo2 { short s; }; - -struct Foo2 ctest2() -{ - struct Foo2 f; - - f.s = 0x1234; - return f; -} - -struct Foo3 { char c; short s; }; - -struct Foo3 ctest3() -{ - struct Foo3 f; - - f.s = 0x5678; - return f; -} - - -struct Foo4 { int i; }; - -struct Foo4 ctest4() -{ - struct Foo4 f; - - f.i = 0x12345678; - return f; -} - -struct Foo5 { int i, j; }; - -struct Foo5 ctest5() -{ - struct Foo5 f; - - f.i = 0x12345678; - f.j = 0x21436587; - return f; -} - - -struct Foo6 { int i, j, k; }; - -struct Foo6 ctest6() -{ - struct Foo6 f; - - f.i = 0x12345678; - f.j = 0x21463587; - f.k = 0x24163857; - return f; -} - -struct S7 { float a,b; }; - -struct S7 ctest10() -{ - struct S7 f; - - f.a = 2.5; - f.b = 1.5; - return f; -} - -// ================================= - -char ctest7(char c) -{ - return c + 1; -} - -unsigned char ctest8(unsigned char c) -{ - return c + 1; -} - -signed char ctest9(signed char c) -{ - return c + 1; -} - -/***********************************************/ - -void ctestrir(int x1, int x2, int x3, int x4, int x5, int x6, long double a, int b, long double c) -{ - assert(a == 100.0); - assert(b == 67); - assert(c == 200.0); -} - -/***********************************************/ - -extern void dtestrir(int x1, int x2, int x3, int x4, int x5, int x6, long double a, int b, long double c); - -void test4() -{ - dtestrir(1,2,3,4,5,6, 300.0, 68, 401.0); -} - -/**********************************************/ - -typedef struct S11 { - char a; - char b; - char c; -} S11; - -S11 ctest11(char x, S11 s, char y) { - printf("C sz = %d\n", (int)sizeof(S11)); - assert(sizeof(S11) == 3); - printf("x = %d\n", (int)x); - printf("s.a = %d\n", (int)s.a); - printf("s.b = %d\n", (int)s.b); - printf("s.c = %d\n", (int)s.c); - printf("y = %d\n", (int)y); - return s; -} - -/**********************************************/ - -typedef struct S12 { - char a,d; - char b,e; - char c; -} S12; - -S12 ctest12(char x, S12 s, char y) { - printf("C sz = %d\n", (int)sizeof(S12)); - assert(sizeof(S12) == 5); - printf("x = %d\n", (int)x); - printf("s.a = %d\n", (int)s.a); - printf("s.b = %d\n", (int)s.b); - printf("s.c = %d\n", (int)s.c); - printf("y = %d\n", (int)y); - return s; -} - - -/**********************************************/ - -typedef struct S13 { - short a; - short b; - short c; -} S13; - -S13 ctest13(char x, S13 s, char y) { - printf("C sz = %d\n", (int)sizeof(S13)); - assert(sizeof(S13) == 6); - printf("x = %d\n", (int)x); - printf("s.a = %d\n", (int)s.a); - printf("s.b = %d\n", (int)s.b); - printf("s.c = %d\n", (int)s.c); - printf("y = %d\n", (int)y); - return s; -} - - -/**********************************************/ - -typedef struct S14 { - char a,d,e,f; - char b,g; - char c; -} S14; - -S14 ctest14(char x, S14 s, char y) { - printf("C sz = %d\n", (int)sizeof(S14)); - assert(sizeof(S14) == 7); - printf("x = %d\n", (int)x); - printf("s.a = %d\n", (int)s.a); - printf("s.b = %d\n", (int)s.b); - printf("s.c = %d\n", (int)s.c); - printf("y = %d\n", (int)y); - return s; -} - - -/**********************************************/ - -typedef struct S15 { - char a,d,e,f; - char b,g,h,i; - char c; -} S15; - -S15 ctest15(char x, S15 s, char y) { - printf("C sz = %d\n", (int)sizeof(S15)); - assert(sizeof(S15) == 9); - printf("x = %d\n", (int)x); - printf("s.a = %d\n", (int)s.a); - printf("s.b = %d\n", (int)s.b); - printf("s.c = %d\n", (int)s.c); - printf("y = %d\n", (int)y); - return s; -} - - -/**********************************************/ - -typedef struct S16 { - char a[5]; -#ifdef __GNUC__ - struct __attribute__((packed)) -#else - #pragma pack(push, 1) - struct -#endif - { - char b; - int c; - }; -#ifndef __GNUC__ - #pragma pack(pop) -#endif -} S16; - -S16 ctest16(char x, S16 s, char y) { - printf("C sz = %d\n", (int)sizeof(S16)); - assert(sizeof(S16) == 10); - printf("x = %d\n", (int)x); - printf("s.a = %.*s\n", 5, s.a); - printf("s.b = %d\n", (int)s.b); - printf("s.c = %d\n", s.c); - printf("y = %d\n", (int)y); - return s; -} - - - -#if __cplusplus -} -#endif - diff --git a/gcc/testsuite/gdc.test/runnable/extra-files/cpp_abi_tests.cpp b/gcc/testsuite/gdc.test/runnable/extra-files/cpp_abi_tests.cpp deleted file mode 100644 index 63f74a280c1..00000000000 --- a/gcc/testsuite/gdc.test/runnable/extra-files/cpp_abi_tests.cpp +++ /dev/null @@ -1,60 +0,0 @@ -struct S{ - float a; -}; - -bool passthrough(bool value) { return value; } -signed char passthrough(signed char value) { return value; } -unsigned char passthrough(unsigned char value) { return value; } -char passthrough(char value) { return value; } -wchar_t passthrough(wchar_t value) { return value; } -short passthrough(short value) { return value; } -unsigned short passthrough(unsigned short value) { return value; } -int passthrough(int value) { return value; } -unsigned int passthrough(unsigned int value) { return value; } -long passthrough(long value) { return value; } -unsigned long passthrough(unsigned long value) { return value; } -long long passthrough(long long value) { return value; } -unsigned long long passthrough(unsigned long long value) { return value; } -float passthrough(float value) { return value; } -double passthrough(double value) { return value; } -S passthrough(S value) { return value; } - -bool passthrough_ptr(bool *value) { return *value; } -signed char passthrough_ptr(signed char *value) { return *value; } -unsigned char passthrough_ptr(unsigned char *value) { return *value; } -char passthrough_ptr(char *value) { return *value; } -wchar_t passthrough_ptr(wchar_t *value) { return *value; } -short passthrough_ptr(short *value) { return *value; } -unsigned short passthrough_ptr(unsigned short *value) { return *value; } -int passthrough_ptr(int *value) { return *value; } -unsigned int passthrough_ptr(unsigned int *value) { return *value; } -long passthrough_ptr(long *value) { return *value; } -unsigned long passthrough_ptr(unsigned long *value) { return *value; } -long long passthrough_ptr(long long *value) { return *value; } -unsigned long long passthrough_ptr(unsigned long long *value) { return *value; } -float passthrough_ptr(float *value) { return *value; } -double passthrough_ptr(double *value) { return *value; } -S passthrough_ptr(S *value) { return *value; } - -bool passthrough_ref(bool &value) { return value; } -signed char passthrough_ref(signed char &value) { return value; } -unsigned char passthrough_ref(unsigned char &value) { return value; } -char passthrough_ref(char &value) { return value; } -wchar_t passthrough_ref(wchar_t &value) { return value; } -short passthrough_ref(short &value) { return value; } -unsigned short passthrough_ref(unsigned short &value) { return value; } -int passthrough_ref(int &value) { return value; } -unsigned int passthrough_ref(unsigned int &value) { return value; } -long passthrough_ref(long &value) { return value; } -unsigned long passthrough_ref(unsigned long &value) { return value; } -long long passthrough_ref(long long &value) { return value; } -unsigned long long passthrough_ref(unsigned long long &value) { return value; } -float passthrough_ref(float &value) { return value; } -double passthrough_ref(double &value) { return value; } -S passthrough_ref(S &value) { return value; } - -// Uncomment when mangling is fixed -// typedef void(*fn0)(); -// fn0 passthrough_fn0 (fn0 value) { return value; } -// typedef int (*fn1)(int); -// fn1 passthrough_fn1 (fn1 value) { return value; } diff --git a/gcc/testsuite/gdc.test/runnable/extra-files/cppb.cpp b/gcc/testsuite/gdc.test/runnable/extra-files/cppb.cpp deleted file mode 100644 index 587145c61c3..00000000000 --- a/gcc/testsuite/gdc.test/runnable/extra-files/cppb.cpp +++ /dev/null @@ -1,818 +0,0 @@ -/* -GCC 5.1 introduced new implementations of std::string and std::list: - -https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html - -This causes e.g. std::string to be actually defined as -std::__cxx11::string. - -On machines with GCC 5.1, this manifests as a linker error when -running the cppa.d / cppb.cpp test: - -cppa.o: In function `_D4cppa6test14FZv': -cppa.d:(.text._D4cppa6test14FZv+0x11): undefined reference to `foo14a(std::string*)' -cppa.d:(.text._D4cppa6test14FZv+0x18): undefined reference to `foo14b(std::basic_string, std::allocator >*)' -cppa.d:(.text._D4cppa6test14FZv+0x3a): undefined reference to `foo14f(std::char_traits*, std::string*, std::string*)' -cppa.o: In function `_D4cppa7testeh3FZv': -cppa.d:(.text._D4cppa7testeh3FZv+0x19): undefined reference to `throwle()' -collect2: error: ld returned 1 exit status ---- errorlevel 1 - -When the .cpp file is compiled with g++ 5.3.0, the actual function -signatures in the cppb.o object file are: - -foo14a(std::__cxx11::basic_string, std::allocator >*) -foo14b(std::__cxx11::basic_string, std::allocator >*) -foo14f(std::char_traits*, std::__cxx11::basic_string, std::allocator >*, std::__cxx11::basic_string, std::allocator >*) - -Fortunately, it is easily possible to disable the new feature -by defining _GLIBCXX_USE_CXX11_ABI as 0 before including any standard -headers. -*/ -#define _GLIBCXX_USE_CXX11_ABI 0 - -#include -#include -#include -#include - -/**************************************/ - -int foo(int i, int j, int k); - -int foob(int i, int j, int k) -{ - printf("i = %d\n", i); - printf("j = %d\n", j); - printf("k = %d\n", k); - assert(i == 1); - assert(j == 2); - assert(k == 3); - - foo(i, j, k); - - return 7; -} - -/**************************************/ - -class D *dthis; - -class D -{ - public: - virtual int bar(int i, int j, int k) - { - printf("this = %p\n", this); - assert(this == dthis); - printf("D.bar: i = %d\n", i); - printf("D.bar: j = %d\n", j); - printf("D.bar: k = %d\n", k); - assert(i == 9); - assert(j == 10); - assert(k == 11); - return 8; - } -}; - - -D* getD() -{ - D *d = new D(); - dthis = d; - return d; -} - -/**************************************/ - -class E -{ - public: - virtual int bar(int i, int j, int k); -}; - - -int callE(E *e) -{ - return e->bar(11,12,13); -} - -/**************************************/ - -void foo4(char *p) -{ -} - -/**************************************/ - -struct foo5 { int i; int j; void *p; }; - -class bar5 -{ -public: - virtual foo5 getFoo(int i){ - printf("This = %p\n", this); - foo5 f; - f.i = 1; - f.j = 2 + i; - f.p = (void*)this; - return f; - } -}; - -bar5* newBar() -{ - bar5* b = new bar5(); - printf("bar = %p\n", b); - return b; -} - - -/**************************************/ - -struct A11802; -struct B11802; - -class C11802 -{ -public: - virtual void fun(A11802 *); - virtual void fun(B11802 *); -}; - -class D11802 : public C11802 -{ -public: - void fun(A11802 *); - void fun(B11802 *); -}; - -void test11802x(D11802 *c) -{ - c->fun((A11802 *)0); - c->fun((B11802 *)0); -} - -/**************************************/ - -typedef struct -{ - int i; - double d; -} S6; - -union S6_2 -{ - int i; - double d; -}; - -enum S6_3 -{ - A, B -}; - - -S6 foo6(void) -{ - S6 s; - s.i = 42; - s.d = 2.5; - return s; -} - -S6_2 foo6_2(void) -{ - S6_2 s; - s.i = 42; - return s; -} - -S6_3 foo6_3(void) -{ - S6_3 s = A; - return s; -} - -extern "C" { int foosize6() -{ - return sizeof(S6); -} -} - -/**************************************/ - -typedef struct -{ - int i; - long long d; -} S7; - -extern "C" { int foo7() -{ - return sizeof(S7); -} -} - -/**************************************/ - -struct S13955a -{ - float a; - double b; -}; - -struct S13955b -{ - double a; - float b; -}; - -struct S13955c -{ - float a; - float b; -}; - -struct S13955d -{ - double a; - double b; -}; - -void check13955(S13955a a, S13955b b, S13955c c, S13955d d); - -void func13955(S13955a a, S13955b b, S13955c c, S13955d d) -{ - check13955(a, b, c, d); -} - -/**************************************/ - -struct Struct10071 -{ - void *p; - long double r; -}; - -size_t offset10071() -{ - Struct10071 s; - return (char *)&s.r - (char *)&s; -} - -/**************************************/ - -void foo8(const char *p) -{ -} - -/**************************************/ -// 4059 - -struct elem9 { }; -void foobar9(elem9*, elem9*) { } - -/**************************************/ -// 5148 - -void foo10(const char*, const char*) { } -void foo10(const int, const int) { } -void foo10(const char, const char) { } -void foo10(bool, bool) { } - -struct MyStructType { }; -void foo10(const MyStructType s, const MyStructType t) { } - -enum MyEnumType { onemember }; -void foo10(const MyEnumType s, const MyEnumType t) { } - -/**************************************/ - -namespace N11 { namespace M { void bar11() { } } } - -namespace A11 { namespace B { namespace C { void bar() { } } } } - -/**************************************/ - -void myvprintfx(const char* format, va_list); - -void myvprintf(const char* format, va_list va) -{ - myvprintfx(format, va); -} - -/**************************************/ - -class C13161 -{ -public: - virtual void dummyfunc() {} - long long val_5; - unsigned val_9; -}; - -class Test : public C13161 -{ -public: - unsigned val_0; - long long val_1; -}; - -size_t getoffset13161() -{ - Test s; - return (char *)&s.val_0 - (char *)&s; -} - -class C13161a -{ -public: - virtual void dummyfunc() {} - long double val_5; - unsigned val_9; -}; - -class Testa : public C13161a -{ -public: - bool val_0; -}; - -size_t getoffset13161a() -{ - Testa s; - return (char *)&s.val_0 - (char *)&s; -} - -/****************************************************/ - -#if __linux__ || __APPLE__ || __FreeBSD__ -#include -#include -#include - -#if __linux__ -template struct std::allocator; -template struct std::vector; - -void foo15() -{ - std::allocator* p; - p->deallocate(0, 0); -} - -#endif - -// _Z5foo14PSt6vectorIiSaIiEE -void foo14(std::vector > *p) { } - -void foo14a(std::basic_string *p) { } -void foo14b(std::basic_string *p) { } -void foo14c(std::basic_istream *p) { } -void foo14d(std::basic_ostream *p) { } -void foo14e(std::basic_iostream *p) { } - -void foo14f(std::char_traits* x, std::basic_string *p, std::basic_string *q) { } - -#endif - -/**************************************/ - -struct S13956 -{ -}; - -void check13956(S13956 arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6); - -void func13956(S13956 arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) -{ - check13956(arg0, arg1, arg2, arg3, arg4, arg5, arg6); -} - -/**************************************/ - -wchar_t f13289_cpp_wchar_t(wchar_t ch) -{ - if (ch <= L'z' && ch >= L'a') - { - return ch - (L'a' - L'A'); - } - else - { - return ch; - } -} - -#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __NetBSD__ -unsigned short f13289_d_wchar(unsigned short ch); -wchar_t f13289_d_dchar(wchar_t ch); -#elif _WIN32 -wchar_t f13289_d_wchar(wchar_t ch); -unsigned int f13289_d_dchar(unsigned int ch); -#endif - -bool f13289_cpp_test() -{ -#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __NetBSD__ - if (!(f13289_d_wchar((unsigned short)'c') == (unsigned short)'C')) return false; - if (!(f13289_d_wchar((unsigned short)'D') == (unsigned short)'D')) return false; - if (!(f13289_d_dchar(L'e') == L'E')) return false; - if (!(f13289_d_dchar(L'F') == L'F')) return false; - return true; -#elif _WIN32 - if (!(f13289_d_wchar(L'c') == L'C')) return false; - if (!(f13289_d_wchar(L'D') == L'D')) return false; - if (!(f13289_d_dchar((unsigned int)'e') == (unsigned int)'E')) return false; - if (!(f13289_d_dchar((unsigned int)'F') == (unsigned int)'F')) return false; - return true; -#else - return false; -#endif -} - -/******************************************/ - -long double testld(long double ld) -{ - assert(ld == 5); - return ld + 1; -} - -long double testldld(long double ld1, long double ld2) -{ - assert(ld1 == 5); - return ld2 + 1; -} - -long testl(long lng) -{ - assert(lng == 5); - return lng + sizeof(long); -} - -unsigned long testul(unsigned long ul) -{ - assert(ul == 5); - return ul + sizeof(unsigned long); -} - -/******************************************/ - -struct S13707 -{ - void* a; - void* b; - S13707(void *a, void* b) - { - this->a = a; - this->b = b; - } -}; - -S13707 func13707() -{ - S13707 pt(NULL, NULL); - return pt; -} - -/******************************************/ - -template struct S13932 -{ - int member; -}; - -void func13932(S13932<-1> s) {} - -/******************************************/ - -namespace N13337 { - namespace M13337 { - struct S13337 { }; - void foo13337(S13337 s) { } - } -} - -/****************************************/ -// 14195 - -template -struct Delegate1 {}; - -template -struct Delegate1 < R1() > {}; - -template -struct Delegate2 {}; - -template < typename R1, typename T1, typename T2, typename R2, typename T3, typename T4 > -struct Delegate2 {}; - -void test14195a(Delegate1 func) {} - -void test14195b(Delegate2 func) {} - -/******************************************/ -// 14200 - -void test14200a(int a) {}; -void test14200b(float a, int b, double c) {}; - -/******************************************/ -// 14956 - -namespace std { - namespace N14956 { - struct S14956 { }; - } -} - -void test14956(std::N14956::S14956 s) { } - -/******************************************/ -// check order of overloads in vtable - -class Statement; -class ErrorStatement; -class PeelStatement; -class ExpStatement; -class DtorExpStatement; - -class Visitor -{ -public: - virtual int visit(Statement*) { return 1; } - virtual int visit(ErrorStatement*) { return 2; } - virtual int visit(PeelStatement*) { return 3; } -}; - -class Visitor2 : public Visitor -{ -public: - virtual int visit2(ExpStatement*) { return 4; } - virtual int visit2(DtorExpStatement*) { return 5; } -}; - -bool testVtableCpp(Visitor2* sv) -{ - if (sv->visit((Statement*)0) != 1) return false; - if (sv->visit((ErrorStatement*)0) != 2) return false; - if (sv->visit((PeelStatement*)0) != 3) return false; - if (sv->visit2((ExpStatement*)0) != 4) return false; - if (sv->visit2((DtorExpStatement*)0) != 5) return false; - return true; -} - -Visitor2 inst; - -Visitor2* getVisitor2() -{ - return &inst; -} - -/******************************************/ -// issues detected by fuzzer -#if _LP64 -#define longlong long -#else -#define longlong long long -#endif - -void fuzz1_checkValues(longlong arg10, longlong arg11, bool arg12); -void fuzz1_cppvararg(longlong arg10, longlong arg11, bool arg12) -{ - fuzz1_checkValues(arg10, arg11, arg12); -} - -void fuzz2_checkValues(unsigned longlong arg10, unsigned longlong arg11, bool arg12); -void fuzz2_cppvararg(unsigned longlong arg10, unsigned longlong arg11, bool arg12) -{ - fuzz2_checkValues(arg10, arg11, arg12); -} - -#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __NetBSD__ -#define wchar unsigned short -#elif _WIN32 -#define wchar wchar_t -#endif - -void fuzz3_checkValues(wchar arg10, wchar arg11, bool arg12); -void fuzz3_cppvararg(wchar arg10, wchar arg11, bool arg12) -{ - fuzz3_checkValues(arg10, arg11, arg12); -} - -/******************************************/ - -void throwit() -{ -#if _WIN32 -#else - std::exception se; - throw se; -#endif -} - -/******************************************/ - -#if linux -#include - -void throwle() -{ - std::logic_error le("test"); - throw le; -} - -#endif - -/******************************************/ -// 15579 - -/******************************************/ -// 15579 - -class Base -{ -public: - //virtual ~Base() {} - virtual void base(); - unsigned char x; -}; - -class Interface -{ -public: - virtual int MethodCPP() = 0; - virtual int MethodD() = 0; -}; - -class Derived : public Base, public Interface -{ -public: - Derived(); - short y; - int MethodCPP(); -#if _WIN32 || _WIN64 - int MethodD(); - virtual int Method(); -#else - int MethodD() { return 3; } // need def or vtbl[] is not generated - virtual int Method() { return 6; } // need def or vtbl[] is not generated -#endif -}; - -void Base::base() { } -int Derived::MethodCPP() { - printf("Derived::MethodCPP() this = %p, x = %d, y = %d\n", this, x, y); - assert(x == 4 || x == 7); - assert(y == 5 || y == 8); - return 30; -} -Derived::Derived() { } - - -Derived *cppfoo(Derived *d) -{ - printf("cppfoo(): d = %p\n", d); - assert(d->x == 4); - assert(d->y == 5); - assert(d->MethodD() == 3); - assert(d->MethodCPP() == 30); - assert(d->Method() == 6); - - d = new Derived(); - d->x = 7; - d->y = 8; - assert(d->MethodD() == 3); - assert(d->MethodCPP() == 30); - assert(d->Method() == 6); - printf("d1 = %p\n", d); - return d; -} - -Interface *cppfooi(Interface *i) -{ - printf("cppfooi(): i = %p\n", i); - assert(i->MethodD() == 3); - assert(i->MethodCPP() == 30); - - Derived *d = new Derived(); - d->x = 7; - d->y = 8; - printf("d = %p, i = %p\n", d, (Interface *)d); - return d; -} - -/******************************************/ -// 15610 - -class Base2 -{ - public: - int i; - virtual void baser() { } -}; - -class Interface2 -{ - public: - virtual void f() = 0; -}; - -class Derived2 : public Base2, public Interface2 -{ - public: - void f(); -}; - -void Derived2::f() -{ - printf("Derived2::f() this = %p i = %d\n", this, i); - assert(i == 3); -} - -/******************************************/ -// 15455 - -struct X6 -{ - unsigned short a; - unsigned short b; - unsigned char c; - unsigned char d; -}; - -struct X8 -{ - unsigned short a; - X6 b; -}; - -void test15455b(X8 s) -{ - assert(sizeof(X6) == 6); - assert(sizeof(X8) == 8); - assert(s.a == 1); - assert(s.b.a == 2); - assert(s.b.b == 3); - assert(s.b.c == 4); - assert(s.b.d == 5); -} - -/******************************************/ -// 15372 - -template -int foo15372(int value) -{ - return value; -} - -void test15372b() -{ - int t = foo15372(1); -} - -/****************************************/ -// 15576 - -namespace ns15576 -{ - int global15576; - - namespace ns - { - int n_global15576; - } -} - -/****************************************/ -// 15802 - -template -class Foo15802 -{ -public: - static int boo(int value) - { - return value; - } -}; - -void test15802b() -{ - int t = Foo15802::boo(1); -} - - -/****************************************/ -// 16536 - mangling mismatch on OSX - -#if defined(__APPLE__) -__UINTMAX_TYPE__ pass16536(__UINTMAX_TYPE__ a) -{ - return a; -} -#endif diff --git a/gcc/testsuite/gdc.test/runnable/extra-files/externmangle.cpp b/gcc/testsuite/gdc.test/runnable/extra-files/externmangle.cpp deleted file mode 100644 index da3e8449b2e..00000000000 --- a/gcc/testsuite/gdc.test/runnable/extra-files/externmangle.cpp +++ /dev/null @@ -1,404 +0,0 @@ -#include - -template -struct Foo -{ - X *v; -}; - -template -struct Boo -{ - X *v; -}; - -void test1(Foo arg1) -{ -} - - -void test2(int* arg2, Boo arg1) -{ -} - -template -struct Test3 -{ - -}; - -void test3(Test3<3,3> arg1) -{ -} - -void test4(Foo arg1, Boo arg2, Boo arg3, int*, Foo) -{ -} - -void test5(Foo arg1, Boo arg2, Boo arg3) -{ -} - -struct Goo -{ - - template - struct Foo - { - X* v; - }; - - template - struct Boo - { - template - struct Xoo - { - Y* v; - }; - X* v; - }; - - - void test6(Foo > > arg1); - void test7(Boo::Xoo arg1); -}; - -void Goo::test6(Goo::Foo > > arg1) -{ -} - -void Goo::test7(Goo::Boo::Xoo arg1) -{ -} - -struct P1 -{ - template - struct Mem - { - }; -}; - -struct P2 -{ - template - struct Mem - { - }; -}; - -void test8(P1::Mem, P2::Mem){} -void test9(Foo, Foo, int**, int*){} - - - -class Test10 -{ - private: void test10(); - public: void test11(); - protected: void test12(); - public: void test13() const; - - private: void test14(); // Private methods in D are always non-virtual - public: virtual void test15(); - protected: virtual void test16(); - - private: static void test17(); - public: static void test18(); - protected: static void test19(); -}; - -Test10* Test10Ctor() -{ - return new Test10(); -} - -void Test10Dtor(Test10*& ptr) -{ - delete ptr; - ptr = 0; -} - -void Test10::test10(){} -void Test10::test11(){} -void Test10::test12(){} -void Test10::test13() const{} -void Test10::test14(){} -void Test10::test15(){} -void Test10::test16(){} -void Test10::test17(){} -void Test10::test18(){} -void Test10::test19(){} - -struct Test20 -{ - private: static int test20; - protected: static int test21; - public: static int test22; -}; - -int Test20::test20 = 20; -int Test20::test21 = 21; -int Test20::test22 = 22; - -int test23(Test10**, Test10*, Test10***, Test10 const *const) -{ - return 1; -} - -int test23b(Test10 const *const *const, Test10 const* const, Test10*) -{ - return 1; -} - -void test24(int(*)(int,int)) -{ -} - -void test25(int arr[2][5][6][291]) -{ -} - -int test26(int arr[5][6][291]) -{ - return arr[1][1][1]; -} - -void test27(int, ...){} -void test28(int){} - -void test29(float){} -void test30(const float){} - -template -struct Array -{ - int dim; -}; - -class Module -{ -public: - static void imports(Module*); - static int dim(Array*); -}; - - -void Module::imports(Module*) -{ -} - -int Module::dim(Array* arr) -{ - return arr->dim; -} - -#if _LP64 -unsigned long testlongmangle(int32_t a, uint32_t b, long c, unsigned long d) -{ - return a + b + c + d; -} -#else -unsigned long long testlongmangle(int a, unsigned int b, long long c, unsigned long long d) -{ - return a + b + c + d; -} -#endif - -int test31[2][2][2] = {1, 1, 1, 1, 1, 1, 1, 1}; -int *test32 = 0; - - - -class Expression; - -typedef int (*apply_fp_t)(Expression*, void*); - -class Expression -{ - int type; -public: - int apply(apply_fp_t fp, apply_fp_t fp2, void *param); - int getType(); - static Expression* create(int v); - static void dispose(Expression*&); -}; - -int Expression::apply(apply_fp_t fp, apply_fp_t fp2, void *param) -{ - return fp(this, param) * fp2(this, param); -} - -int Expression::getType() -{ - return type; -} - -Expression* Expression::create(int v) -{ - Expression *e = new Expression(); - e->type = v; - return e; -} - -void Expression::dispose(Expression *&e) -{ - if (e) - delete e; - e = 0; -} - -/*int test34(int v[0][0][0]) -{ - return 0; -}*/ - -#ifndef _MSC_VER - int test35(long double arg) - { - return (int)arg; - } -#endif - -const char *test36(const char *arg) -{ - return arg; -} - -class Test37 -{ -public: - static Test37 *create(); - bool test(); -}; - -bool test37() -{ - Test37 *o = Test37::create(); - return o->test(); -} - -class Test38 -{ -public: - int test(int, ...); - static Test38* create(); - static void dispose(Test38*&); -}; - -int Test38::test(int a, ...) -{ - return a; -} - -Test38* Test38::create() -{ - Test38 *t = new Test38(); - return t; -} - -void Test38::dispose(Test38 *&t) -{ - if (t) - delete t; - t = 0; -} - -class S1 -{ - int val; -public: - static S1* init(int); - S1(int v) : val(v) {} - int value(); -}; - -S1* S1::init(int x) -{ - return new S1(x); -} - -int S1::value() -{ - return val; -} - -template -class S2 -{ - T val; -public: - static S2* init(T); - S2(T v) : val(v) {} - T value(); -}; - -template<> -S2* S2::init(int x) -{ - return new S2(x); -} - -template<> -int S2::value() -{ - return val; -} - -struct C1 -{ - const char *data; - - static C1* init(const char *p); - - C1(const char* p) : data(p) { } - - virtual const char* getDataCPP(); - virtual const char* getDataD(); -}; - -C1* C1::init(const char *p) -{ - return new C1(p); -} - -const char* C1::getDataCPP() -{ - return data; -} - -template -struct C2 -{ - const T *data; - - static C2* init(const T *p); - - C2(const T* p) : data(p) { } - - virtual const T* getData(); -}; - -template<> -C2* C2::init(const char *p) -{ - return new C2(p); -} - -template<> -const char* C2::getData() -{ - return data; -} - -int test39cpp(C2* c2, S2* s2) -{ - C2* otherC2 = C2::init(c2->getData()); - if (c2->getData() != otherC2->getData()) - return 1; - S2* otherS2 = S2::init(s2->value()); - if (s2->value() != otherS2->value()) - return 2; - return 0; -} \ No newline at end of file diff --git a/gcc/testsuite/gdc.test/runnable/extra-files/externmangle2.cpp b/gcc/testsuite/gdc.test/runnable/extra-files/externmangle2.cpp deleted file mode 100644 index b481348976a..00000000000 --- a/gcc/testsuite/gdc.test/runnable/extra-files/externmangle2.cpp +++ /dev/null @@ -1,145 +0,0 @@ - -struct Test32NS1 -{ - template - struct Foo - { - X *v; - }; - - template - struct Bar - { - X *v; - }; - -}; - -struct Test32NS2 -{ - template - struct Foo - { - X *v; - }; -}; - -template