diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2019-04-23 20:08:46 +0000 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gcc.gnu.org> | 2019-04-23 20:08:46 +0000 |
commit | c0aebc60b2ac19816f0431241d8f7203e60afb01 (patch) | |
tree | 4eec38d1f02e2a59de0dc908c56593c54d0d3960 /gcc/testsuite/gdc.test | |
parent | 32efff9f947137bb6f6bf47a846e3bf8a162170a (diff) | |
download | gcc-c0aebc60b2ac19816f0431241d8f7203e60afb01.zip gcc-c0aebc60b2ac19816f0431241d8f7203e60afb01.tar.gz gcc-c0aebc60b2ac19816f0431241d8f7203e60afb01.tar.bz2 |
d: Add support for compiling without libphobos library.
Merges upstream dmd 3b3dca8be
Reviewed-on: https://github.com/dlang/dmd/pull/9678
gcc/d/ChangeLog:
2019-04-23 Iain Buclaw <ibuclaw@gdcproject.org>
* d-builtins.cc (d_init_versions): Add D_BetterC, D_ModuleInfo,
D_Exceptions, D_TypeInfo as predefined version conditions.
* d-codegen.cc (build_bounds_condition): Generate trap if D asserts
are turned off.
* d-frontend.cc (getTypeInfoType): Add error when -fno-rtti is set.
* d-lang.cc (d_init_options): Initialize new front-end options.
(d_handle_option): Handle -fdruntime, -fexceptions, and -frtti.
(d_post_options): Turn off D runtime features if -fno-druntime is set.
* d-spec.cc (lang_specific_driver): Handle -fdruntime.
* d-tree.h (have_typeinfo_p): Add prototype.
(build_typeinfo): Update prototype.
* decl.cc (DeclVisitor::visit(StructDeclaration)): Create typeinfo
only if TypeInfo exists.
(DeclVisitor::visit(ClassDeclaration)): Likewise.
(DeclVisitor::visit(InterfaceDeclaration)): Likewise.
(DeclVisitor::visit(EnumDeclaration)): Likewise.
* expr.cc: Update all calls to build_typeinfo.
* gdc.texi (Runtime Options): Document -fdruntime and -frtti.
* lang.opt: Add -fdruntime and -frtti.
* modules.cc (build_module_tree): Create module info only if
ModuleInfo exists.
* toir.cc (IRVisitor::visit(ThrowStatement)): Update test for
-fno-exceptions.
* typeinfo.cc (create_tinfo_types): Build internal typeinfo classes
only if Object exists.
(have_typeinfo_p): New function.
(class TypeInfoVisitor): Update all calls to build_typeinfo.
(build_typeinfo): Add error when -fno-rtti is set.
gcc/testsuite/ChangeLog:
2019-04-23 Iain Buclaw <ibuclaw@gdcproject.org>
* gdc.test/fail_compilation/fail2456.d: New test.
* gdc.test/fail_compilation/test18312.d: New test.
* gdc.test/gdc-test.exp (gdc-convert-args): Handle -betterC.
From-SVN: r270518
Diffstat (limited to 'gcc/testsuite/gdc.test')
-rw-r--r-- | gcc/testsuite/gdc.test/fail_compilation/fail2456.d | 110 | ||||
-rw-r--r-- | gcc/testsuite/gdc.test/fail_compilation/test18312.d | 15 | ||||
-rw-r--r-- | gcc/testsuite/gdc.test/gdc-test.exp | 3 |
3 files changed, 128 insertions, 0 deletions
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail2456.d b/gcc/testsuite/gdc.test/fail_compilation/fail2456.d new file mode 100644 index 0000000..e8cf5ab --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/fail2456.d @@ -0,0 +1,110 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/fail2456.d(14): Error: cannot put `scope(success)` statement inside finally block +--- +*/ +void test_success() +{ + try + { + } + finally + { + scope(success) {} // NG + } +} + +/* +TEST_OUTPUT: +--- +fail_compilation/fail2456.d(31): Error: cannot put `scope(failure)` statement inside finally block +--- +*/ +void test_failure() +{ + try + { + } + finally + { + scope(failure) {} // NG + } +} + +/* +TEST_OUTPUT: +--- +--- +*/ +void test_exit() +{ + try + { + } + finally + { + scope(exit) {} // OK + } +} + +/* +TEST_OUTPUT: +--- +fail_compilation/fail2456.d(64): Error: cannot put `scope(success)` statement inside `scope(success)` +fail_compilation/fail2456.d(65): Error: cannot put `scope(failure)` statement inside `scope(success)` +fail_compilation/fail2456.d(78): Error: cannot put `scope(success)` statement inside `scope(exit)` +fail_compilation/fail2456.d(79): Error: cannot put `scope(failure)` statement inside `scope(exit)` +--- +*/ +void test2456a() +{ + scope(success) + { + scope(success) {} // NG + scope(failure) {} // NG + scope(exit) {} // OK + } + + scope(failure) + { + scope(success) {} // OK + scope(failure) {} // OK + scope(exit) {} // OK + } + + scope(exit) + { + scope(success) {} // NG + scope(failure) {} // NG + scope(exit) {} // OK + } +} + +/* +TEST_OUTPUT: +--- +fail_compilation/fail2456.d(96): Error: cannot put catch statement inside `scope(success)` +fail_compilation/fail2456.d(108): Error: cannot put catch statement inside `scope(exit)` +--- +*/ +void test2456b() +{ + scope(success) + { + try {} + catch (Throwable) {} // NG + } + + scope(failure) + { + try {} + catch (Throwable) {} // OK + } + + scope(exit) + { + try {} + catch (Throwable) {} // NG + } +} diff --git a/gcc/testsuite/gdc.test/fail_compilation/test18312.d b/gcc/testsuite/gdc.test/fail_compilation/test18312.d new file mode 100644 index 0000000..e354a11 --- /dev/null +++ b/gcc/testsuite/gdc.test/fail_compilation/test18312.d @@ -0,0 +1,15 @@ +/* +REQUIRED_ARGS: -betterC +TEST_OUTPUT: +--- +fail_compilation/test18312.d(14): Error: array concatenation of expression `"[" ~ s ~ "]"` requires the GC which is not available with -betterC +--- +*/ + +// https://issues.dlang.org/show_bug.cgi?id=18312 + +extern (C) void main() +{ + scope string s; + s = "[" ~ s ~ "]"; +} diff --git a/gcc/testsuite/gdc.test/gdc-test.exp b/gcc/testsuite/gdc.test/gdc-test.exp index ab8a4a3..ce5575c 100644 --- a/gcc/testsuite/gdc.test/gdc-test.exp +++ b/gcc/testsuite/gdc.test/gdc-test.exp @@ -39,6 +39,9 @@ proc gdc-convert-args { args } { } elseif [string match "-allinst" $arg] { lappend out "-fall-instantiations" + } elseif [string match "-betterC" $arg] { + lappend out "-fno-druntime" + } elseif { [string match "-boundscheck" $arg] || [string match "-boundscheck=on" $arg] } { lappend out "-fbounds-check" |