aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2023-09-23 12:27:26 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2023-09-23 13:01:16 +0200
commitd6679fa2d65316e80a267c94c17ad9e23f433f77 (patch)
treeeca9ecef18b21760629c54620785c18bc4452bbd /gcc
parent59d27cc55a0588ed7b03bef804662cb844e8a24d (diff)
downloadgcc-d6679fa2d65316e80a267c94c17ad9e23f433f77.zip
gcc-d6679fa2d65316e80a267c94c17ad9e23f433f77.tar.gz
gcc-d6679fa2d65316e80a267c94c17ad9e23f433f77.tar.bz2
d: Merge upstream dmd, druntime 4574d1728d, phobos d7e79f024.
D front-end changes: - Import dmd v2.105.0. - Catch clause must take only `const' or mutable exceptions. - Creating a `scope' class instance with a non-scope constructor is now `@system' only with `-fpreview=dip1000'. - Global `const' variables can no longer be initialized from a non-shared static constructor D runtime changes: - Import druntime v2.105.0. Phobos changes: - Import phobos v2.105.0. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 4574d1728d. * dmd/VERSION: Bump version to v2.105.0. * d-diagnostic.cc (verror): Remove. (verrorSupplemental): Remove. (vwarning): Remove. (vwarningSupplemental): Remove. (vdeprecation): Remove. (vdeprecationSupplemental): Remove. (vmessage): Remove. (vtip): Remove. (verrorReport): New function. (verrorReportSupplemental): New function. * d-lang.cc (d_parse_file): Update for new front-end interface. * decl.cc (d_mangle_decl): Update for new front-end interface. * intrinsics.cc (maybe_set_intrinsic): Update for new front-end interface. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 4574d1728d. * src/MERGE: Merge upstream phobos d7e79f024.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/d/d-diagnostic.cc199
-rw-r--r--gcc/d/d-lang.cc6
-rw-r--r--gcc/d/decl.cc2
-rw-r--r--gcc/d/dmd/MERGE2
-rw-r--r--gcc/d/dmd/README.md3
-rw-r--r--gcc/d/dmd/VERSION2
-rw-r--r--gcc/d/dmd/access.d1
-rw-r--r--gcc/d/dmd/aggregate.d2
-rw-r--r--gcc/d/dmd/aliasthis.d3
-rw-r--r--gcc/d/dmd/arrayop.d10
-rw-r--r--gcc/d/dmd/attrib.d47
-rw-r--r--gcc/d/dmd/blockexit.d1
-rw-r--r--gcc/d/dmd/canthrow.d3
-rw-r--r--gcc/d/dmd/common/file.d8
-rw-r--r--gcc/d/dmd/common/outbuffer.d12
-rw-r--r--gcc/d/dmd/common/string.d5
-rw-r--r--gcc/d/dmd/cond.d16
-rw-r--r--gcc/d/dmd/constfold.d4
-rw-r--r--gcc/d/dmd/cppmangle.d18
-rw-r--r--gcc/d/dmd/ctfeexpr.d24
-rw-r--r--gcc/d/dmd/ctorflow.d8
-rw-r--r--gcc/d/dmd/dclass.d2
-rw-r--r--gcc/d/dmd/declaration.d30
-rw-r--r--gcc/d/dmd/declaration.h4
-rw-r--r--gcc/d/dmd/delegatize.d4
-rw-r--r--gcc/d/dmd/dinterpret.d17
-rw-r--r--gcc/d/dmd/dmangle.d66
-rw-r--r--gcc/d/dmd/dmodule.d6
-rw-r--r--gcc/d/dmd/doc.d99
-rw-r--r--gcc/d/dmd/doc.h3
-rw-r--r--gcc/d/dmd/dscope.d15
-rw-r--r--gcc/d/dmd/dsymbol.d52
-rw-r--r--gcc/d/dmd/dsymbolsem.d30
-rw-r--r--gcc/d/dmd/dtemplate.d22
-rw-r--r--gcc/d/dmd/dtoh.d23
-rw-r--r--gcc/d/dmd/dversion.d8
-rw-r--r--gcc/d/dmd/errors.d180
-rw-r--r--gcc/d/dmd/errors.h20
-rw-r--r--gcc/d/dmd/errorsink.d6
-rw-r--r--gcc/d/dmd/escape.d2
-rw-r--r--gcc/d/dmd/expression.d303
-rw-r--r--gcc/d/dmd/expression.h1
-rw-r--r--gcc/d/dmd/expressionsem.d49
-rw-r--r--gcc/d/dmd/foreachvar.d2
-rw-r--r--gcc/d/dmd/func.d17
-rw-r--r--gcc/d/dmd/globals.d18
-rw-r--r--gcc/d/dmd/globals.h2
-rw-r--r--gcc/d/dmd/hdrgen.d16
-rw-r--r--gcc/d/dmd/id.d8
-rw-r--r--gcc/d/dmd/identifier.d6
-rw-r--r--gcc/d/dmd/imphint.d2
-rw-r--r--gcc/d/dmd/init.d14
-rw-r--r--gcc/d/dmd/intrange.d50
-rw-r--r--gcc/d/dmd/json.d2
-rw-r--r--gcc/d/dmd/lambdacomp.d2
-rw-r--r--gcc/d/dmd/lexer.d2
-rw-r--r--gcc/d/dmd/location.d6
-rw-r--r--gcc/d/dmd/mangle.h8
-rw-r--r--gcc/d/dmd/mtype.d76
-rw-r--r--gcc/d/dmd/mtype.h3
-rw-r--r--gcc/d/dmd/mustuse.d4
-rw-r--r--gcc/d/dmd/nogc.d8
-rw-r--r--gcc/d/dmd/ob.d6
-rw-r--r--gcc/d/dmd/objc.d8
-rw-r--r--gcc/d/dmd/opover.d4
-rw-r--r--gcc/d/dmd/parse.d264
-rw-r--r--gcc/d/dmd/postordervisitor.d2
-rw-r--r--gcc/d/dmd/printast.d2
-rw-r--r--gcc/d/dmd/root/complex.d8
-rw-r--r--gcc/d/dmd/root/filename.d9
-rw-r--r--gcc/d/dmd/root/longdouble.d3
-rw-r--r--gcc/d/dmd/root/rmem.d2
-rw-r--r--gcc/d/dmd/root/utf.d10
-rw-r--r--gcc/d/dmd/sapply.d2
-rw-r--r--gcc/d/dmd/scope.h2
-rw-r--r--gcc/d/dmd/semantic2.d7
-rw-r--r--gcc/d/dmd/semantic3.d10
-rw-r--r--gcc/d/dmd/sideeffect.d4
-rw-r--r--gcc/d/dmd/statement.d126
-rw-r--r--gcc/d/dmd/statement.h1
-rw-r--r--gcc/d/dmd/statementsem.d32
-rw-r--r--gcc/d/dmd/target.d10
-rw-r--r--gcc/d/dmd/templateparamsem.d2
-rw-r--r--gcc/d/dmd/tokens.d2
-rw-r--r--gcc/d/dmd/typesem.d17
-rw-r--r--gcc/d/dmd/visitor.d2
-rw-r--r--gcc/d/intrinsics.cc2
-rw-r--r--gcc/testsuite/gdc.test/compilable/test23145.d14
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/biterrors3.d4
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/bug8891.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/deprecatedinref.d10
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/diag15209.d4
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/diag9451.d11
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/diag9635.d4
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/dip1000_deprecation.d20
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/e15876_6.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail10285.d13
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail11545.d4
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail120.d4
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail142.d5
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail143.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail144.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail145.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail17955.d27
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail20538.d6
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail25.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail301.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail46.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail4923.d8
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail50.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail61.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail66.d4
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail7851.d6
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail9613.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail_scope.d4
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/failcontracts.d17
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/ice15332.d4
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/ice15922.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/ice20056.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/ice7645.d4
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/ice9439.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/misc_parser_err_cov1.d2
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/mixintype2.d8
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/noreturn.d14
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/noreturn2.d13
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/systemvariables.d27
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test13536.d4
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test16365.d4
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test21008.d4
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test9701.d42
-rw-r--r--gcc/testsuite/gdc.test/runnable/aliasthis.d10
-rw-r--r--gcc/testsuite/gdc.test/runnable/complex.d56
-rw-r--r--gcc/testsuite/gdc.test/runnable/interpret.d8
-rw-r--r--gcc/testsuite/gdc.test/runnable/template9.d2
-rw-r--r--gcc/testsuite/gdc.test/runnable/test17684.d10
-rw-r--r--gcc/testsuite/gdc.test/runnable/test19782.d8
-rw-r--r--gcc/testsuite/gdc.test/runnable/test20.d4
-rw-r--r--gcc/testsuite/gdc.test/runnable/test21039.d7
-rw-r--r--gcc/testsuite/gdc.test/runnable/test23234.d7
-rw-r--r--gcc/testsuite/gdc.test/runnable/test3449.d2
-rw-r--r--gcc/testsuite/gdc.test/runnable/test42.d2
-rw-r--r--gcc/testsuite/gdc.test/runnable/testaliascast.d8
-rw-r--r--gcc/testsuite/gdc.test/runnable/testassign.d6
-rw-r--r--gcc/testsuite/gdc.test/runnable/testconst.d6
-rw-r--r--gcc/testsuite/gdc.test/runnable/testswitch.d8
-rw-r--r--gcc/testsuite/gdc.test/runnable/traits_getPointerBitmap.d29
-rw-r--r--gcc/testsuite/gdc.test/runnable/xtest46.d4
-rw-r--r--gcc/testsuite/gdc.test/runnable/xtest46_gc.d4
148 files changed, 1307 insertions, 1294 deletions
diff --git a/gcc/d/d-diagnostic.cc b/gcc/d/d-diagnostic.cc
index 7e5b17c..57f36f2 100644
--- a/gcc/d/d-diagnostic.cc
+++ b/gcc/d/d-diagnostic.cc
@@ -218,139 +218,116 @@ d_diagnostic_report_diagnostic (const Loc &loc, int opt, const char *format,
va_end (argp);
}
-/* Print a hard error message with explicit location LOC with an optional
- message prefix PREFIX1 and PREFIX2, increasing the global or gagged
- error count. */
+/* Print a diagnostic message of type KIND with explicit location LOC with an
+ optional message prefix PREFIX1 and PREFIX2, increasing the global or gagged
+ error count depending on how KIND is treated. */
-void ATTRIBUTE_GCC_DIAG(2,0)
-verror (const Loc &loc, const char *format, va_list ap,
- const char *prefix1, const char *prefix2, const char *)
+void D_ATTRIBUTE_FORMAT(2,0) ATTRIBUTE_GCC_DIAG(2,0)
+verrorReport (const Loc& loc, const char *format, va_list ap, ErrorKind kind,
+ const char *prefix1 = NULL, const char *prefix2 = NULL)
{
- if (!global.gag || global.params.showGaggedErrors)
- {
- char *xformat;
-
- /* Build string and emit. */
- if (prefix2 != NULL)
- xformat = xasprintf ("%s %s %s", escape_d_format (prefix1),
- escape_d_format (prefix2), format);
- else if (prefix1 != NULL)
- xformat = xasprintf ("%s %s", escape_d_format (prefix1), format);
- else
- xformat = xasprintf ("%s", format);
-
- d_diagnostic_report_diagnostic (loc, 0, xformat, ap,
- global.gag ? DK_ANACHRONISM : DK_ERROR,
- false);
- free (xformat);
- }
-
- if (global.gag)
- global.gaggedErrors++;
+ diagnostic_t diag_kind = DK_UNSPECIFIED;
+ int opt = 0;
+ bool verbatim = false;
+ char *xformat;
- global.errors++;
-}
-
-/* Print supplementary message about the last error with explicit location LOC.
- This doesn't increase the global error count. */
+ if (kind == ErrorKind::error)
+ {
+ global.errors++;
+ if (global.gag)
+ global.gaggedErrors++;
-void ATTRIBUTE_GCC_DIAG(2,0)
-verrorSupplemental (const Loc &loc, const char *format, va_list ap)
-{
- if (global.gag && !global.params.showGaggedErrors)
- return;
+ if (global.gag && !global.params.showGaggedErrors)
+ return;
- d_diagnostic_report_diagnostic (loc, 0, format, ap, DK_NOTE, false);
-}
+ diag_kind = global.gag ? DK_ANACHRONISM : DK_ERROR;
+ }
+ else if (kind == ErrorKind::warning)
+ {
+ if (global.gag || global.params.warnings == DIAGNOSTICoff)
+ {
+ if (global.gag)
+ global.gaggedWarnings++;
-/* Print a warning message with explicit location LOC, increasing the
- global warning count. */
+ return;
+ }
-void ATTRIBUTE_GCC_DIAG(2,0)
-vwarning (const Loc &loc, const char *format, va_list ap)
-{
- if (!global.gag && global.params.warnings != DIAGNOSTICoff)
- {
/* Warnings don't count if not treated as errors. */
if (global.params.warnings == DIAGNOSTICerror)
global.warnings++;
- d_diagnostic_report_diagnostic (loc, 0, format, ap, DK_WARNING, false);
+ diag_kind = DK_WARNING;
}
- else if (global.gag)
- global.gaggedWarnings++;
-}
-
-/* Print supplementary message about the last warning with explicit location
- LOC. This doesn't increase the global warning count. */
-
-void ATTRIBUTE_GCC_DIAG(2,0)
-vwarningSupplemental (const Loc &loc, const char *format, va_list ap)
-{
- if (global.params.warnings == DIAGNOSTICoff || global.gag)
- return;
-
- d_diagnostic_report_diagnostic (loc, 0, format, ap, DK_NOTE, false);
-}
+ else if (kind == ErrorKind::deprecation)
+ {
+ if (global.params.useDeprecated == DIAGNOSTICerror)
+ return verrorReport (loc, format, ap, ErrorKind::error, prefix1,
+ prefix2);
+ else if (global.gag || global.params.useDeprecated != DIAGNOSTICinform)
+ {
+ if (global.gag)
+ global.gaggedWarnings++;
-/* Print a deprecation message with explicit location LOC with an optional
- message prefix PREFIX1 and PREFIX2, increasing the global warning or
- error count depending on how deprecations are treated. */
+ return;
+ }
-void ATTRIBUTE_GCC_DIAG(2,0)
-vdeprecation (const Loc &loc, const char *format, va_list ap,
- const char *prefix1, const char *prefix2)
-{
- if (global.params.useDeprecated == DIAGNOSTICerror)
- verror (loc, format, ap, prefix1, prefix2);
- else if (global.params.useDeprecated == DIAGNOSTICinform && !global.gag)
+ opt = OPT_Wdeprecated;
+ diag_kind = DK_WARNING;
+ }
+ else if (kind == ErrorKind::message)
{
- char *xformat;
-
- /* Build string and emit. */
- if (prefix2 != NULL)
- xformat = xasprintf ("%s %s %s", escape_d_format (prefix1),
- escape_d_format (prefix2), format);
- else if (prefix1 != NULL)
- xformat = xasprintf ("%s %s", escape_d_format (prefix1), format);
- else
- xformat = xasprintf ("%s", format);
-
- d_diagnostic_report_diagnostic (loc, OPT_Wdeprecated, xformat, ap,
- DK_WARNING, false);
- free (xformat);
+ diag_kind = DK_NOTE;
+ verbatim = true;
}
- else if (global.gag)
- global.gaggedWarnings++;
-}
-
-/* Print supplementary message about the last deprecation with explicit
- location LOC. This does not increase the global error count. */
+ else if (kind == ErrorKind::tip)
+ {
+ diag_kind = DK_DEBUG;
+ verbatim = true;
+ }
+ else
+ gcc_unreachable ();
+
+ /* Build string and emit. */
+ if (prefix2 != NULL)
+ xformat = xasprintf ("%s %s %s", escape_d_format (prefix1),
+ escape_d_format (prefix2), format);
+ else if (prefix1 != NULL)
+ xformat = xasprintf ("%s %s", escape_d_format (prefix1), format);
+ else
+ xformat = xasprintf ("%s", format);
-void ATTRIBUTE_GCC_DIAG(2,0)
-vdeprecationSupplemental (const Loc &loc, const char *format, va_list ap)
-{
- if (global.params.useDeprecated == DIAGNOSTICerror)
- verrorSupplemental (loc, format, ap);
- else if (global.params.useDeprecated == DIAGNOSTICinform && !global.gag)
- d_diagnostic_report_diagnostic (loc, 0, format, ap, DK_NOTE, false);
+ d_diagnostic_report_diagnostic (loc, opt, xformat, ap, diag_kind, verbatim);
+ free (xformat);
}
-/* Print a verbose message with explicit location LOC. */
+/* Print supplementary message about the last diagnostic of type KIND, with
+ explicit location LOC. This doesn't increase the global error count. */
-void ATTRIBUTE_GCC_DIAG(2,0)
-vmessage (const Loc &loc, const char *format, va_list ap)
+void D_ATTRIBUTE_FORMAT(2,0) ATTRIBUTE_GCC_DIAG(2,0)
+verrorReportSupplemental (const Loc& loc, const char* format, va_list ap,
+ ErrorKind kind)
{
- d_diagnostic_report_diagnostic (loc, 0, format, ap, DK_NOTE, true);
-}
-
-/* Print a tip message with prefix and highlighing. */
+ if (kind == ErrorKind::error)
+ {
+ if (global.gag && !global.params.showGaggedErrors)
+ return;
+ }
+ else if (kind == ErrorKind::warning)
+ {
+ if (global.params.warnings == DIAGNOSTICoff || global.gag)
+ return;
+ }
+ else if (kind == ErrorKind::deprecation)
+ {
+ if (global.params.useDeprecated == DIAGNOSTICerror)
+ return verrorReportSupplemental (loc, format, ap, ErrorKind::error);
+ else if (global.params.useDeprecated != DIAGNOSTICinform || global.gag)
+ return;
+ }
+ else
+ gcc_unreachable ();
-void ATTRIBUTE_GCC_DIAG(1,0)
-vtip (const char *format, va_list ap)
-{
- if (!global.gag)
- d_diagnostic_report_diagnostic (Loc (), 0, format, ap, DK_DEBUG, true);
+ d_diagnostic_report_diagnostic (loc, 0, format, ap, DK_NOTE, false);
}
/* Call this after printing out fatal error messages to clean up and
diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc
index 10b9000..7dddcf5 100644
--- a/gcc/d/d-lang.cc
+++ b/gcc/d/d-lang.cc
@@ -1101,7 +1101,7 @@ d_parse_file (void)
if (m->filetype == FileType::ddoc)
{
- gendocfile (m);
+ gendocfile (m, global.errorSink);
/* Remove M from list of modules. */
modules.remove (i);
i--;
@@ -1256,7 +1256,7 @@ d_parse_file (void)
/* Declare the name of the root module as the first global name in order
to make the middle-end fully deterministic. */
OutBuffer buf;
- mangleToBuffer (Module::rootModule, &buf);
+ mangleToBuffer (Module::rootModule, buf);
first_global_object_name = buf.extractChars ();
}
@@ -1337,7 +1337,7 @@ d_parse_file (void)
for (size_t i = 0; i < modules.length; i++)
{
Module *m = modules[i];
- gendocfile (m);
+ gendocfile (m, global.errorSink);
}
}
diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index b866593..7e612e1 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -73,7 +73,7 @@ d_mangle_decl (Dsymbol *decl)
else
{
OutBuffer buf;
- mangleToBuffer (decl, &buf);
+ mangleToBuffer (decl, buf);
return buf.extractChars ();
}
}
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index a02a8cb..dc26778 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-26f049fb26e755096dea3f1474decea7c0fef187
+4574d1728d1f7e52ff40e6733b8c39889d128349
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/d/dmd/README.md b/gcc/d/dmd/README.md
index 4fd7831..d0c75a5b 100644
--- a/gcc/d/dmd/README.md
+++ b/gcc/d/dmd/README.md
@@ -31,7 +31,8 @@ Note that these groups have no strict meaning, the category assignments are a bi
| File | Purpose |
|-----------------------------------------------------------------------------|-----------------------------------------------------------------------|
-| [mars.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/mars.d) | The entry point. Contains `main`. |
+| [main.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/main.d) | The entry point. Contains `main`. |
+| [mars.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/mars.d) | Argument parsing, path manipulation. |
| [cli.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/cli.d) | Define the command line interface |
| [dmdparams.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/dmdparams.d) | DMD-specific parameters |
| [globals.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/globals.d) | Define a structure storing command line options |
diff --git a/gcc/d/dmd/VERSION b/gcc/d/dmd/VERSION
index 6faa8d8..8012337 100644
--- a/gcc/d/dmd/VERSION
+++ b/gcc/d/dmd/VERSION
@@ -1 +1 @@
-v2.105.0-beta.1
+v2.105.0
diff --git a/gcc/d/dmd/access.d b/gcc/d/dmd/access.d
index 668129a..ab9b5d9 100644
--- a/gcc/d/dmd/access.d
+++ b/gcc/d/dmd/access.d
@@ -21,7 +21,6 @@ import dmd.dscope;
import dmd.dstruct;
import dmd.dsymbol;
import dmd.expression;
-import dmd.globals;
import dmd.location;
import dmd.tokens;
diff --git a/gcc/d/dmd/aggregate.d b/gcc/d/dmd/aggregate.d
index 42b926b..4ae6b6b 100644
--- a/gcc/d/dmd/aggregate.d
+++ b/gcc/d/dmd/aggregate.d
@@ -64,7 +64,7 @@ enum ClassKind : ubyte
* Returns:
* 0-terminated string for `c`
*/
-const(char)* toChars(ClassKind c)
+const(char)* toChars(ClassKind c) @safe
{
final switch (c)
{
diff --git a/gcc/d/dmd/aliasthis.d b/gcc/d/dmd/aliasthis.d
index ce38459..a8933f6 100644
--- a/gcc/d/dmd/aliasthis.d
+++ b/gcc/d/dmd/aliasthis.d
@@ -23,7 +23,6 @@ import dmd.globals;
import dmd.identifier;
import dmd.location;
import dmd.mtype;
-import dmd.opover;
import dmd.tokens;
import dmd.visitor;
@@ -38,7 +37,7 @@ extern (C++) final class AliasThis : Dsymbol
/// Whether this `alias this` is deprecated or not
bool isDeprecated_;
- extern (D) this(const ref Loc loc, Identifier ident)
+ extern (D) this(const ref Loc loc, Identifier ident) @safe
{
super(loc, null); // it's anonymous (no identifier)
this.ident = ident;
diff --git a/gcc/d/dmd/arrayop.d b/gcc/d/dmd/arrayop.d
index 908855e..d843073 100644
--- a/gcc/d/dmd/arrayop.d
+++ b/gcc/d/dmd/arrayop.d
@@ -22,14 +22,12 @@ import dmd.dsymbol;
import dmd.expression;
import dmd.expressionsem;
import dmd.func;
-import dmd.globals;
import dmd.hdrgen;
import dmd.id;
import dmd.identifier;
import dmd.location;
import dmd.mtype;
import dmd.common.outbuffer;
-import dmd.statement;
import dmd.tokens;
import dmd.visitor;
@@ -194,7 +192,7 @@ private Expressions* buildArrayOp(Scope* sc, Expression e, Objects* tiargs)
Expressions* args;
public:
- extern (D) this(Scope* sc, Objects* tiargs) scope
+ extern (D) this(Scope* sc, Objects* tiargs) scope @safe
{
this.sc = sc;
this.tiargs = tiargs;
@@ -276,7 +274,7 @@ bool isArrayOpImplicitCast(TypeDArray tfrom, TypeDArray tto)
/***********************************************
* Test if expression is a unary array op.
*/
-bool isUnaArrayOp(EXP op)
+bool isUnaArrayOp(EXP op) @safe
{
switch (op)
{
@@ -292,7 +290,7 @@ bool isUnaArrayOp(EXP op)
/***********************************************
* Test if expression is a binary array op.
*/
-bool isBinArrayOp(EXP op)
+bool isBinArrayOp(EXP op) @safe
{
switch (op)
{
@@ -315,7 +313,7 @@ bool isBinArrayOp(EXP op)
/***********************************************
* Test if expression is a binary assignment array op.
*/
-bool isBinAssignArrayOp(EXP op)
+bool isBinAssignArrayOp(EXP op) @safe
{
switch (op)
{
diff --git a/gcc/d/dmd/attrib.d b/gcc/d/dmd/attrib.d
index ff4ebe8..baabe93 100644
--- a/gcc/d/dmd/attrib.d
+++ b/gcc/d/dmd/attrib.d
@@ -45,7 +45,6 @@ import dmd.mtype;
import dmd.objc; // for objc.addSymbols
import dmd.common.outbuffer;
import dmd.root.array; // for each
-import dmd.tokens;
import dmd.visitor;
/***********************************************************
@@ -57,18 +56,18 @@ extern (C++) abstract class AttribDeclaration : Dsymbol
{
Dsymbols* decl; /// Dsymbol's affected by this AttribDeclaration
- extern (D) this(Dsymbols* decl)
+ extern (D) this(Dsymbols* decl) @safe
{
this.decl = decl;
}
- extern (D) this(const ref Loc loc, Dsymbols* decl)
+ extern (D) this(const ref Loc loc, Dsymbols* decl) @safe
{
super(loc, null);
this.decl = decl;
}
- extern (D) this(const ref Loc loc, Identifier ident, Dsymbols* decl)
+ extern (D) this(const ref Loc loc, Identifier ident, Dsymbols* decl) @safe
{
super(loc, ident);
this.decl = decl;
@@ -228,13 +227,13 @@ extern (C++) class StorageClassDeclaration : AttribDeclaration
{
StorageClass stc;
- extern (D) this(StorageClass stc, Dsymbols* decl)
+ extern (D) this(StorageClass stc, Dsymbols* decl) @safe
{
super(decl);
this.stc = stc;
}
- extern (D) this(const ref Loc loc, StorageClass stc, Dsymbols* decl)
+ extern (D) this(const ref Loc loc, StorageClass stc, Dsymbols* decl) @safe
{
super(loc, decl);
this.stc = stc;
@@ -347,7 +346,7 @@ extern (C++) final class DeprecatedDeclaration : StorageClassDeclaration
Expression msg; /// deprecation message
const(char)* msgstr; /// cached string representation of msg
- extern (D) this(Expression msg, Dsymbols* decl)
+ extern (D) this(Expression msg, Dsymbols* decl) @safe
{
super(STC.deprecated_, decl);
this.msg = msg;
@@ -402,14 +401,14 @@ extern (C++) final class LinkDeclaration : AttribDeclaration
{
LINK linkage; /// either explicitly set or `default_`
- extern (D) this(const ref Loc loc, LINK linkage, Dsymbols* decl)
+ extern (D) this(const ref Loc loc, LINK linkage, Dsymbols* decl) @safe
{
super(loc, null, decl);
//printf("LinkDeclaration(linkage = %d, decl = %p)\n", linkage, decl);
this.linkage = linkage;
}
- static LinkDeclaration create(const ref Loc loc, LINK p, Dsymbols* decl)
+ static LinkDeclaration create(const ref Loc loc, LINK p, Dsymbols* decl) @safe
{
return new LinkDeclaration(loc, p, decl);
}
@@ -454,7 +453,7 @@ extern (C++) final class CPPMangleDeclaration : AttribDeclaration
{
CPPMANGLE cppmangle;
- extern (D) this(const ref Loc loc, CPPMANGLE cppmangle, Dsymbols* decl)
+ extern (D) this(const ref Loc loc, CPPMANGLE cppmangle, Dsymbols* decl) @safe
{
super(loc, null, decl);
//printf("CPPMangleDeclaration(cppmangle = %d, decl = %p)\n", cppmangle, decl);
@@ -524,19 +523,19 @@ extern (C++) final class CPPNamespaceDeclaration : AttribDeclaration
/// CTFE-able expression, resolving to `TupleExp` or `StringExp`
Expression exp;
- extern (D) this(const ref Loc loc, Identifier ident, Dsymbols* decl)
+ extern (D) this(const ref Loc loc, Identifier ident, Dsymbols* decl) @safe
{
super(loc, ident, decl);
}
- extern (D) this(const ref Loc loc, Expression exp, Dsymbols* decl)
+ extern (D) this(const ref Loc loc, Expression exp, Dsymbols* decl) @safe
{
super(loc, null, decl);
this.exp = exp;
}
extern (D) this(const ref Loc loc, Identifier ident, Expression exp, Dsymbols* decl,
- CPPNamespaceDeclaration parent)
+ CPPNamespaceDeclaration parent) @safe
{
super(loc, ident, decl);
this.exp = exp;
@@ -597,7 +596,7 @@ extern (C++) final class VisibilityDeclaration : AttribDeclaration
* visibility = visibility attribute data
* decl = declarations which are affected by this visibility attribute
*/
- extern (D) this(const ref Loc loc, Visibility visibility, Dsymbols* decl)
+ extern (D) this(const ref Loc loc, Visibility visibility, Dsymbols* decl) @safe
{
super(loc, null, decl);
this.visibility = visibility;
@@ -720,13 +719,13 @@ extern (C++) final class AlignDeclaration : AttribDeclaration
}
}
- extern (D) this(const ref Loc loc, Expressions* exps, Dsymbols* decl)
+ extern (D) this(const ref Loc loc, Expressions* exps, Dsymbols* decl) @safe
{
super(loc, null, decl);
this.exps = exps;
}
- extern (D) this(const ref Loc loc, structalign_t salign, Dsymbols* decl)
+ extern (D) this(const ref Loc loc, structalign_t salign, Dsymbols* decl) @safe
{
super(loc, null, decl);
this.salign = salign;
@@ -762,7 +761,7 @@ extern (C++) final class AnonDeclaration : AttribDeclaration
uint anonstructsize; /// size of anonymous struct
uint anonalignsize; /// size of anonymous struct for alignment purposes
- extern (D) this(const ref Loc loc, bool isunion, Dsymbols* decl)
+ extern (D) this(const ref Loc loc, bool isunion, Dsymbols* decl) @safe
{
super(loc, null, decl);
this.isunion = isunion;
@@ -882,7 +881,7 @@ extern (C++) final class PragmaDeclaration : AttribDeclaration
{
Expressions* args; /// parameters of this pragma
- extern (D) this(const ref Loc loc, Identifier ident, Expressions* args, Dsymbols* decl)
+ extern (D) this(const ref Loc loc, Identifier ident, Expressions* args, Dsymbols* decl) @safe
{
super(loc, ident, decl);
this.args = args;
@@ -928,7 +927,7 @@ extern (C++) class ConditionalDeclaration : AttribDeclaration
Condition condition; /// condition deciding whether decl or elsedecl applies
Dsymbols* elsedecl; /// array of Dsymbol's for else block
- extern (D) this(const ref Loc loc, Condition condition, Dsymbols* decl, Dsymbols* elsedecl)
+ extern (D) this(const ref Loc loc, Condition condition, Dsymbols* decl, Dsymbols* elsedecl) @safe
{
super(loc, null, decl);
//printf("ConditionalDeclaration::ConditionalDeclaration()\n");
@@ -1006,7 +1005,7 @@ extern (C++) final class StaticIfDeclaration : ConditionalDeclaration
private bool addisdone = false; /// true if members have been added to scope
private bool onStack = false; /// true if a call to `include` is currently active
- extern (D) this(const ref Loc loc, Condition condition, Dsymbols* decl, Dsymbols* elsedecl)
+ extern (D) this(const ref Loc loc, Condition condition, Dsymbols* decl, Dsymbols* elsedecl) @safe
{
super(loc, condition, decl, elsedecl);
//printf("StaticIfDeclaration::StaticIfDeclaration()\n");
@@ -1120,7 +1119,7 @@ extern (C++) final class StaticForeachDeclaration : AttribDeclaration
bool cached = false;
Dsymbols* cache = null;
- extern (D) this(StaticForeach sfe, Dsymbols* decl)
+ extern (D) this(StaticForeach sfe, Dsymbols* decl) @safe
{
super(sfe.loc, null, decl);
this.sfe = sfe;
@@ -1251,7 +1250,7 @@ extern(C++) final class ForwardingAttribDeclaration : AttribDeclaration
{
ForwardingScopeDsymbol sym = null;
- this(Dsymbols* decl)
+ this(Dsymbols* decl) @safe
{
super(decl);
sym = new ForwardingScopeDsymbol();
@@ -1299,7 +1298,7 @@ extern (C++) final class MixinDeclaration : AttribDeclaration
ScopeDsymbol scopesym;
bool compiled;
- extern (D) this(const ref Loc loc, Expressions* exps)
+ extern (D) this(const ref Loc loc, Expressions* exps) @safe
{
super(loc, null, null);
//printf("MixinDeclaration(loc = %d)\n", loc.linnum);
@@ -1348,7 +1347,7 @@ extern (C++) final class UserAttributeDeclaration : AttribDeclaration
{
Expressions* atts;
- extern (D) this(Expressions* atts, Dsymbols* decl)
+ extern (D) this(Expressions* atts, Dsymbols* decl) @safe
{
super(decl);
this.atts = atts;
diff --git a/gcc/d/dmd/blockexit.d b/gcc/d/dmd/blockexit.d
index db738b4..bdc81f2 100644
--- a/gcc/d/dmd/blockexit.d
+++ b/gcc/d/dmd/blockexit.d
@@ -27,7 +27,6 @@ import dmd.location;
import dmd.mtype;
import dmd.statement;
import dmd.tokens;
-import dmd.visitor;
/**
* BE stands for BlockExit.
diff --git a/gcc/d/dmd/canthrow.d b/gcc/d/dmd/canthrow.d
index 89d5519..ba13eb0 100644
--- a/gcc/d/dmd/canthrow.d
+++ b/gcc/d/dmd/canthrow.d
@@ -26,7 +26,6 @@ import dmd.globals;
import dmd.init;
import dmd.mtype;
import dmd.postordervisitor;
-import dmd.root.rootobject;
import dmd.tokens;
import dmd.visitor;
@@ -63,7 +62,7 @@ extern (C++) /* CT */ BE canThrow(Expression e, FuncDeclaration func, bool mustN
CT result;
public:
- extern (D) this(FuncDeclaration func, bool mustNotThrow) scope
+ extern (D) this(FuncDeclaration func, bool mustNotThrow) scope @safe
{
this.func = func;
this.mustNotThrow = mustNotThrow;
diff --git a/gcc/d/dmd/common/file.d b/gcc/d/dmd/common/file.d
index ae13c41..076f357 100644
--- a/gcc/d/dmd/common/file.d
+++ b/gcc/d/dmd/common/file.d
@@ -27,6 +27,14 @@ import dmd.common.string;
nothrow:
+version (Windows)
+{
+ import core.sys.windows.winnls : CP_ACP;
+
+ // assume filenames encoded in system default Windows ANSI code page
+ enum CodePage = CP_ACP;
+}
+
/**
Encapsulated management of a memory-mapped file.
diff --git a/gcc/d/dmd/common/outbuffer.d b/gcc/d/dmd/common/outbuffer.d
index 007d301..b8ad785 100644
--- a/gcc/d/dmd/common/outbuffer.d
+++ b/gcc/d/dmd/common/outbuffer.d
@@ -61,7 +61,7 @@ struct OutBuffer
/**
Construct given size.
*/
- this(size_t initialSize) nothrow
+ this(size_t initialSize) nothrow @safe
{
reserve(initialSize);
}
@@ -527,7 +527,7 @@ struct OutBuffer
* Returns:
* slice of the allocated space to be filled in
*/
- extern (D) char[] allocate(size_t nbytes) pure nothrow
+ extern (D) char[] allocate(size_t nbytes) pure nothrow @safe
{
reserve(nbytes);
offset += nbytes;
@@ -711,8 +711,14 @@ struct OutBuffer
return cast(char*)data.ptr;
}
+ // Peek at slice of data without taking ownership
+ extern (D) ubyte[] peekSlice() pure nothrow
+ {
+ return data[0 .. offset];
+ }
+
// Append terminating null if necessary and take ownership of data
- extern (C++) char* extractChars() pure nothrow
+ extern (C++) char* extractChars() pure nothrow @safe
{
if (!offset || data[offset - 1] != '\0')
writeByte(0);
diff --git a/gcc/d/dmd/common/string.d b/gcc/d/dmd/common/string.d
index 6de921e..9453a34 100644
--- a/gcc/d/dmd/common/string.d
+++ b/gcc/d/dmd/common/string.d
@@ -135,9 +135,8 @@ but is guaranteed to follow it.
*/
version(Windows) wchar[] toWStringz(const(char)[] narrow, ref SmallBuffer!wchar buffer) nothrow
{
- import core.sys.windows.winnls : CP_ACP, MultiByteToWideChar;
- // assume filenames encoded in system default Windows ANSI code page
- enum CodePage = CP_ACP;
+ import core.sys.windows.winnls : MultiByteToWideChar;
+ import dmd.common.file : CodePage;
if (narrow is null)
return null;
diff --git a/gcc/d/dmd/cond.d b/gcc/d/dmd/cond.d
index 467f9f1..360acf5 100644
--- a/gcc/d/dmd/cond.d
+++ b/gcc/d/dmd/cond.d
@@ -62,7 +62,7 @@ extern (C++) abstract class Condition : ASTNode
return DYNCAST.condition;
}
- extern (D) this(const ref Loc loc)
+ extern (D) this(const ref Loc loc) @safe
{
this.loc = loc;
}
@@ -124,7 +124,7 @@ extern (C++) final class StaticForeach : RootObject
*/
bool needExpansion = false;
- extern (D) this(const ref Loc loc, ForeachStatement aggrfe, ForeachRangeStatement rangefe)
+ extern (D) this(const ref Loc loc, ForeachStatement aggrfe, ForeachRangeStatement rangefe) @safe
{
assert(!!aggrfe ^ !!rangefe);
@@ -279,7 +279,7 @@ extern (C++) final class StaticForeach : RootObject
* An AST for the expression `Tuple(e)`.
*/
- private extern(D) Expression createTuple(const ref Loc loc, TypeStruct type, Expressions* e)
+ private extern(D) Expression createTuple(const ref Loc loc, TypeStruct type, Expressions* e) @safe
{ // TODO: move to druntime?
return new CallExp(loc, new TypeExp(loc, type), e);
}
@@ -496,7 +496,7 @@ extern (C++) class DVCondition : Condition
Identifier ident;
Module mod;
- extern (D) this(const ref Loc loc, Module mod, uint level, Identifier ident)
+ extern (D) this(const ref Loc loc, Module mod, uint level, Identifier ident) @safe
{
super(loc);
this.mod = mod;
@@ -563,7 +563,7 @@ extern (C++) final class DebugCondition : DVCondition
* If `null`, this conditiion will use an integer level.
* loc = Location in the source file
*/
- extern (D) this(const ref Loc loc, Module mod, uint level, Identifier ident)
+ extern (D) this(const ref Loc loc, Module mod, uint level, Identifier ident) @safe
{
super(loc, mod, level, ident);
}
@@ -637,7 +637,7 @@ extern (C++) final class VersionCondition : DVCondition
* Returns:
* `true` if it is reserved, `false` otherwise
*/
- extern(D) private static bool isReserved(const(char)[] ident)
+ extern(D) private static bool isReserved(const(char)[] ident) @safe
{
// This list doesn't include "D_*" versions, see the last return
switch (ident)
@@ -840,7 +840,7 @@ extern (C++) final class VersionCondition : DVCondition
* If `null`, this conditiion will use an integer level.
* loc = Location in the source file
*/
- extern (D) this(const ref Loc loc, Module mod, uint level, Identifier ident)
+ extern (D) this(const ref Loc loc, Module mod, uint level, Identifier ident) @safe
{
super(loc, mod, level, ident);
}
@@ -902,7 +902,7 @@ extern (C++) final class StaticIfCondition : Condition
{
Expression exp;
- extern (D) this(const ref Loc loc, Expression exp)
+ extern (D) this(const ref Loc loc, Expression exp) @safe
{
super(loc);
this.exp = exp;
diff --git a/gcc/d/dmd/constfold.d b/gcc/d/dmd/constfold.d
index 415606b..e5526a1 100644
--- a/gcc/d/dmd/constfold.d
+++ b/gcc/d/dmd/constfold.d
@@ -52,7 +52,7 @@ private Expression expType(Type type, Expression e)
* Returns:
* true if e is a constant
*/
-int isConst(Expression e)
+int isConst(Expression e) @safe
{
//printf("Expression::isConst(): %s\n", e.toChars());
switch (e.op)
@@ -1286,7 +1286,7 @@ UnionExp Slice(Type type, Expression e1, Expression lwr, Expression upr)
/* Check whether slice `[newlwr .. newupr]` is in the range `[lwr .. upr]`
*/
-bool sliceBoundsCheck(uinteger_t lwr, uinteger_t upr, uinteger_t newlwr, uinteger_t newupr) pure
+bool sliceBoundsCheck(uinteger_t lwr, uinteger_t upr, uinteger_t newlwr, uinteger_t newupr) pure @safe
{
assert(lwr <= upr);
return !(newlwr <= newupr &&
diff --git a/gcc/d/dmd/cppmangle.d b/gcc/d/dmd/cppmangle.d
index ee1340d..5d74ec4 100644
--- a/gcc/d/dmd/cppmangle.d
+++ b/gcc/d/dmd/cppmangle.d
@@ -139,7 +139,7 @@ private struct Context
* Returns:
* The previous state of this `Context` object
*/
- private Context push(lazy RootObject next)
+ private Context push(lazy RootObject next) @safe
{
auto r = this.res;
if (r !is null)
@@ -150,7 +150,7 @@ private struct Context
/**
* Reset the context to a previous one, making any adjustment necessary
*/
- private void pop(ref Context prev)
+ private void pop(ref Context prev) @safe
{
this.res = prev.res;
}
@@ -236,7 +236,7 @@ private final class CppMangleVisitor : Visitor
* See-Also:
* https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.seq-id
*/
- private void writeSequenceFromIndex(size_t idx)
+ private void writeSequenceFromIndex(size_t idx) @safe
{
if (idx)
{
@@ -1597,7 +1597,7 @@ private final class CppMangleVisitor : Visitor
* or `params.length` if there wasn't any match.
*/
private static size_t templateParamIndex(
- const ref Identifier ident, TemplateParameters* params)
+ const ref Identifier ident, TemplateParameters* params) @safe
{
foreach (idx, param; *params)
if (param.ident == ident)
@@ -2131,7 +2131,7 @@ private void visitObject(V : Visitor)(RootObject o, V this_)
}
/// Helper function to safely get a type out of a `RootObject`
-private Type asType(RootObject o)
+private Type asType(RootObject o) @safe
{
if (Type ta = isType(o))
return ta;
@@ -2143,7 +2143,7 @@ private Type asType(RootObject o)
}
/// Helper function to safely get a `FuncDeclaration` out of a `RootObject`
-private FuncDeclaration asFuncDecl(RootObject o)
+private FuncDeclaration asFuncDecl(RootObject o) @safe
{
Dsymbol d = isDsymbol(o);
assert(d !is null);
@@ -2177,7 +2177,7 @@ private extern(C++) final class ComponentVisitor : Visitor
/// Set to the result of the comparison
private bool result;
- public this(RootObject base)
+ public this(RootObject base) @safe
{
switch (base.dyncast())
{
@@ -2353,7 +2353,7 @@ private bool isNamespaceEqual (CPPNamespaceDeclaration a, Nspace b, size_t idx =
/// Returns:
/// Whether two `CPPNamespaceDeclaration` are equals
-private bool isNamespaceEqual (CPPNamespaceDeclaration a, CPPNamespaceDeclaration b)
+private bool isNamespaceEqual (CPPNamespaceDeclaration a, CPPNamespaceDeclaration b) @safe
{
if (a is null || b is null)
return false;
@@ -2558,7 +2558,7 @@ void leftOver(TypeFunction tf, const(Array!StringExp)* previous, Array!StringExp
private const(Array!StringExp)* ignore;
///
- public this(const(Array!StringExp)* previous, Array!StringExp* toWrite)
+ public this(const(Array!StringExp)* previous, Array!StringExp* toWrite) @safe
{
this.ignore = previous;
this.toWrite = toWrite;
diff --git a/gcc/d/dmd/ctfeexpr.d b/gcc/d/dmd/ctfeexpr.d
index 289ebeb..d355538 100644
--- a/gcc/d/dmd/ctfeexpr.d
+++ b/gcc/d/dmd/ctfeexpr.d
@@ -45,7 +45,7 @@ extern (C++) final class ClassReferenceExp : Expression
{
StructLiteralExp value;
- extern (D) this(const ref Loc loc, StructLiteralExp lit, Type type)
+ extern (D) this(const ref Loc loc, StructLiteralExp lit, Type type) @safe
{
super(loc, EXP.classReference);
assert(lit && lit.sd && lit.sd.isClassDeclaration());
@@ -112,7 +112,7 @@ extern (C++) final class ClassReferenceExp : Expression
* Returns:
* index of the field, or -1 if not found
*/
-int findFieldIndexByName(const StructDeclaration sd, const VarDeclaration v) pure
+int findFieldIndexByName(const StructDeclaration sd, const VarDeclaration v) pure @safe
{
foreach (i, field; sd.fields)
{
@@ -130,7 +130,7 @@ extern (C++) final class ThrownExceptionExp : Expression
{
ClassReferenceExp thrown; // the thing being tossed
- extern (D) this(const ref Loc loc, ClassReferenceExp victim)
+ extern (D) this(const ref Loc loc, ClassReferenceExp victim) @safe
{
super(loc, EXP.thrownException);
this.thrown = victim;
@@ -205,19 +205,19 @@ extern (C++) final class CTFEExp : Expression
*/
extern (D) __gshared CTFEExp showcontext;
- extern (D) static bool isCantExp(const Expression e)
+ extern (D) static bool isCantExp(const Expression e) @safe
{
return e && e.op == EXP.cantExpression;
}
- extern (D) static bool isGotoExp(const Expression e)
+ extern (D) static bool isGotoExp(const Expression e) @safe
{
return e && e.op == EXP.goto_;
}
}
// True if 'e' is CTFEExp::cantexp, or an exception
-bool exceptionOrCantInterpret(const Expression e)
+bool exceptionOrCantInterpret(const Expression e) @safe
{
return e && (e.op == EXP.cantExpression || e.op == EXP.thrownException || e.op == EXP.showCtfeContext);
}
@@ -1068,25 +1068,25 @@ private bool numCmp(N)(EXP op, N n1, N n2)
}
/// Returns cmp OP 0; where OP is ==, !=, <, >=, etc. Result is 0 or 1
-bool specificCmp(EXP op, int rawCmp)
+bool specificCmp(EXP op, int rawCmp) @safe
{
return numCmp!int(op, rawCmp, 0);
}
/// Returns e1 OP e2; where OP is ==, !=, <, >=, etc. Result is 0 or 1
-bool intUnsignedCmp(EXP op, dinteger_t n1, dinteger_t n2)
+bool intUnsignedCmp(EXP op, dinteger_t n1, dinteger_t n2) @safe
{
return numCmp!dinteger_t(op, n1, n2);
}
/// Returns e1 OP e2; where OP is ==, !=, <, >=, etc. Result is 0 or 1
-bool intSignedCmp(EXP op, sinteger_t n1, sinteger_t n2)
+bool intSignedCmp(EXP op, sinteger_t n1, sinteger_t n2) @safe
{
return numCmp!sinteger_t(op, n1, n2);
}
/// Returns e1 OP e2; where OP is ==, !=, <, >=, etc. Result is 0 or 1
-bool realCmp(EXP op, real_t r1, real_t r2)
+bool realCmp(EXP op, real_t r1, real_t r2) @safe
{
// Don't rely on compiler, handle NAN arguments separately
if (CTFloat.isNaN(r1) || CTFloat.isNaN(r2)) // if unordered
@@ -1176,7 +1176,7 @@ private int ctfeCmpArrays(const ref Loc loc, Expression e1, Expression e2, uinte
/* Given a delegate expression e, return .funcptr.
* If e is NullExp, return NULL.
*/
-private FuncDeclaration funcptrOf(Expression e)
+private FuncDeclaration funcptrOf(Expression e) @safe
{
assert(e.type.ty == Tdelegate);
if (auto de = e.isDelegateExp())
@@ -1187,7 +1187,7 @@ private FuncDeclaration funcptrOf(Expression e)
return null;
}
-private bool isArray(const Expression e)
+private bool isArray(const Expression e) @safe
{
return e.op == EXP.arrayLiteral || e.op == EXP.string_ || e.op == EXP.slice || e.op == EXP.null_;
}
diff --git a/gcc/d/dmd/ctorflow.d b/gcc/d/dmd/ctorflow.d
index a3953af..128c698 100644
--- a/gcc/d/dmd/ctorflow.d
+++ b/gcc/d/dmd/ctorflow.d
@@ -71,7 +71,7 @@ struct CtorFlow
* Params:
* csx = bits to set
*/
- void orCSX(CSX csx) nothrow pure
+ void orCSX(CSX csx) nothrow pure @safe
{
callSuper |= csx;
foreach (ref u; fieldinit)
@@ -83,7 +83,7 @@ struct CtorFlow
* Params:
* ctorflow = bits to OR in
*/
- void OR(const ref CtorFlow ctorflow) pure nothrow
+ void OR(const ref CtorFlow ctorflow) pure nothrow @safe
{
callSuper |= ctorflow.callSuper;
if (fieldinit.length && ctorflow.fieldinit.length)
@@ -109,7 +109,7 @@ struct CtorFlow
* Returns:
* false means one of the paths skips construction
*/
-bool mergeCallSuper(ref CSX a, const CSX b) pure nothrow
+bool mergeCallSuper(ref CSX a, const CSX b) pure nothrow @safe
{
// This does a primitive flow analysis to support the restrictions
// regarding when and how constructors can appear.
@@ -172,7 +172,7 @@ bool mergeCallSuper(ref CSX a, const CSX b) pure nothrow
* Returns:
* false means either `a` or `b` skips initialization
*/
-bool mergeFieldInit(ref CSX a, const CSX b) pure nothrow
+bool mergeFieldInit(ref CSX a, const CSX b) pure nothrow @safe
{
if (b == a)
return true;
diff --git a/gcc/d/dmd/dclass.d b/gcc/d/dmd/dclass.d
index 1b8e8ef..20cb82e 100644
--- a/gcc/d/dmd/dclass.d
+++ b/gcc/d/dmd/dclass.d
@@ -1130,7 +1130,7 @@ extern (C++) final class InterfaceDeclaration : ClassDeclaration
* Returns:
* true if the `bc` implements `id`, false otherwise
**/
-private bool baseClassImplementsInterface(InterfaceDeclaration id, BaseClass* bc, int* poffset) pure nothrow @nogc
+private bool baseClassImplementsInterface(InterfaceDeclaration id, BaseClass* bc, int* poffset) pure nothrow @nogc @safe
{
//printf("%s.InterfaceDeclaration.isBaseOf(bc = '%s')\n", id.toChars(), bc.sym.toChars());
for (size_t j = 0; j < bc.baseInterfaces.length; j++)
diff --git a/gcc/d/dmd/declaration.d b/gcc/d/dmd/declaration.d
index 5559b93..8a91a80 100644
--- a/gcc/d/dmd/declaration.d
+++ b/gcc/d/dmd/declaration.d
@@ -188,6 +188,15 @@ bool modifyFieldVar(Loc loc, Scope* sc, VarDeclaration var, Expression e1)
MODtoChars(var.type.mod), var.kind(), var.toChars());
errorSupplemental(loc, "Use `shared static this` instead.");
}
+ else if (fd.isStaticCtorDeclaration() && !fd.isSharedStaticCtorDeclaration() &&
+ var.type.isConst())
+ {
+ // @@@DEPRECATED_2.116@@@
+ // Turn this into an error, merging with the branch above
+ .deprecation(loc, "%s %s `%s` initialization is not allowed in `static this`",
+ MODtoChars(var.type.mod), var.kind(), var.toChars());
+ deprecationSupplemental(loc, "Use `shared static this` instead.");
+ }
return result;
}
else
@@ -242,13 +251,13 @@ extern (C++) abstract class Declaration : Dsymbol
// overridden symbol with pragma(mangle, "...")
const(char)[] mangleOverride;
- final extern (D) this(Identifier ident)
+ final extern (D) this(Identifier ident) @safe
{
super(ident);
visibility = Visibility(Visibility.Kind.undefined);
}
- final extern (D) this(const ref Loc loc, Identifier ident)
+ final extern (D) this(const ref Loc loc, Identifier ident) @safe
{
super(loc, ident);
visibility = Visibility(Visibility.Kind.undefined);
@@ -586,7 +595,7 @@ extern (C++) final class TupleDeclaration : Declaration
bool isexp; // true: expression tuple
bool building; // it's growing in AliasAssign semantic
- extern (D) this(const ref Loc loc, Identifier ident, Objects* objects)
+ extern (D) this(const ref Loc loc, Identifier ident, Objects* objects) @safe
{
super(loc, ident);
this.objects = objects;
@@ -617,7 +626,7 @@ extern (C++) final class TupleDeclaration : Declaration
for (size_t i = 0; i < objects.length; i++)
{
RootObject o = (*objects)[i];
- if (o.dyncast() != DYNCAST.type)
+ if (!o.isType())
{
//printf("\tnot[%d], %p, %d\n", i, o, o.dyncast());
return null;
@@ -737,7 +746,7 @@ extern (C++) final class AliasDeclaration : Declaration
Dsymbol overnext; // next in overload list
Dsymbol _import; // !=null if unresolved internal alias for selective import
- extern (D) this(const ref Loc loc, Identifier ident, Type type)
+ extern (D) this(const ref Loc loc, Identifier ident, Type type) @safe
{
super(loc, ident);
//printf("AliasDeclaration(id = '%s', type = %p)\n", ident.toChars(), type);
@@ -746,7 +755,7 @@ extern (C++) final class AliasDeclaration : Declaration
assert(type);
}
- extern (D) this(const ref Loc loc, Identifier ident, Dsymbol s)
+ extern (D) this(const ref Loc loc, Identifier ident, Dsymbol s) @safe
{
super(loc, ident);
//printf("AliasDeclaration(id = '%s', s = %p)\n", ident.toChars(), s);
@@ -755,7 +764,7 @@ extern (C++) final class AliasDeclaration : Declaration
assert(s);
}
- static AliasDeclaration create(const ref Loc loc, Identifier id, Type type)
+ static AliasDeclaration create(const ref Loc loc, Identifier id, Type type) @safe
{
return new AliasDeclaration(loc, id, type);
}
@@ -1036,7 +1045,7 @@ extern (C++) final class OverDeclaration : Declaration
Dsymbol overnext; // next in overload list
Dsymbol aliassym;
- extern (D) this(Identifier ident, Dsymbol s)
+ extern (D) this(Identifier ident, Dsymbol s) @safe
{
super(ident);
this.aliassym = s;
@@ -1158,10 +1167,11 @@ extern (C++) class VarDeclaration : Declaration
bool inClosure; /// is inserted into a GC allocated closure
bool inAlignSection; /// is inserted into an aligned section on stack
}
+ bool systemInferred; /// @system was inferred from initializer
}
import dmd.common.bitfields : generateBitFields;
- mixin(generateBitFields!(BitFields, ushort));
+ mixin(generateBitFields!(BitFields, uint));
byte canassign; // it can be assigned to
ubyte isdataseg; // private data for isDataseg 0 unset, 1 true, 2 false
@@ -2003,7 +2013,7 @@ extern (C++) final class SymbolDeclaration : Declaration
{
AggregateDeclaration dsym;
- extern (D) this(const ref Loc loc, AggregateDeclaration dsym)
+ extern (D) this(const ref Loc loc, AggregateDeclaration dsym) @safe
{
super(loc, dsym.ident);
this.dsym = dsym;
diff --git a/gcc/d/dmd/declaration.h b/gcc/d/dmd/declaration.h
index 197091e..71f2baa 100644
--- a/gcc/d/dmd/declaration.h
+++ b/gcc/d/dmd/declaration.h
@@ -244,7 +244,7 @@ public:
// The index of this variable on the CTFE stack, ~0u if not allocated
unsigned ctfeAdrOnStack;
private:
- uint16_t bitFields;
+ uint32_t bitFields;
public:
int8_t canassign; // // it can be assigned to
uint8_t isdataseg; // private data for isDataseg
@@ -278,6 +278,8 @@ public:
bool inAlignSection() const; // is inserted into aligned section on stack
bool inAlignSection(bool v);
#endif
+ bool systemInferred() const;
+ bool systemInferred(bool v);
static VarDeclaration *create(const Loc &loc, Type *t, Identifier *id, Initializer *init, StorageClass storage_class = STCundefined);
VarDeclaration *syntaxCopy(Dsymbol *) override;
void setFieldOffset(AggregateDeclaration *ad, FieldState& fieldState, bool isunion) override final;
diff --git a/gcc/d/dmd/delegatize.d b/gcc/d/dmd/delegatize.d
index b135bfa..559f103 100644
--- a/gcc/d/dmd/delegatize.d
+++ b/gcc/d/dmd/delegatize.d
@@ -109,7 +109,7 @@ private void lambdaSetParent(Expression e, FuncDeclaration fd)
}
public:
- extern (D) this(FuncDeclaration fd) scope
+ extern (D) this(FuncDeclaration fd) scope @safe
{
this.fd = fd;
}
@@ -205,7 +205,7 @@ bool lambdaCheckForNestedRef(Expression e, Scope* sc)
Scope* sc;
bool result;
- extern (D) this(Scope* sc) scope
+ extern (D) this(Scope* sc) scope @safe
{
this.sc = sc;
}
diff --git a/gcc/d/dmd/dinterpret.d b/gcc/d/dmd/dinterpret.d
index cb74a07..5948351 100644
--- a/gcc/d/dmd/dinterpret.d
+++ b/gcc/d/dmd/dinterpret.d
@@ -280,19 +280,19 @@ private:
Expression localThis; // value of 'this', or NULL if none
public:
- size_t stackPointer()
+ size_t stackPointer() @safe
{
return values.length;
}
// The current value of 'this', or NULL if none
- Expression getThis()
+ Expression getThis() @safe
{
return localThis;
}
// Largest number of stack positions we've used
- size_t maxStackUsage()
+ size_t maxStackUsage() @safe
{
return maxStackPointer;
}
@@ -1646,7 +1646,7 @@ public:
Expression result;
UnionExp* pue; // storage for `result`
- extern (D) this(UnionExp* pue, InterState* istate, CTFEGoal goal) scope
+ extern (D) this(UnionExp* pue, InterState* istate, CTFEGoal goal) scope @safe
{
this.pue = pue;
this.istate = istate;
@@ -3246,7 +3246,7 @@ public:
*/
// Returns the variable which is eventually modified, or NULL if an rvalue.
// thisval is the current value of 'this'.
- static VarDeclaration findParentVar(Expression e)
+ static VarDeclaration findParentVar(Expression e) @safe
{
for (;;)
{
@@ -6105,7 +6105,10 @@ public:
result = interpret(&ue, e.msg, istate);
if (exceptionOrCant(result))
return;
- e.error("`%s`", result.toChars());
+ if (StringExp se = result.isStringExp())
+ e.error("%s", se.toStringz().ptr);
+ else
+ e.error("%s", result.toChars());
}
else
e.error("`%s` failed", e.toChars());
@@ -7703,7 +7706,7 @@ private void removeHookTraceImpl(ref CallExp ce, ref FuncDeclaration fd)
// Get the Hook from the second template parameter
TemplateInstance templateInstance = fd.parent.isTemplateInstance;
RootObject hook = (*templateInstance.tiargs)[1];
- assert(hook.dyncast() == DYNCAST.dsymbol, "Expected _d_HookTraceImpl's second template parameter to be an alias to the hook!");
+ assert(hook.isDsymbol(), "Expected _d_HookTraceImpl's second template parameter to be an alias to the hook!");
fd = (cast(Dsymbol)hook).isFuncDeclaration;
// Remove the first three trace parameters
diff --git a/gcc/d/dmd/dmangle.d b/gcc/d/dmd/dmangle.d
index ad1e816..9b72308 100644
--- a/gcc/d/dmd/dmangle.d
+++ b/gcc/d/dmd/dmangle.d
@@ -25,14 +25,14 @@ extern (C++) const(char)* mangleExact(FuncDeclaration fd)
{
OutBuffer buf;
auto backref = Backref(null);
- scope Mangler v = new Mangler(&buf, &backref);
+ scope Mangler v = new Mangler(buf, &backref);
v.mangleExact(fd);
fd.mangleString = buf.extractChars();
}
return fd.mangleString;
}
-extern (C++) void mangleToBuffer(Type t, OutBuffer* buf)
+extern (C++) void mangleToBuffer(Type t, ref OutBuffer buf)
{
//printf("mangleToBuffer t()\n");
if (t.deco)
@@ -45,7 +45,7 @@ extern (C++) void mangleToBuffer(Type t, OutBuffer* buf)
}
}
-extern (C++) void mangleToBuffer(Expression e, OutBuffer* buf)
+extern (C++) void mangleToBuffer(Expression e, ref OutBuffer buf)
{
//printf("mangleToBuffer e()\n");
auto backref = Backref(null);
@@ -53,7 +53,7 @@ extern (C++) void mangleToBuffer(Expression e, OutBuffer* buf)
e.accept(v);
}
-extern (C++) void mangleToBuffer(Dsymbol s, OutBuffer* buf)
+extern (C++) void mangleToBuffer(Dsymbol s, ref OutBuffer buf)
{
//printf("mangleToBuffer s(%s)\n", s.toChars());
auto backref = Backref(null);
@@ -61,7 +61,7 @@ extern (C++) void mangleToBuffer(Dsymbol s, OutBuffer* buf)
s.accept(v);
}
-extern (C++) void mangleToBuffer(TemplateInstance ti, OutBuffer* buf)
+extern (C++) void mangleToBuffer(TemplateInstance ti, ref OutBuffer buf)
{
//printf("mangleToBuffer ti()\n");
auto backref = Backref(null);
@@ -249,7 +249,7 @@ unittest
* buf = buffer to append mangling to
* backref = state of back references (updated)
*/
-void mangleType(Type t, ubyte modMask, OutBuffer* buf, ref Backref backref)
+void mangleType(Type t, ubyte modMask, ref OutBuffer buf, ref Backref backref)
{
void visitWithMask(Type t, ubyte modMask)
{
@@ -395,7 +395,7 @@ void mangleType(Type t, ubyte modMask, OutBuffer* buf, ref Backref backref)
/*************************************************************
*/
-void mangleFuncType(TypeFunction t, TypeFunction ta, ubyte modMask, Type tret, OutBuffer* buf, ref Backref backref)
+void mangleFuncType(TypeFunction t, TypeFunction ta, ubyte modMask, Type tret, ref OutBuffer buf, ref Backref backref)
{
//printf("mangleFuncType() %s\n", t.toChars());
if (t.inuse && tret)
@@ -485,7 +485,7 @@ void mangleFuncType(TypeFunction t, TypeFunction ta, ubyte modMask, Type tret, O
/*************************************************************
*/
-void mangleParameter(Parameter p, OutBuffer* buf, ref Backref backref)
+void mangleParameter(Parameter p, ref OutBuffer buf, ref Backref backref)
{
// https://dlang.org/spec/abi.html#Parameter
@@ -564,9 +564,9 @@ public:
OutBuffer* buf;
Backref* backref;
- extern (D) this(OutBuffer* buf, Backref* backref)
+ extern (D) this(ref OutBuffer buf, Backref* backref) @trusted
{
- this.buf = buf;
+ this.buf = &buf;
this.backref = backref;
}
@@ -577,8 +577,8 @@ public:
void mangleIdentifier(Identifier id, Dsymbol s)
{
- if (!backref.addRefToIdentifier(buf, id))
- toBuffer(buf, id.toString(), s);
+ if (!backref.addRefToIdentifier(*buf, id))
+ toBuffer(*buf, id.toString(), s);
}
////////////////////////////////////////////////////////////////////////////
@@ -593,7 +593,7 @@ public:
}
else if (sthis.type)
{
- mangleType(sthis.type, 0, buf, *backref);
+ mangleType(sthis.type, 0, *buf, *backref);
}
else
assert(0);
@@ -627,7 +627,7 @@ public:
buf.writeByte('0');
if (localNum)
- writeLocalParent(buf, localNum);
+ writeLocalParent(*buf, localNum);
}
}
@@ -651,11 +651,11 @@ public:
{
TypeFunction tf = fd.type.isTypeFunction();
TypeFunction tfo = fd.originalType.isTypeFunction();
- mangleFuncType(tf, tfo, 0, null, buf, *backref);
+ mangleFuncType(tf, tfo, 0, null, *buf, *backref);
}
else
{
- mangleType(fd.type, 0, buf, *backref);
+ mangleType(fd.type, 0, *buf, *backref);
}
}
@@ -856,7 +856,7 @@ public:
if (ta)
{
buf.writeByte('T');
- mangleType(ta, 0, buf, *backref);
+ mangleType(ta, 0, *buf, *backref);
}
else if (ea)
{
@@ -899,7 +899,7 @@ public:
/* Use type mangling that matches what it would be for a function parameter
*/
- mangleType(ea.type, 0, buf, *backref);
+ mangleType(ea.type, 0, *buf, *backref);
ea.accept(this);
}
else if (sa)
@@ -915,13 +915,13 @@ public:
if (d.mangleOverride)
{
buf.writeByte('X');
- toBuffer(buf, d.mangleOverride, d);
+ toBuffer(*buf, d.mangleOverride, d);
continue;
}
if (const id = externallyMangledIdentifier(d))
{
buf.writeByte('X');
- toBuffer(buf, id, d);
+ toBuffer(*buf, id, d);
continue;
}
if (!d.type || !d.type.deco)
@@ -975,7 +975,7 @@ public:
if (s.ident)
mangleIdentifier(s.ident, s);
else
- toBuffer(buf, s.toString(), s);
+ toBuffer(*buf, s.toString(), s);
//printf("Dsymbol.mangle() %s = %s\n", s.toChars(), id);
}
@@ -1003,15 +1003,15 @@ public:
override void visit(RealExp e)
{
buf.writeByte('e');
- realToMangleBuffer(buf, e.value);
+ realToMangleBuffer(*buf, e.value);
}
override void visit(ComplexExp e)
{
buf.writeByte('c');
- realToMangleBuffer(buf, e.toReal());
+ realToMangleBuffer(*buf, e.toReal());
buf.writeByte('c'); // separate the two
- realToMangleBuffer(buf, e.toImaginary());
+ realToMangleBuffer(*buf, e.toImaginary());
}
override void visit(NullExp e)
@@ -1145,7 +1145,7 @@ private struct Backref
* true if the type was found. A back reference has been encoded.
* false if the type was not found. The current position is saved for later back references.
*/
- bool addRefToType(OutBuffer* buf, Type t)
+ bool addRefToType(ref OutBuffer buf, Type t)
{
if (t.isTypeBasic())
return false;
@@ -1184,14 +1184,14 @@ private struct Backref
* true if the identifier was found. A back reference has been encoded.
* false if the identifier was not found. The current position is saved for later back references.
*/
- bool addRefToIdentifier(OutBuffer* buf, Identifier id)
+ bool addRefToIdentifier(ref OutBuffer buf, Identifier id)
{
return backrefImpl(buf, idents, id);
}
private:
- extern(D) bool backrefImpl(T)(OutBuffer* buf, ref AssocArray!(T, size_t) aa, T key)
+ extern(D) bool backrefImpl(T)(ref OutBuffer buf, ref AssocArray!(T, size_t) aa, T key)
{
auto p = aa.getLvalue(key);
if (*p)
@@ -1214,7 +1214,7 @@ private struct Backref
* Mangle basic type ty to buf.
*/
-private void tyToDecoBuffer(OutBuffer* buf, int ty)
+private void tyToDecoBuffer(ref OutBuffer buf, int ty) @safe
{
const c = mangleChar[ty];
buf.writeByte(c);
@@ -1225,7 +1225,7 @@ private void tyToDecoBuffer(OutBuffer* buf, int ty)
/*********************************
* Mangling for mod.
*/
-private void MODtoDecoBuffer(OutBuffer* buf, MOD mod)
+private void MODtoDecoBuffer(ref OutBuffer buf, MOD mod) @safe
{
switch (mod)
{
@@ -1274,7 +1274,7 @@ private void MODtoDecoBuffer(OutBuffer* buf, MOD mod)
* pos = relative position to encode
*/
private
-void writeBackRef(OutBuffer* buf, size_t pos)
+void writeBackRef(ref OutBuffer buf, size_t pos) @safe
{
buf.writeByte('Q');
enum base = 26;
@@ -1296,7 +1296,7 @@ void writeBackRef(OutBuffer* buf, size_t pos)
* Write length prefixed string to buf.
*/
private
-extern (D) void toBuffer(OutBuffer* buf, const(char)[] id, Dsymbol s)
+extern (D) void toBuffer(ref OutBuffer buf, const(char)[] id, Dsymbol s)
{
const len = id.length;
if (buf.length + len >= 8 * 1024 * 1024) // 8 megs ought be enough for anyone
@@ -1321,7 +1321,7 @@ extern (D) void toBuffer(OutBuffer* buf, const(char)[] id, Dsymbol s)
* localNum = local symbol number
*/
private
-void writeLocalParent(OutBuffer* buf, uint localNum)
+void writeLocalParent(ref OutBuffer buf, uint localNum)
{
uint ndigits = 1;
auto n = localNum;
@@ -1340,7 +1340,7 @@ void writeLocalParent(OutBuffer* buf, uint localNum)
* value = real to write
*/
private
-void realToMangleBuffer(OutBuffer* buf, real_t value)
+void realToMangleBuffer(ref OutBuffer buf, real_t value)
{
/* Rely on %A to get portable mangling.
* Must munge result to get only identifier characters.
diff --git a/gcc/d/dmd/dmodule.d b/gcc/d/dmd/dmodule.d
index f00dec7..4a2e15c 100644
--- a/gcc/d/dmd/dmodule.d
+++ b/gcc/d/dmd/dmodule.d
@@ -948,7 +948,7 @@ extern (C++) final class Module : Package
* gets imported, it is unaffected by context.
* Ignore prevsc.
*/
- Scope* sc = Scope.createGlobal(this); // create root scope
+ Scope* sc = Scope.createGlobal(this, global.errorSink); // create root scope
if (md && md.msg)
md.msg = semanticString(sc, md.msg, "deprecation message");
@@ -1380,7 +1380,7 @@ extern (C++) struct ModuleDeclaration
bool isdeprecated; // if it is a deprecated module
Expression msg;
- extern (D) this(const ref Loc loc, Identifier[] packages, Identifier id, Expression msg, bool isdeprecated)
+ extern (D) this(const ref Loc loc, Identifier[] packages, Identifier id, Expression msg, bool isdeprecated) @safe
{
this.loc = loc;
this.packages = packages;
@@ -1389,7 +1389,7 @@ extern (C++) struct ModuleDeclaration
this.isdeprecated = isdeprecated;
}
- extern (C++) const(char)* toChars() const
+ extern (C++) const(char)* toChars() const @safe
{
OutBuffer buf;
foreach (pid; packages)
diff --git a/gcc/d/dmd/doc.d b/gcc/d/dmd/doc.d
index 3e60dc4..887fd6c 100644
--- a/gcc/d/dmd/doc.d
+++ b/gcc/d/dmd/doc.d
@@ -34,7 +34,7 @@ import dmd.dstruct;
import dmd.dsymbol;
import dmd.dsymbolsem;
import dmd.dtemplate;
-import dmd.errors;
+import dmd.errorsink;
import dmd.func;
import dmd.globals;
import dmd.hdrgen;
@@ -62,7 +62,7 @@ struct Escape
/***************************************
* Find character string to replace c with.
*/
- const(char)[] escapeChar(char c)
+ const(char)[] escapeChar(char c) @safe
{
version (all)
{
@@ -140,7 +140,7 @@ private class Section
size_t o = buf.length;
foreach (char c; name)
buf.writeByte((c == '_') ? ' ' : c);
- escapeStrayParenthesis(loc, buf, o, false);
+ escapeStrayParenthesis(loc, buf, o, false, sc.eSink);
buf.writestring(")");
}
else
@@ -150,7 +150,7 @@ private class Section
L1:
size_t o = buf.length;
buf.write(body_);
- escapeStrayParenthesis(loc, buf, o, true);
+ escapeStrayParenthesis(loc, buf, o, true, sc.eSink);
highlightText(sc, a, loc, *buf, o);
buf.writestring(")");
}
@@ -252,11 +252,11 @@ private final class ParamSection : Section
}
else if (!fparam)
{
- warning(s.loc, "Ddoc: function declaration has no parameter '%.*s'", cast(int)namelen, namestart);
+ sc.eSink.warning(s.loc, "Ddoc: function declaration has no parameter '%.*s'", cast(int)namelen, namestart);
}
buf.write(namestart[0 .. namelen]);
}
- escapeStrayParenthesis(loc, buf, o, true);
+ escapeStrayParenthesis(loc, buf, o, true, sc.eSink);
highlightCode(sc, a, *buf, o);
}
buf.writestring(")");
@@ -264,7 +264,7 @@ private final class ParamSection : Section
{
size_t o = buf.length;
buf.write(textstart[0 .. textlen]);
- escapeStrayParenthesis(loc, buf, o, true);
+ escapeStrayParenthesis(loc, buf, o, true, sc.eSink);
highlightText(sc, a, loc, *buf, o);
}
buf.writestring(")");
@@ -303,12 +303,12 @@ private final class ParamSection : Section
cast(int)(tf.parameterList.varargs == VarArg.variadic);
if (pcount != paramcount)
{
- warning(s.loc, "Ddoc: parameter count mismatch, expected %llu, got %llu",
+ sc.eSink.warning(s.loc, "Ddoc: parameter count mismatch, expected %llu, got %llu",
cast(ulong) pcount, cast(ulong) paramcount);
if (paramcount == 0)
{
// Chances are someone messed up the format
- warningSupplemental(s.loc, "Note that the format is `param = description`");
+ sc.eSink.warningSupplemental(s.loc, "Note that the format is `param = description`");
}
}
}
@@ -355,7 +355,7 @@ private Dsymbol getEponymousMember(TemplateDeclaration td) @safe
return null;
}
-private TemplateDeclaration getEponymousParent(Dsymbol s)
+private TemplateDeclaration getEponymousParent(Dsymbol s) @safe
{
if (!s.parent)
return null;
@@ -371,7 +371,7 @@ private immutable ddoc_decl_dd_e = ")\n";
/****************************************************
*/
-extern(C++) void gendocfile(Module m)
+extern(C++) void gendocfile(Module m, ErrorSink eSink)
{
__gshared OutBuffer mbuf;
__gshared int mbuf_done;
@@ -397,7 +397,7 @@ extern(C++) void gendocfile(Module m)
}
}
DocComment.parseMacros(m.escapetable, m.macrotable, mbuf[]);
- Scope* sc = Scope.createGlobal(m); // create root scope
+ Scope* sc = Scope.createGlobal(m, eSink); // create root scope
DocComment* dc = DocComment.parse(m, m.comment);
dc.pmacrotable = &m.macrotable;
dc.escapetable = m.escapetable;
@@ -460,7 +460,7 @@ extern(C++) void gendocfile(Module m)
const success = m.macrotable.expand(buf2, 0, end, null, global.recursionLimit);
if (!success)
- error(Loc.initial, "DDoc macro expansion limit exceeded; more than %d expansions.", global.recursionLimit);
+ eSink.error(Loc.initial, "DDoc macro expansion limit exceeded; more than %d expansions.", global.recursionLimit);
version (all)
{
@@ -568,7 +568,7 @@ void escapeDdocString(OutBuffer* buf, size_t start)
* directly preceeded by a backslash with $(LPAREN) or $(RPAREN) instead of
* counting them as stray parentheses
*/
-private void escapeStrayParenthesis(Loc loc, OutBuffer* buf, size_t start, bool respectBackslashEscapes)
+private void escapeStrayParenthesis(Loc loc, OutBuffer* buf, size_t start, bool respectBackslashEscapes, ErrorSink eSink)
{
uint par_open = 0;
char inCode = 0;
@@ -589,7 +589,7 @@ private void escapeStrayParenthesis(Loc loc, OutBuffer* buf, size_t start, bool
if (par_open == 0)
{
//stray ')'
- warning(loc, "Ddoc: Stray ')'. This may cause incorrect Ddoc output. Use $(RPAREN) instead for unpaired right parentheses.");
+ eSink.warning(loc, "Ddoc: Stray ')'. This may cause incorrect Ddoc output. Use $(RPAREN) instead for unpaired right parentheses.");
buf.remove(u, 1); //remove the )
buf.insert(u, "$(RPAREN)"); //insert this instead
u += 8; //skip over newly inserted macro
@@ -667,7 +667,7 @@ private void escapeStrayParenthesis(Loc loc, OutBuffer* buf, size_t start, bool
if (par_open == 0)
{
//stray '('
- warning(loc, "Ddoc: Stray '('. This may cause incorrect Ddoc output. Use $(LPAREN) instead for unpaired left parentheses.");
+ eSink.warning(loc, "Ddoc: Stray '('. This may cause incorrect Ddoc output. Use $(LPAREN) instead for unpaired left parentheses.");
buf.remove(u, 1); //remove the (
buf.insert(u, "$(LPAREN)"); //insert this instead
}
@@ -683,7 +683,7 @@ private void escapeStrayParenthesis(Loc loc, OutBuffer* buf, size_t start, bool
// Basically, this is to skip over things like private{} blocks in a struct or
// class definition that don't add any components to the qualified name.
-private Scope* skipNonQualScopes(Scope* sc)
+private Scope* skipNonQualScopes(Scope* sc) @safe
{
while (sc && !sc.scopesym)
sc = sc.enclosing;
@@ -1398,7 +1398,7 @@ private void toDocBuffer(Dsymbol s, ref OutBuffer buf, Scope* sc)
}
}
- static bool inSameModule(Dsymbol s, Dsymbol p)
+ static bool inSameModule(Dsymbol s, Dsymbol p) @safe
{
for (; s; s = s.parent)
{
@@ -1896,7 +1896,7 @@ struct DocComment
buf.writestring("$(DDOC_SUMMARY ");
size_t o = buf.length;
buf.write(sec.body_);
- escapeStrayParenthesis(loc, buf, o, true);
+ escapeStrayParenthesis(loc, buf, o, true, sc.eSink);
highlightText(sc, a, loc, *buf, o);
buf.writestring(")");
}
@@ -1968,7 +1968,7 @@ private const(char)* skipwhitespace(const(char)* p)
}
/// Ditto
-private const(char)[] skipwhitespace(const(char)[] p)
+private const(char)[] skipwhitespace(const(char)[] p) @safe
{
foreach (idx, char c; p)
{
@@ -1993,7 +1993,7 @@ private const(char)[] skipwhitespace(const(char)[] p)
* chars = the characters to skip; order is unimportant
* Returns: the index after skipping characters.
*/
-private size_t skipChars(ref OutBuffer buf, size_t i, string chars)
+private size_t skipChars(ref OutBuffer buf, size_t i, string chars) @safe
{
Outer:
foreach (j, c; buf[][i..$])
@@ -2028,7 +2028,7 @@ unittest {
* r = the string to replace `c` with
* Returns: `s` with `c` replaced with `r`
*/
-private inout(char)[] replaceChar(inout(char)[] s, char c, string r) pure
+private inout(char)[] replaceChar(inout(char)[] s, char c, string r) pure @safe
{
int count = 0;
foreach (char sc; s)
@@ -2070,7 +2070,7 @@ unittest
* s = the string to lowercase
* Returns: the lowercase version of the string or the original if already lowercase
*/
-private string toLowercase(string s) pure
+private string toLowercase(string s) pure @safe
{
string lower;
foreach (size_t i; 0..s.length)
@@ -2112,7 +2112,7 @@ unittest
* to = the index within `buf` to stop counting at, exclusive
* Returns: the indent
*/
-private int getMarkdownIndent(ref OutBuffer buf, size_t from, size_t to)
+private int getMarkdownIndent(ref OutBuffer buf, size_t from, size_t to) @safe
{
const slice = buf[];
if (to > slice.length)
@@ -2129,7 +2129,7 @@ private int getMarkdownIndent(ref OutBuffer buf, size_t from, size_t to)
* beginning of next line
* end of buf
*/
-size_t skiptoident(ref OutBuffer buf, size_t i)
+size_t skiptoident(ref OutBuffer buf, size_t i) @safe
{
const slice = buf[];
while (i < slice.length)
@@ -2158,7 +2158,7 @@ size_t skiptoident(ref OutBuffer buf, size_t i)
/************************************************
* Scan forward past end of identifier.
*/
-private size_t skippastident(ref OutBuffer buf, size_t i)
+private size_t skippastident(ref OutBuffer buf, size_t i) @safe
{
const slice = buf[];
while (i < slice.length)
@@ -2188,7 +2188,7 @@ private size_t skippastident(ref OutBuffer buf, size_t i)
* Scan forward past end of an identifier that might
* contain dots (e.g. `abc.def`)
*/
-private size_t skipPastIdentWithDots(ref OutBuffer buf, size_t i)
+private size_t skipPastIdentWithDots(ref OutBuffer buf, size_t i) @safe
{
const slice = buf[];
bool lastCharWasDot;
@@ -2356,7 +2356,7 @@ private bool replaceMarkdownThematicBreak(ref OutBuffer buf, ref size_t i, size_
* the detected heading level from 1 to 6, or
* 0 if not at an ATX heading
*/
-private int detectAtxHeadingLevel(ref OutBuffer buf, const size_t i)
+private int detectAtxHeadingLevel(ref OutBuffer buf, const size_t i) @safe
{
const iHeadingStart = i;
const iAfterHashes = skipChars(buf, i, "#");
@@ -2566,7 +2566,7 @@ private size_t replaceMarkdownEmphasis(ref OutBuffer buf, const ref Loc loc, ref
/****************************************************
*/
-private bool isIdentifier(Dsymbols* a, const(char)[] s)
+private bool isIdentifier(Dsymbols* a, const(char)[] s) @safe
{
foreach (member; *a)
{
@@ -2744,7 +2744,7 @@ private TemplateParameter isTemplateParameter(Dsymbols* a, const(char)* p, size_
* Return true if str is a reserved symbol name
* that starts with a double underscore.
*/
-private bool isReservedName(const(char)[] str)
+private bool isReservedName(const(char)[] str) @safe
{
immutable string[] table =
[
@@ -2802,10 +2802,10 @@ private struct MarkdownDelimiter
char type; /// the type of delimiter, defined by its starting character
/// whether this describes a valid delimiter
- @property bool isValid() const { return count != 0; }
+ @property bool isValid() const @safe { return count != 0; }
/// flag this delimiter as invalid
- void invalidate() { count = 0; }
+ void invalidate() @safe { count = 0; }
}
/****************************************************
@@ -2822,7 +2822,7 @@ private struct MarkdownList
char type; /// the type of list, defined by its starting character
/// whether this describes a valid list
- @property bool isValid() const { return type != type.init; }
+ @property bool isValid() const @safe { return type != type.init; }
/****************************************************
* Try to parse a list item, returning whether successful.
@@ -2832,7 +2832,7 @@ private struct MarkdownList
* i = the index within `buf` of the potential list item
* Returns: the parsed list item. Its `isValid` property describes whether parsing succeeded.
*/
- static MarkdownList parseItem(ref OutBuffer buf, size_t iLineStart, size_t i)
+ static MarkdownList parseItem(ref OutBuffer buf, size_t iLineStart, size_t i) @safe
{
if (buf[i] == '+' || buf[i] == '-' || buf[i] == '*')
return parseUnorderedListItem(buf, iLineStart, i);
@@ -2848,7 +2848,7 @@ private struct MarkdownList
* i = the index within `buf` of the list item
* Returns: whether `i` is at a list item of the same type as this list
*/
- private bool isAtItemInThisList(ref OutBuffer buf, size_t iLineStart, size_t i)
+ private bool isAtItemInThisList(ref OutBuffer buf, size_t iLineStart, size_t i) @safe
{
MarkdownList item = (type == '.' || type == ')') ?
parseOrderedListItem(buf, iLineStart, i) :
@@ -2970,7 +2970,7 @@ private struct MarkdownList
* i = the index within `buf` of the list item
* Returns: the parsed list item, or a list item with type `.init` if no list item is available
*/
- private static MarkdownList parseUnorderedListItem(ref OutBuffer buf, size_t iLineStart, size_t i)
+ private static MarkdownList parseUnorderedListItem(ref OutBuffer buf, size_t iLineStart, size_t i) @safe
{
if (i+1 < buf.length &&
(buf[i] == '-' ||
@@ -2998,7 +2998,7 @@ private struct MarkdownList
* i = the index within `buf` of the list item
* Returns: the parsed list item, or a list item with type `.init` if no list item is available
*/
- private static MarkdownList parseOrderedListItem(ref OutBuffer buf, size_t iLineStart, size_t i)
+ private static MarkdownList parseOrderedListItem(ref OutBuffer buf, size_t iLineStart, size_t i) @safe
{
size_t iAfterNumbers = skipChars(buf, i, "0123456789");
if (iAfterNumbers - i > 0 &&
@@ -3156,7 +3156,7 @@ private struct MarkdownLink
* delimiter = the delimiter that starts this link
* Returns: the index at the end of parsing the link, or `i` if parsing failed.
*/
- private size_t parseReferenceLink(ref OutBuffer buf, size_t i, MarkdownDelimiter delimiter)
+ private size_t parseReferenceLink(ref OutBuffer buf, size_t i, MarkdownDelimiter delimiter) @safe
{
size_t iStart = i + 1;
size_t iEnd = iStart;
@@ -3233,7 +3233,7 @@ private struct MarkdownLink
* If this function returns a non-empty label then `i` will point just after the ']' at the end of the label.
* Returns: the parsed and normalized label, possibly empty
*/
- private bool parseLabel(ref OutBuffer buf, ref size_t i)
+ private bool parseLabel(ref OutBuffer buf, ref size_t i) @safe
{
if (buf[i] != '[')
return false;
@@ -3506,7 +3506,7 @@ private struct MarkdownLink
* s = the string to remove escaping backslashes from
* Returns: `s` without escaping backslashes in it
*/
- private static char[] removeEscapeBackslashes(char[] s)
+ private static char[] removeEscapeBackslashes(char[] s) @safe
{
if (!s.length)
return s;
@@ -3550,7 +3550,7 @@ private struct MarkdownLink
* s = the string to percent-encode
* Returns: `s` with special characters percent-encoded
*/
- private static inout(char)[] percentEncode(inout(char)[] s) pure
+ private static inout(char)[] percentEncode(inout(char)[] s) pure @safe
{
static bool shouldEncode(char c)
{
@@ -3591,7 +3591,7 @@ private struct MarkdownLink
* If this function succeeds `i` will point after the newline.
* Returns: whether a newline was skipped
*/
- private static bool skipOneNewline(ref OutBuffer buf, ref size_t i) pure
+ private static bool skipOneNewline(ref OutBuffer buf, ref size_t i) pure @safe
{
if (i < buf.length && buf[i] == '\r')
++i;
@@ -3786,7 +3786,7 @@ private struct MarkdownLinkReferences
* delimiter = the character to split by
* Returns: the resulting array of strings
*/
- private static string[] split(string s, char delimiter) pure
+ private static string[] split(string s, char delimiter) pure @safe
{
string[] result;
size_t iStart = 0;
@@ -3893,7 +3893,7 @@ private enum TableColumnAlignment
* columnAlignments = alignments to populate for each column
* Returns: the index of the end of the parsed delimiter, or `0` if not found
*/
-private size_t parseTableDelimiterRow(ref OutBuffer buf, const size_t iStart, bool inQuote, ref TableColumnAlignment[] columnAlignments)
+private size_t parseTableDelimiterRow(ref OutBuffer buf, const size_t iStart, bool inQuote, ref TableColumnAlignment[] columnAlignments) @safe
{
size_t i = skipChars(buf, iStart, inQuote ? ">| \t" : "| \t");
while (i < buf.length && buf[i] != '\r' && buf[i] != '\n')
@@ -4417,7 +4417,7 @@ private void highlightText(Scope* sc, Dsymbols* a, Loc loc, ref OutBuffer buf, s
codebuf.write(buf[iCodeStart + count .. i]);
// escape the contents, but do not perform highlighting except for DDOC_PSYMBOL
highlightCode(sc, a, codebuf, 0);
- escapeStrayParenthesis(loc, &codebuf, 0, false);
+ escapeStrayParenthesis(loc, &codebuf, 0, false, sc.eSink);
buf.remove(iCodeStart, i - iCodeStart + count); // also trimming off the current `
immutable pre = "$(DDOC_BACKQUOTED ";
i = buf.insert(iCodeStart, pre);
@@ -4626,7 +4626,7 @@ private void highlightText(Scope* sc, Dsymbols* a, Loc loc, ref OutBuffer buf, s
highlightCode2(sc, a, codebuf, 0);
else
codebuf.remove(codebuf.length-1, 1); // remove the trailing 0 byte
- escapeStrayParenthesis(loc, &codebuf, 0, false);
+ escapeStrayParenthesis(loc, &codebuf, 0, false, sc.eSink);
buf.remove(iCodeStart, i - iCodeStart);
i = buf.insert(iCodeStart, codebuf[]);
i = buf.insert(i, ")\n");
@@ -4984,7 +4984,7 @@ private void highlightText(Scope* sc, Dsymbols* a, Loc loc, ref OutBuffer buf, s
}
if (inCode == '-')
- error(loc, "unmatched `---` in DDoc comment");
+ sc.eSink.error(loc, "unmatched `---` in DDoc comment");
else if (inCode)
buf.insert(buf.length, ")");
@@ -5180,10 +5180,10 @@ private void highlightCode3(Scope* sc, ref OutBuffer buf, const(char)* p, const(
*/
private void highlightCode2(Scope* sc, Dsymbols* a, ref OutBuffer buf, size_t offset)
{
- uint errorsave = global.startGagging();
+ scope eSinkNull = new ErrorSinkNull();
scope Lexer lex = new Lexer(null, cast(char*)buf[].ptr, 0, buf.length - 1, 0, 1,
- global.errorSink,
+ eSinkNull, // ignore errors
&global.compileEnv);
OutBuffer res;
const(char)* lastp = cast(char*)buf[].ptr;
@@ -5247,7 +5247,6 @@ private void highlightCode2(Scope* sc, Dsymbols* a, ref OutBuffer buf, size_t of
}
buf.setsize(offset);
buf.write(&res);
- global.endGagging(errorsave);
}
/****************************************
diff --git a/gcc/d/dmd/doc.h b/gcc/d/dmd/doc.h
index d16806b..669e308 100644
--- a/gcc/d/dmd/doc.h
+++ b/gcc/d/dmd/doc.h
@@ -11,5 +11,6 @@
#pragma once
class Module;
+class ErrorSink;
-void gendocfile(Module *m);
+void gendocfile(Module *m, ErrorSink *eSink);
diff --git a/gcc/d/dmd/dscope.d b/gcc/d/dmd/dscope.d
index 95cfec9..c2c0628 100644
--- a/gcc/d/dmd/dscope.d
+++ b/gcc/d/dmd/dscope.d
@@ -29,6 +29,7 @@ import dmd.dsymbolsem;
import dmd.dtemplate;
import dmd.expression;
import dmd.errors;
+import dmd.errorsink;
import dmd.func;
import dmd.globals;
import dmd.id;
@@ -96,6 +97,7 @@ extern (C++) struct Scope
bool inLoop; /// true if inside a loop (where constructor calls aren't allowed)
int intypeof; /// in typeof(exp)
VarDeclaration lastVar; /// Previous symbol used to prevent goto-skips-init
+ ErrorSink eSink; /// sink for error messages
/* If minst && !tinst, it's in definitely non-speculative scope (eg. module member scope).
* If !minst && !tinst, it's in definitely speculative scope (eg. template constraint).
@@ -158,7 +160,7 @@ extern (C++) struct Scope
return new Scope();
}
- extern (D) static Scope* createGlobal(Module _module)
+ extern (D) static Scope* createGlobal(Module _module, ErrorSink eSink)
{
Scope* sc = Scope.alloc();
*sc = Scope.init;
@@ -166,6 +168,7 @@ extern (C++) struct Scope
sc.minst = _module;
sc.scopesym = new ScopeDsymbol();
sc.scopesym.symtab = new DsymbolTable();
+ sc.eSink = eSink;
// Add top level package as member of this global scope
Dsymbol m = _module;
while (m.parent)
@@ -614,7 +617,7 @@ extern (C++) struct Scope
* Returns:
* innermost scope, null if none
*/
- extern (D) Scope* inner() return
+ extern (D) Scope* inner() return @safe
{
for (Scope* sc = &this; sc; sc = sc.enclosing)
{
@@ -670,7 +673,7 @@ extern (C++) struct Scope
/********************************************
* Search enclosing scopes for ScopeDsymbol.
*/
- extern (D) ScopeDsymbol getScopesym()
+ extern (D) ScopeDsymbol getScopesym() @safe
{
for (Scope* sc = &this; sc; sc = sc.enclosing)
{
@@ -683,7 +686,7 @@ extern (C++) struct Scope
/********************************************
* Search enclosing scopes for ClassDeclaration.
*/
- extern (D) ClassDeclaration getClassScope()
+ extern (D) ClassDeclaration getClassScope() @safe
{
for (Scope* sc = &this; sc; sc = sc.enclosing)
{
@@ -698,7 +701,7 @@ extern (C++) struct Scope
/********************************************
* Search enclosing scopes for ClassDeclaration or StructDeclaration.
*/
- extern (D) AggregateDeclaration getStructClassScope()
+ extern (D) AggregateDeclaration getStructClassScope() @safe
{
for (Scope* sc = &this; sc; sc = sc.enclosing)
{
@@ -742,7 +745,7 @@ extern (C++) struct Scope
* where it was declared. So mark the Scope as not
* to be free'd.
*/
- extern (D) void setNoFree()
+ extern (D) void setNoFree() @safe
{
//int i = 0;
//printf("Scope::setNoFree(this = %p)\n", this);
diff --git a/gcc/d/dmd/dsymbol.d b/gcc/d/dmd/dsymbol.d
index 2373313..0fa4dbc 100644
--- a/gcc/d/dmd/dsymbol.d
+++ b/gcc/d/dmd/dsymbol.d
@@ -113,7 +113,7 @@ struct Ungag
{
uint oldgag;
- extern (D) this(uint old) nothrow
+ extern (D) this(uint old) nothrow @safe
{
this.oldgag = old;
}
@@ -177,7 +177,7 @@ struct Visibility
/**
* Checks if `this` is absolutely identical visibility attribute to `other`
*/
- bool opEquals(ref const Visibility other) const
+ bool opEquals(ref const Visibility other) const @safe
{
if (this.kind == other.kind)
{
@@ -264,27 +264,27 @@ extern (C++) class Dsymbol : ASTNode
PASS semanticRun = PASS.initial;
ushort localNum; /// perturb mangled name to avoid collisions with those in FuncDeclaration.localsymtab
- final extern (D) this() nothrow
+ final extern (D) this() nothrow @safe
{
//printf("Dsymbol::Dsymbol(%p)\n", this);
loc = Loc(null, 0, 0);
}
- final extern (D) this(Identifier ident) nothrow
+ final extern (D) this(Identifier ident) nothrow @safe
{
//printf("Dsymbol::Dsymbol(%p, ident)\n", this);
this.loc = Loc(null, 0, 0);
this.ident = ident;
}
- final extern (D) this(const ref Loc loc, Identifier ident) nothrow
+ final extern (D) this(const ref Loc loc, Identifier ident) nothrow @safe
{
//printf("Dsymbol::Dsymbol(%p, ident)\n", this);
this.loc = loc;
this.ident = ident;
}
- static Dsymbol create(Identifier ident) nothrow
+ static Dsymbol create(Identifier ident) nothrow @safe
{
return new Dsymbol(ident);
}
@@ -353,9 +353,9 @@ extern (C++) class Dsymbol : ASTNode
{
if (this == o)
return true;
- if (o.dyncast() != DYNCAST.dsymbol)
+ const s = o.isDsymbol();
+ if (!s)
return false;
- auto s = cast(Dsymbol)o;
// Overload sets don't have an ident
// Function-local declarations may have identical names
// if they are declared in different scopes
@@ -381,7 +381,7 @@ extern (C++) class Dsymbol : ASTNode
{
va_list ap;
va_start(ap, format);
- .verror(loc, format, ap, kind(), prettyFormatHelper().ptr);
+ .verrorReport(loc, format, ap, ErrorKind.error, kind(), prettyFormatHelper().ptr);
va_end(ap);
}
@@ -390,7 +390,7 @@ extern (C++) class Dsymbol : ASTNode
va_list ap;
va_start(ap, format);
const loc = getLoc();
- .verror(loc, format, ap, kind(), prettyFormatHelper().ptr);
+ .verrorReport(loc, format, ap, ErrorKind.error, kind(), prettyFormatHelper().ptr);
va_end(ap);
}
@@ -398,7 +398,7 @@ extern (C++) class Dsymbol : ASTNode
{
va_list ap;
va_start(ap, format);
- .vdeprecation(loc, format, ap, kind(), prettyFormatHelper().ptr);
+ .verrorReport(loc, format, ap, ErrorKind.deprecation, kind(), prettyFormatHelper().ptr);
va_end(ap);
}
@@ -407,7 +407,7 @@ extern (C++) class Dsymbol : ASTNode
va_list ap;
va_start(ap, format);
const loc = getLoc();
- .vdeprecation(loc, format, ap, kind(), prettyFormatHelper().ptr);
+ .verrorReport(loc, format, ap, ErrorKind.deprecation, kind(), prettyFormatHelper().ptr);
va_end(ap);
}
}
@@ -417,7 +417,7 @@ extern (C++) class Dsymbol : ASTNode
{
va_list ap;
va_start(ap, format);
- .verror(loc, format, ap, kind(), prettyFormatHelper().ptr);
+ .verrorReport(loc, format, ap, ErrorKind.error, kind(), prettyFormatHelper().ptr);
va_end(ap);
}
@@ -426,7 +426,7 @@ extern (C++) class Dsymbol : ASTNode
va_list ap;
va_start(ap, format);
const loc = getLoc();
- .verror(loc, format, ap, kind(), prettyFormatHelper().ptr);
+ .verrorReport(loc, format, ap, ErrorKind.error, kind(), prettyFormatHelper().ptr);
va_end(ap);
}
@@ -434,7 +434,7 @@ extern (C++) class Dsymbol : ASTNode
{
va_list ap;
va_start(ap, format);
- .vdeprecation(loc, format, ap, kind(), prettyFormatHelper().ptr);
+ .verrorReport(loc, format, ap, ErrorKind.deprecation, kind(), prettyFormatHelper().ptr);
va_end(ap);
}
@@ -443,7 +443,7 @@ extern (C++) class Dsymbol : ASTNode
va_list ap;
va_start(ap, format);
const loc = getLoc();
- .vdeprecation(loc, format, ap, kind(), prettyFormatHelper().ptr);
+ .verrorReport(loc, format, ap, ErrorKind.deprecation, kind(), prettyFormatHelper().ptr);
va_end(ap);
}
}
@@ -1430,16 +1430,16 @@ private:
BitArray accessiblePackages, privateAccessiblePackages;// whitelists of accessible (imported) packages
public:
- final extern (D) this() nothrow
+ final extern (D) this() nothrow @safe
{
}
- final extern (D) this(Identifier ident) nothrow
+ final extern (D) this(Identifier ident) nothrow @safe
{
super(ident);
}
- final extern (D) this(const ref Loc loc, Identifier ident) nothrow
+ final extern (D) this(const ref Loc loc, Identifier ident) nothrow @safe
{
super(loc, ident);
}
@@ -1919,7 +1919,7 @@ extern (C++) final class WithScopeSymbol : ScopeDsymbol
{
WithStatement withstate;
- extern (D) this(WithStatement withstate) nothrow
+ extern (D) this(WithStatement withstate) nothrow @safe
{
this.withstate = withstate;
}
@@ -1979,7 +1979,7 @@ extern (C++) final class ArrayScopeSymbol : ScopeDsymbol
private RootObject arrayContent;
Scope* sc;
- extern (D) this(Scope* sc, Expression exp) nothrow
+ extern (D) this(Scope* sc, Expression exp) nothrow @safe
{
super(exp.loc, null);
assert(exp.op == EXP.index || exp.op == EXP.slice || exp.op == EXP.array);
@@ -1987,13 +1987,13 @@ extern (C++) final class ArrayScopeSymbol : ScopeDsymbol
this.arrayContent = exp;
}
- extern (D) this(Scope* sc, TypeTuple type) nothrow
+ extern (D) this(Scope* sc, TypeTuple type) nothrow @safe
{
this.sc = sc;
this.arrayContent = type;
}
- extern (D) this(Scope* sc, TupleDeclaration td) nothrow
+ extern (D) this(Scope* sc, TupleDeclaration td) nothrow @safe
{
this.sc = sc;
this.arrayContent = td;
@@ -2242,7 +2242,7 @@ extern (C++) final class OverloadSet : Dsymbol
*/
extern (C++) final class ForwardingScopeDsymbol : ScopeDsymbol
{
- extern (D) this() nothrow
+ extern (D) this() nothrow @safe
{
super();
}
@@ -2328,7 +2328,7 @@ extern (C++) final class ForwardingScopeDsymbol : ScopeDsymbol
extern (C++) final class ExpressionDsymbol : Dsymbol
{
Expression exp;
- this(Expression exp) nothrow
+ this(Expression exp) nothrow @safe
{
super();
this.exp = exp;
@@ -2353,7 +2353,7 @@ extern (C++) final class AliasAssign : Dsymbol
Dsymbol aliassym; /// replace previous RHS of AliasDeclaration with `aliassym`
/// only one of type and aliassym can be != null
- extern (D) this(const ref Loc loc, Identifier ident, Type type, Dsymbol aliassym) nothrow
+ extern (D) this(const ref Loc loc, Identifier ident, Type type, Dsymbol aliassym) nothrow @safe
{
super(loc, null);
this.ident = ident;
diff --git a/gcc/d/dmd/dsymbolsem.d b/gcc/d/dmd/dsymbolsem.d
index 7a800bd..378d3e6 100644
--- a/gcc/d/dmd/dsymbolsem.d
+++ b/gcc/d/dmd/dsymbolsem.d
@@ -274,7 +274,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
alias visit = Visitor.visit;
Scope* sc;
- this(Scope* sc) scope
+ this(Scope* sc) scope @safe
{
this.sc = sc;
}
@@ -320,11 +320,6 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
return;
}
- // @@@DEPRECATED_2.121@@@
- // Deprecated in 2.101 - Can be removed in 2.121
- if (ad.isClassDeclaration() || ad.isInterfaceDeclaration())
- deprecation(dsym.loc, "alias this for classes/interfaces is deprecated");
-
assert(ad.members);
Dsymbol s = ad.search(dsym.loc, dsym.ident);
if (!s)
@@ -1125,16 +1120,12 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
*/
if (ne.member && !(ne.member.storage_class & STC.scope_))
{
- if (sc.func.isSafe())
- {
- // @@@DEPRECATED_2.112@@@
- deprecation(dsym.loc,
- "`scope` allocation of `%s` requires that constructor be annotated with `scope`",
- dsym.toChars());
- deprecationSupplemental(ne.member.loc, "is the location of the constructor");
- }
- else
- sc.func.setUnsafe();
+ import dmd.escape : setUnsafeDIP1000;
+ const inSafeFunc = sc.func && sc.func.isSafeBypassingInference();
+ if (sc.setUnsafeDIP1000(false, dsym.loc, "`scope` allocation of `%s` requires that constructor be annotated with `scope`", dsym))
+ errorSupplemental(ne.member.loc, "is the location of the constructor");
+ else if (global.params.obsolete && inSafeFunc)
+ warningSupplemental(ne.member.loc, "is the location of the constructor");
}
ne.onstack = 1;
dsym.onstack = true;
@@ -1224,8 +1215,11 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
bool needctfe = dsym.isDataseg() || (dsym.storage_class & STC.manifest);
if (needctfe)
sc = sc.startCTFE();
+ sc = sc.push();
+ sc.varDecl = dsym; // https://issues.dlang.org/show_bug.cgi?id=24051
exp = exp.expressionSemantic(sc);
exp = resolveProperties(sc, exp);
+ sc = sc.pop();
if (needctfe)
sc = sc.endCTFE();
ei.exp = exp;
@@ -2098,7 +2092,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
Scope* sc = m._scope; // see if already got one from importAll()
if (!sc)
{
- sc = Scope.createGlobal(m); // create root scope
+ sc = Scope.createGlobal(m, global.errorSink); // create root scope
}
//printf("Module = %p, linkage = %d\n", sc.scopesym, sc.linkage);
@@ -6087,7 +6081,7 @@ void templateInstanceSemantic(TemplateInstance tempinst, Scope* sc, ArgumentList
alias visit = Visitor.visit;
TemplateInstance inst;
- extern (D) this(TemplateInstance inst) scope
+ extern (D) this(TemplateInstance inst) scope @safe
{
this.inst = inst;
}
diff --git a/gcc/d/dmd/dtemplate.d b/gcc/d/dmd/dtemplate.d
index f2ab694..e492c7e 100644
--- a/gcc/d/dmd/dtemplate.d
+++ b/gcc/d/dmd/dtemplate.d
@@ -84,7 +84,7 @@ private enum LOG = false;
enum IDX_NOTFOUND = 0x12345678;
-pure nothrow @nogc
+pure nothrow @nogc @safe
{
/********************************************
@@ -3507,7 +3507,7 @@ MATCH deduceType(RootObject o, Scope* sc, Type tparam, TemplateParameters* param
bool ignoreAliasThis;
MATCH result;
- extern (D) this(Scope* sc, Type tparam, TemplateParameters* parameters, Objects* dedtypes, uint* wm, size_t inferStart, bool ignoreAliasThis)
+ extern (D) this(Scope* sc, Type tparam, TemplateParameters* parameters, Objects* dedtypes, uint* wm, size_t inferStart, bool ignoreAliasThis) @safe
{
this.sc = sc;
this.tparam = tparam;
@@ -5091,7 +5091,7 @@ private bool reliesOnTemplateParameters(Expression e, TemplateParameter[] tparam
TemplateParameter[] tparams;
bool result;
- extern (D) this(TemplateParameter[] tparams)
+ extern (D) this(TemplateParameter[] tparams) @safe
{
this.tparams = tparams;
}
@@ -5358,7 +5358,7 @@ extern (C++) class TemplateParameter : ASTNode
bool dependent;
/* ======================== TemplateParameter =============================== */
- extern (D) this(const ref Loc loc, Identifier ident)
+ extern (D) this(const ref Loc loc, Identifier ident) @safe
{
this.loc = loc;
this.ident = ident;
@@ -5433,7 +5433,7 @@ extern (C++) class TemplateTypeParameter : TemplateParameter
extern (D) __gshared Type tdummy = null;
- extern (D) this(const ref Loc loc, Identifier ident, Type specType, Type defaultType)
+ extern (D) this(const ref Loc loc, Identifier ident, Type specType, Type defaultType) @safe
{
super(loc, ident);
this.specType = specType;
@@ -5521,7 +5521,7 @@ extern (C++) class TemplateTypeParameter : TemplateParameter
*/
extern (C++) final class TemplateThisParameter : TemplateTypeParameter
{
- extern (D) this(const ref Loc loc, Identifier ident, Type specType, Type defaultType)
+ extern (D) this(const ref Loc loc, Identifier ident, Type specType, Type defaultType) @safe
{
super(loc, ident, specType, defaultType);
}
@@ -5556,7 +5556,7 @@ extern (C++) final class TemplateValueParameter : TemplateParameter
extern (D) __gshared Expression[void*] edummies;
extern (D) this(const ref Loc loc, Identifier ident, Type valType,
- Expression specValue, Expression defaultValue)
+ Expression specValue, Expression defaultValue) @safe
{
super(loc, ident);
this.valType = valType;
@@ -5683,7 +5683,7 @@ extern (C++) final class TemplateAliasParameter : TemplateParameter
extern (D) __gshared Dsymbol sdummy = null;
- extern (D) this(const ref Loc loc, Identifier ident, Type specType, RootObject specAlias, RootObject defaultAlias)
+ extern (D) this(const ref Loc loc, Identifier ident, Type specType, RootObject specAlias, RootObject defaultAlias) @safe
{
super(loc, ident);
this.specType = specType;
@@ -5768,7 +5768,7 @@ extern (C++) final class TemplateAliasParameter : TemplateParameter
*/
extern (C++) final class TemplateTupleParameter : TemplateParameter
{
- extern (D) this(const ref Loc loc, Identifier ident)
+ extern (D) this(const ref Loc loc, Identifier ident) @safe
{
super(loc, ident);
}
@@ -7542,7 +7542,7 @@ extern (C++) class TemplateInstance : ScopeDsymbol
//printf("TemplateInstance.genIdent('%s')\n", tempdecl.ident.toChars());
assert(args is tiargs);
OutBuffer buf;
- mangleToBuffer(this, &buf);
+ mangleToBuffer(this, buf);
//printf("\tgenIdent = %s\n", buf.peekChars());
return Identifier.idPool(buf[]);
}
@@ -7717,7 +7717,7 @@ void unSpeculative(Scope* sc, RootObject o)
* Return false if it might be an alias or tuple.
* (Note that even in this case, it could still turn out to be a value).
*/
-bool definitelyValueParameter(Expression e)
+bool definitelyValueParameter(Expression e) @safe
{
// None of these can be value parameters
if (e.op == EXP.tuple || e.op == EXP.scope_ ||
diff --git a/gcc/d/dmd/dtoh.d b/gcc/d/dmd/dtoh.d
index b9bbad0..6a7442a 100644
--- a/gcc/d/dmd/dtoh.d
+++ b/gcc/d/dmd/dtoh.d
@@ -295,7 +295,7 @@ public:
// Generates getter-setter methods to replace the use of alias this
// This should be replaced by a `static foreach` once the gdc tester
// gets upgraded to version 10 (to support `static foreach`).
- private extern(D) static string generateMembers()
+ private extern(D) static string generateMembers() @safe
{
string result = "";
foreach(member; __traits(allMembers, Context))
@@ -304,7 +304,6 @@ public:
}
return result;
}
-
mixin(generateMembers());
this(OutBuffer* fwdbuf, OutBuffer* donebuf, OutBuffer* buf) scope
@@ -396,7 +395,7 @@ public:
}
/// Writes a final `;` and insert an empty line outside of aggregates
- private void writeDeclEnd()
+ private void writeDeclEnd() @safe
{
buf.writestringln(";");
@@ -1213,7 +1212,7 @@ public:
buf.writestringln("};");
}
- private bool memberField(AST.VarDeclaration vd)
+ private bool memberField(AST.VarDeclaration vd) @safe
{
if (!vd.type || !vd.type.deco || !vd.ident)
return false;
@@ -1411,7 +1410,7 @@ public:
/// Ends a custom alignment section using `#pragma pack` if
/// `alignment` specifies a custom alignment
- private void popAlignToBuffer(structalign_t alignment)
+ private void popAlignToBuffer(structalign_t alignment) @safe
{
if (alignment.isDefault() || (tdparent && alignment.isUnknown()))
return;
@@ -3038,7 +3037,7 @@ public:
}
/// Returns: Explicit mangling for `sym` if present
- extern(D) static const(char)[] getMangleOverride(const AST.Dsymbol sym)
+ extern(D) static const(char)[] getMangleOverride(const AST.Dsymbol sym) @safe
{
if (auto decl = sym.isDeclaration())
return decl.mangleOverride;
@@ -3090,34 +3089,34 @@ void initialize()
}
/// Writes `#if <content>` into the supplied buffer
-void hashIf(ref OutBuffer buf, string content)
+void hashIf(ref OutBuffer buf, string content) @safe
{
buf.writestring("#if ");
buf.writestringln(content);
}
/// Writes `#elif <content>` into the supplied buffer
-void hashElIf(ref OutBuffer buf, string content)
+void hashElIf(ref OutBuffer buf, string content) @safe
{
buf.writestring("#elif ");
buf.writestringln(content);
}
/// Writes `#endif` into the supplied buffer
-void hashEndIf(ref OutBuffer buf)
+void hashEndIf(ref OutBuffer buf) @safe
{
buf.writestringln("#endif");
}
/// Writes `#define <content>` into the supplied buffer
-void hashDefine(ref OutBuffer buf, string content)
+void hashDefine(ref OutBuffer buf, string content) @safe
{
buf.writestring("#define ");
buf.writestringln(content);
}
/// Writes `#include <content>` into the supplied buffer
-void hashInclude(ref OutBuffer buf, string content)
+void hashInclude(ref OutBuffer buf, string content) @safe
{
buf.writestring("#include ");
buf.writestringln(content);
@@ -3232,7 +3231,7 @@ ASTCodegen.Dsymbol outermostSymbol(ASTCodegen.Dsymbol sym)
/// Fetches the symbol for user-defined types from the type `t`
/// if `t` is either `TypeClass`, `TypeStruct` or `TypeEnum`
-ASTCodegen.Dsymbol symbolFromType(ASTCodegen.Type t)
+ASTCodegen.Dsymbol symbolFromType(ASTCodegen.Type t) @safe
{
if (auto tc = t.isTypeClass())
return tc.sym;
diff --git a/gcc/d/dmd/dversion.d b/gcc/d/dmd/dversion.d
index 259f85c5..0945b54 100644
--- a/gcc/d/dmd/dversion.d
+++ b/gcc/d/dmd/dversion.d
@@ -35,12 +35,12 @@ extern (C++) final class DebugSymbol : Dsymbol
{
uint level;
- extern (D) this(const ref Loc loc, Identifier ident)
+ extern (D) this(const ref Loc loc, Identifier ident) @safe
{
super(loc, ident);
}
- extern (D) this(const ref Loc loc, uint level)
+ extern (D) this(const ref Loc loc, uint level) @safe
{
super(loc, null);
this.level = level;
@@ -129,12 +129,12 @@ extern (C++) final class VersionSymbol : Dsymbol
{
uint level;
- extern (D) this(const ref Loc loc, Identifier ident)
+ extern (D) this(const ref Loc loc, Identifier ident) @safe
{
super(loc, ident);
}
- extern (D) this(const ref Loc loc, uint level)
+ extern (D) this(const ref Loc loc, uint level) @safe
{
super(loc, null);
this.level = level;
diff --git a/gcc/d/dmd/errors.d b/gcc/d/dmd/errors.d
index 1f7a78e..542b97b 100644
--- a/gcc/d/dmd/errors.d
+++ b/gcc/d/dmd/errors.d
@@ -18,6 +18,16 @@ import dmd.location;
nothrow:
+/// Constants used to discriminate kinds of error messages.
+enum ErrorKind
+{
+ warning,
+ deprecation,
+ error,
+ tip,
+ message,
+}
+
/***************************
* Error message sink for D compiler.
*/
@@ -31,7 +41,7 @@ class ErrorSinkCompiler : ErrorSink
{
va_list ap;
va_start(ap, format);
- verror(loc, format, ap);
+ verrorReport(loc, format, ap, ErrorKind.error);
va_end(ap);
}
@@ -39,7 +49,7 @@ class ErrorSinkCompiler : ErrorSink
{
va_list ap;
va_start(ap, format);
- verrorSupplemental(loc, format, ap);
+ verrorReportSupplemental(loc, format, ap, ErrorKind.error);
va_end(ap);
}
@@ -47,7 +57,15 @@ class ErrorSinkCompiler : ErrorSink
{
va_list ap;
va_start(ap, format);
- vwarning(loc, format, ap);
+ verrorReport(loc, format, ap, ErrorKind.warning);
+ va_end(ap);
+ }
+
+ void warningSupplemental(const ref Loc loc, const(char)* format, ...)
+ {
+ va_list ap;
+ va_start(ap, format);
+ verrorReportSupplemental(loc, format, ap, ErrorKind.warning);
va_end(ap);
}
@@ -55,7 +73,7 @@ class ErrorSinkCompiler : ErrorSink
{
va_list ap;
va_start(ap, format);
- vdeprecation(loc, format, ap);
+ verrorReport(loc, format, ap, ErrorKind.deprecation);
va_end(ap);
}
@@ -63,7 +81,7 @@ class ErrorSinkCompiler : ErrorSink
{
va_list ap;
va_start(ap, format);
- vdeprecationSupplemental(loc, format, ap);
+ verrorReportSupplemental(loc, format, ap, ErrorKind.deprecation);
va_end(ap);
}
@@ -71,7 +89,7 @@ class ErrorSinkCompiler : ErrorSink
{
va_list ap;
va_start(ap, format);
- vmessage(loc, format, ap);
+ verrorReport(loc, format, ap, ErrorKind.message);
va_end(ap);
}
}
@@ -160,7 +178,7 @@ static if (__VERSION__ < 2092)
{
va_list ap;
va_start(ap, format);
- verror(loc, format, ap);
+ verrorReport(loc, format, ap, ErrorKind.error);
va_end(ap);
}
else
@@ -168,7 +186,7 @@ else
{
va_list ap;
va_start(ap, format);
- verror(loc, format, ap);
+ verrorReport(loc, format, ap, ErrorKind.error);
va_end(ap);
}
@@ -187,7 +205,7 @@ static if (__VERSION__ < 2092)
const loc = Loc(filename, linnum, charnum);
va_list ap;
va_start(ap, format);
- verror(loc, format, ap);
+ verrorReport(loc, format, ap, ErrorKind.error);
va_end(ap);
}
else
@@ -196,7 +214,7 @@ else
const loc = Loc(filename, linnum, charnum);
va_list ap;
va_start(ap, format);
- verror(loc, format, ap);
+ verrorReport(loc, format, ap, ErrorKind.error);
va_end(ap);
}
@@ -213,7 +231,7 @@ static if (__VERSION__ < 2092)
{
va_list ap;
va_start(ap, format);
- verrorSupplemental(loc, format, ap);
+ verrorReportSupplemental(loc, format, ap, ErrorKind.error);
va_end(ap);
}
else
@@ -221,7 +239,7 @@ else
{
va_list ap;
va_start(ap, format);
- verrorSupplemental(loc, format, ap);
+ verrorReportSupplemental(loc, format, ap, ErrorKind.error);
va_end(ap);
}
@@ -237,7 +255,7 @@ static if (__VERSION__ < 2092)
{
va_list ap;
va_start(ap, format);
- vwarning(loc, format, ap);
+ verrorReport(loc, format, ap, ErrorKind.warning);
va_end(ap);
}
else
@@ -245,7 +263,7 @@ else
{
va_list ap;
va_start(ap, format);
- vwarning(loc, format, ap);
+ verrorReport(loc, format, ap, ErrorKind.warning);
va_end(ap);
}
@@ -262,7 +280,7 @@ static if (__VERSION__ < 2092)
{
va_list ap;
va_start(ap, format);
- vwarningSupplemental(loc, format, ap);
+ verrorReportSupplemental(loc, format, ap, ErrorKind.warning);
va_end(ap);
}
else
@@ -270,7 +288,7 @@ else
{
va_list ap;
va_start(ap, format);
- vwarningSupplemental(loc, format, ap);
+ verrorReportSupplemental(loc, format, ap, ErrorKind.warning);
va_end(ap);
}
@@ -287,7 +305,7 @@ static if (__VERSION__ < 2092)
{
va_list ap;
va_start(ap, format);
- vdeprecation(loc, format, ap);
+ verrorReport(loc, format, ap, ErrorKind.deprecation);
va_end(ap);
}
else
@@ -295,7 +313,7 @@ else
{
va_list ap;
va_start(ap, format);
- vdeprecation(loc, format, ap);
+ verrorReport(loc, format, ap, ErrorKind.deprecation);
va_end(ap);
}
@@ -312,7 +330,7 @@ static if (__VERSION__ < 2092)
{
va_list ap;
va_start(ap, format);
- vdeprecationSupplemental(loc, format, ap);
+ verrorReportSupplemental(loc, format, ap, ErrorKind.deprecation);
va_end(ap);
}
else
@@ -320,7 +338,7 @@ else
{
va_list ap;
va_start(ap, format);
- vdeprecationSupplemental(loc, format, ap);
+ verrorReportSupplemental(loc, format, ap, ErrorKind.deprecation);
va_end(ap);
}
@@ -337,7 +355,7 @@ static if (__VERSION__ < 2092)
{
va_list ap;
va_start(ap, format);
- vmessage(loc, format, ap);
+ verrorReport(loc, format, ap, ErrorKind.message);
va_end(ap);
}
else
@@ -345,7 +363,7 @@ else
{
va_list ap;
va_start(ap, format);
- vmessage(loc, format, ap);
+ verrorReport(loc, format, ap, ErrorKind.message);
va_end(ap);
}
@@ -360,7 +378,7 @@ static if (__VERSION__ < 2092)
{
va_list ap;
va_start(ap, format);
- vmessage(Loc.initial, format, ap);
+ verrorReport(Loc.initial, format, ap, ErrorKind.message);
va_end(ap);
}
else
@@ -368,13 +386,13 @@ else
{
va_list ap;
va_start(ap, format);
- vmessage(Loc.initial, format, ap);
+ verrorReport(Loc.initial, format, ap, ErrorKind.message);
va_end(ap);
}
/**
* The type of the diagnostic handler
- * see verrorPrint for arguments
+ * see verrorReport for arguments
* Returns: true if error handling is done, false to continue printing to stderr
*/
alias DiagnosticHandler = bool delegate(const ref Loc location, Color headerColor, const(char)* header, const(char)* messageFormat, va_list args, const(char)* prefix1, const(char)* prefix2);
@@ -397,7 +415,7 @@ static if (__VERSION__ < 2092)
{
va_list ap;
va_start(ap, format);
- vtip(format, ap);
+ verrorReport(Loc.initial, format, ap, ErrorKind.tip);
va_end(ap);
}
else
@@ -405,104 +423,38 @@ else
{
va_list ap;
va_start(ap, format);
- vtip(format, ap);
+ verrorReport(Loc.initial, format, ap, ErrorKind.tip);
va_end(ap);
}
/**
- * Same as $(D error), but takes a va_list parameter, and optionally additional message prefixes.
+ * Implements $(D error), $(D warning), $(D deprecation), $(D message), and
+ * $(D tip). Report a diagnostic error, taking a va_list parameter, and
+ * optionally additional message prefixes. Whether the message gets printed
+ * depends on runtime values of DiagnosticReporting and global gagging.
* Params:
- * loc = location of error
- * format = printf-style format specification
- * ap = printf-style variadic arguments
- * p1 = additional message prefix
- * p2 = additional message prefix
- * header = title of error message
+ * loc = location of error
+ * format = printf-style format specification
+ * ap = printf-style variadic arguments
+ * kind = kind of error being printed
+ * p1 = additional message prefix
+ * p2 = additional message prefix
*/
-extern (C++) void verror(const ref Loc loc, const(char)* format, va_list ap, const(char)* p1 = null, const(char)* p2 = null, const(char)* header = "Error: ");
+extern (C++) void verrorReport(const ref Loc loc, const(char)* format, va_list ap, ErrorKind kind, const(char)* p1 = null, const(char)* p2 = null);
/**
- * Same as $(D errorSupplemental), but takes a va_list parameter.
+ * Implements $(D errorSupplemental), $(D warningSupplemental), and
+ * $(D deprecationSupplemental). Report an addition diagnostic error, taking a
+ * va_list parameter. Whether the message gets printed depends on runtime
+ * values of DiagnosticReporting and global gagging.
* Params:
- * loc = location of error
- * format = printf-style format specification
- * ap = printf-style variadic arguments
- */
-static if (__VERSION__ < 2092)
- extern (C++) void verrorSupplemental(const ref Loc loc, const(char)* format, va_list ap);
-else
- pragma(printf) extern (C++) void verrorSupplemental(const ref Loc loc, const(char)* format, va_list ap);
-
-/**
- * Same as $(D warning), but takes a va_list parameter.
- * Params:
- * loc = location of warning
- * format = printf-style format specification
- * ap = printf-style variadic arguments
- */
-static if (__VERSION__ < 2092)
- extern (C++) void vwarning(const ref Loc loc, const(char)* format, va_list ap);
-else
- pragma(printf) extern (C++) void vwarning(const ref Loc loc, const(char)* format, va_list ap);
-
-/**
- * Same as $(D warningSupplemental), but takes a va_list parameter.
- * Params:
- * loc = location of warning
- * format = printf-style format specification
- * ap = printf-style variadic arguments
+ * loc = location of error
+ * format = printf-style format specification
+ * ap = printf-style variadic arguments
+ * kind = kind of error being printed
*/
-static if (__VERSION__ < 2092)
- extern (C++) void vwarningSupplemental(const ref Loc loc, const(char)* format, va_list ap);
-else
- pragma(printf) extern (C++) void vwarningSupplemental(const ref Loc loc, const(char)* format, va_list ap);
-
-/**
- * Same as $(D deprecation), but takes a va_list parameter, and optionally additional message prefixes.
- * Params:
- * loc = location of deprecation
- * format = printf-style format specification
- * ap = printf-style variadic arguments
- * p1 = additional message prefix
- * p2 = additional message prefix
- */
-extern (C++) void vdeprecation(const ref Loc loc, const(char)* format, va_list ap, const(char)* p1 = null, const(char)* p2 = null);
-
-/**
- * Same as $(D message), but takes a va_list parameter.
- * Params:
- * loc = location of message
- * format = printf-style format specification
- * ap = printf-style variadic arguments
- */
-static if (__VERSION__ < 2092)
- extern (C++) void vmessage(const ref Loc loc, const(char)* format, va_list ap);
-else
- pragma(printf) extern (C++) void vmessage(const ref Loc loc, const(char)* format, va_list ap);
-
-/**
- * Same as $(D tip), but takes a va_list parameter.
- * Params:
- * format = printf-style format specification
- * ap = printf-style variadic arguments
- */
-static if (__VERSION__ < 2092)
- extern (C++) void vtip(const(char)* format, va_list ap);
-else
- pragma(printf) extern (C++) void vtip(const(char)* format, va_list ap);
-
-/**
- * Same as $(D deprecationSupplemental), but takes a va_list parameter.
- * Params:
- * loc = location of deprecation
- * format = printf-style format specification
- * ap = printf-style variadic arguments
- */
-static if (__VERSION__ < 2092)
- extern (C++) void vdeprecationSupplemental(const ref Loc loc, const(char)* format, va_list ap);
-else
- pragma(printf) extern (C++) void vdeprecationSupplemental(const ref Loc loc, const(char)* format, va_list ap);
+extern (C++) void verrorReportSupplemental(const ref Loc loc, const(char)* format, va_list ap, ErrorKind kind);
/**
* The type of the fatal error handler
@@ -526,4 +478,4 @@ extern (C++) void fatal();
* Try to stop forgetting to remove the breakpoints from
* release builds.
*/
-extern (C++) void halt();
+extern (C++) void halt() @safe;
diff --git a/gcc/d/dmd/errors.h b/gcc/d/dmd/errors.h
index cc72811..c6b5975 100644
--- a/gcc/d/dmd/errors.h
+++ b/gcc/d/dmd/errors.h
@@ -14,6 +14,15 @@
struct Loc;
+enum class ErrorKind
+{
+ warning = 0,
+ deprecation = 1,
+ error = 2,
+ tip = 3,
+ message = 4,
+};
+
bool isConsoleColorSupported();
#if defined(__GNUC__)
@@ -30,17 +39,12 @@ D_ATTRIBUTE_FORMAT(2, 3) void deprecationSupplemental(const Loc& loc, const char
D_ATTRIBUTE_FORMAT(2, 3) void error(const Loc& loc, const char *format, ...);
D_ATTRIBUTE_FORMAT(4, 5) void error(const char *filename, unsigned linnum, unsigned charnum, const char *format, ...);
D_ATTRIBUTE_FORMAT(2, 3) void errorSupplemental(const Loc& loc, const char *format, ...);
-D_ATTRIBUTE_FORMAT(2, 0) void verror(const Loc& loc, const char *format, va_list ap, const char *p1 = NULL, const char *p2 = NULL, const char *header = "Error: ");
-D_ATTRIBUTE_FORMAT(2, 0) void verrorSupplemental(const Loc& loc, const char *format, va_list ap);
-D_ATTRIBUTE_FORMAT(2, 0) void vwarning(const Loc& loc, const char *format, va_list);
-D_ATTRIBUTE_FORMAT(2, 0) void vwarningSupplemental(const Loc& loc, const char *format, va_list ap);
-D_ATTRIBUTE_FORMAT(2, 0) void vdeprecation(const Loc& loc, const char *format, va_list ap, const char *p1 = NULL, const char *p2 = NULL);
-D_ATTRIBUTE_FORMAT(2, 0) void vdeprecationSupplemental(const Loc& loc, const char *format, va_list ap);
D_ATTRIBUTE_FORMAT(1, 2) void message(const char *format, ...);
D_ATTRIBUTE_FORMAT(2, 3) void message(const Loc& loc, const char *format, ...);
-D_ATTRIBUTE_FORMAT(2, 0) void vmessage(const Loc& loc, const char *format, va_list ap);
D_ATTRIBUTE_FORMAT(1, 2) void tip(const char *format, ...);
-D_ATTRIBUTE_FORMAT(1, 0) void vtip(const char *format, va_list ap);
+
+D_ATTRIBUTE_FORMAT(2, 0) void verrorReport(const Loc& loc, const char *format, va_list ap, const char *p1 = NULL, const char *p2 = NULL);
+D_ATTRIBUTE_FORMAT(2, 0) void verrorReportSupplemental(const Loc& loc, const char* format, va_list ap, ErrorKind kind);
#if defined(__GNUC__) || defined(__clang__)
#define D_ATTRIBUTE_NORETURN __attribute__((noreturn))
diff --git a/gcc/d/dmd/errorsink.d b/gcc/d/dmd/errorsink.d
index e57c2b6..e14829e 100644
--- a/gcc/d/dmd/errorsink.d
+++ b/gcc/d/dmd/errorsink.d
@@ -27,6 +27,8 @@ abstract class ErrorSink
void warning(const ref Loc loc, const(char)* format, ...);
+ void warningSupplemental(const ref Loc loc, const(char)* format, ...);
+
void message(const ref Loc loc, const(char)* format, ...);
void deprecation(const ref Loc loc, const(char)* format, ...);
@@ -49,6 +51,8 @@ class ErrorSinkNull : ErrorSink
void warning(const ref Loc loc, const(char)* format, ...) { }
+ void warningSupplemental(const ref Loc loc, const(char)* format, ...) { }
+
void message(const ref Loc loc, const(char)* format, ...) { }
void deprecation(const ref Loc loc, const(char)* format, ...) { }
@@ -104,6 +108,8 @@ class ErrorSinkStderr : ErrorSink
va_end(ap);
}
+ void warningSupplemental(const ref Loc loc, const(char)* format, ...) { }
+
void deprecation(const ref Loc loc, const(char)* format, ...)
{
fputs("Deprecation: ", stderr);
diff --git a/gcc/d/dmd/escape.d b/gcc/d/dmd/escape.d
index efd6bea..f817a4e 100644
--- a/gcc/d/dmd/escape.d
+++ b/gcc/d/dmd/escape.d
@@ -2561,7 +2561,7 @@ private void addMaybe(VarDeclaration va, VarDeclaration v)
}
// `setUnsafePreview` partially evaluated for dip1000
-private bool setUnsafeDIP1000(Scope* sc, bool gag, Loc loc, const(char)* msg,
+bool setUnsafeDIP1000(Scope* sc, bool gag, Loc loc, const(char)* msg,
RootObject arg0 = null, RootObject arg1 = null, RootObject arg2 = null)
{
return setUnsafePreview(sc, global.params.useDIP1000, gag, loc, msg, arg0, arg1, arg2);
diff --git a/gcc/d/dmd/expression.d b/gcc/d/dmd/expression.d
index 9477867..07cc8d4 100644
--- a/gcc/d/dmd/expression.d
+++ b/gcc/d/dmd/expression.d
@@ -421,7 +421,7 @@ int expandAliasThisTuples(Expressions* exps, size_t starti = 0)
* Returns:
* template for that function, otherwise null
*/
-TemplateDeclaration getFuncTemplateDecl(Dsymbol s)
+TemplateDeclaration getFuncTemplateDecl(Dsymbol s) @safe
{
FuncDeclaration f = s.isFuncDeclaration();
if (f && f.parent)
@@ -636,7 +636,7 @@ private:
* true if x1 is x2
* else false
*/
-bool RealIdentical(real_t x1, real_t x2)
+bool RealIdentical(real_t x1, real_t x2) @safe
{
return (CTFloat.isNaN(x1) && CTFloat.isNaN(x2)) || CTFloat.isIdentical(x1, x2);
}
@@ -648,7 +648,7 @@ bool RealIdentical(real_t x1, real_t x2)
* (foo).size
* cast(foo).size
*/
-DotIdExp typeDotIdExp(const ref Loc loc, Type type, Identifier ident)
+DotIdExp typeDotIdExp(const ref Loc loc, Type type, Identifier ident) @safe
{
return new DotIdExp(loc, new TypeExp(loc, type), ident);
}
@@ -738,7 +738,7 @@ extern (C++) abstract class Expression : ASTNode
Loc loc; // file location
const EXP op; // to minimize use of dynamic_cast
- extern (D) this(const ref Loc loc, EXP op) scope
+ extern (D) this(const ref Loc loc, EXP op) scope @safe
{
//printf("Expression::Expression(op = %d) this = %p\n", op, this);
this.loc = loc;
@@ -825,7 +825,7 @@ extern (C++) abstract class Expression : ASTNode
{
va_list ap;
va_start(ap, format);
- .verror(loc, format, ap);
+ .verrorReport(loc, format, ap, ErrorKind.error);
va_end(ap);
}
}
@@ -837,7 +837,7 @@ extern (C++) abstract class Expression : ASTNode
va_list ap;
va_start(ap, format);
- .verrorSupplemental(loc, format, ap);
+ .verrorReportSupplemental(loc, format, ap, ErrorKind.error);
va_end(ap);
}
@@ -847,7 +847,7 @@ extern (C++) abstract class Expression : ASTNode
{
va_list ap;
va_start(ap, format);
- .vwarning(loc, format, ap);
+ .verrorReport(loc, format, ap, ErrorKind.warning);
va_end(ap);
}
}
@@ -858,7 +858,7 @@ extern (C++) abstract class Expression : ASTNode
{
va_list ap;
va_start(ap, format);
- .vdeprecation(loc, format, ap);
+ .verrorReport(loc, format, ap, ErrorKind.deprecation);
va_end(ap);
}
}
@@ -871,7 +871,7 @@ extern (C++) abstract class Expression : ASTNode
{
va_list ap;
va_start(ap, format);
- .verror(loc, format, ap);
+ .verrorReport(loc, format, ap, ErrorKind.error);
va_end(ap);
}
}
@@ -883,7 +883,7 @@ extern (C++) abstract class Expression : ASTNode
va_list ap;
va_start(ap, format);
- .verrorSupplemental(loc, format, ap);
+ .verrorReportSupplemental(loc, format, ap, ErrorKind.error);
va_end(ap);
}
@@ -893,7 +893,7 @@ extern (C++) abstract class Expression : ASTNode
{
va_list ap;
va_start(ap, format);
- .vwarning(loc, format, ap);
+ .verrorReport(loc, format, ap, ErrorKind.warning);
va_end(ap);
}
}
@@ -904,7 +904,7 @@ extern (C++) abstract class Expression : ASTNode
{
va_list ap;
va_start(ap, format);
- .vdeprecation(loc, format, ap);
+ .verrorReport(loc, format, ap, ErrorKind.deprecation);
va_end(ap);
}
}
@@ -913,7 +913,7 @@ extern (C++) abstract class Expression : ASTNode
/**********************************
* Combine e1 and e2 by CommaExp if both are not NULL.
*/
- extern (D) static Expression combine(Expression e1, Expression e2)
+ extern (D) static Expression combine(Expression e1, Expression e2) @safe
{
if (e1)
{
@@ -928,12 +928,12 @@ extern (C++) abstract class Expression : ASTNode
return e1;
}
- extern (D) static Expression combine(Expression e1, Expression e2, Expression e3)
+ extern (D) static Expression combine(Expression e1, Expression e2, Expression e3) @safe
{
return combine(combine(e1, e2), e3);
}
- extern (D) static Expression combine(Expression e1, Expression e2, Expression e3, Expression e4)
+ extern (D) static Expression combine(Expression e1, Expression e2, Expression e3, Expression e4) @safe
{
return combine(combine(e1, e2), combine(e3, e4));
}
@@ -944,7 +944,7 @@ extern (C++) abstract class Expression : ASTNode
* is returned via e0.
* Otherwise 'e' is directly returned and e0 is set to NULL.
*/
- extern (D) static Expression extractLast(Expression e, out Expression e0)
+ extern (D) static Expression extractLast(Expression e, out Expression e0) @safe
{
if (e.op != EXP.comma)
{
@@ -1485,6 +1485,7 @@ extern (C++) abstract class Expression : ASTNode
else
{
sc.varDecl.storage_class |= STC.system;
+ sc.varDecl.systemInferred = true;
}
}
return false;
@@ -1620,7 +1621,9 @@ extern (C++) abstract class Expression : ASTNode
{
//printf("checkRightThis sc.intypeof = %d, ad = %p, func = %p, fdthis = %p\n",
// sc.intypeof, sc.getStructClassScope(), func, fdthis);
- error("need `this` for `%s` of type `%s`", ve.var.toChars(), ve.var.type.toChars());
+ auto t = ve.var.isThis();
+ assert(t);
+ error("accessing non-static variable `%s` requires an instance of `%s`", ve.var.toChars(), t.toChars());
return true;
}
}
@@ -2157,7 +2160,7 @@ extern (C++) final class VoidInitExp : Expression
VarDeclaration var; /// the variable from where the void value came from, null if not known
/// Useful for error messages
- extern (D) this(VarDeclaration var)
+ extern (D) this(VarDeclaration var) @safe
{
super(var.loc, EXP.void_);
this.var = var;
@@ -2183,7 +2186,7 @@ extern (C++) final class RealExp : Expression
{
real_t value;
- extern (D) this(const ref Loc loc, real_t value, Type type)
+ extern (D) this(const ref Loc loc, real_t value, Type type) @safe
{
super(loc, EXP.float64);
//printf("RealExp::RealExp(%Lg)\n", value);
@@ -2191,7 +2194,7 @@ extern (C++) final class RealExp : Expression
this.type = type;
}
- static RealExp create(const ref Loc loc, real_t value, Type type)
+ static RealExp create(const ref Loc loc, real_t value, Type type) @safe
{
return new RealExp(loc, value, type);
}
@@ -2266,7 +2269,7 @@ extern (C++) final class ComplexExp : Expression
{
complex_t value;
- extern (D) this(const ref Loc loc, complex_t value, Type type)
+ extern (D) this(const ref Loc loc, complex_t value, Type type) @safe
{
super(loc, EXP.complex80);
this.value = value;
@@ -2274,7 +2277,7 @@ extern (C++) final class ComplexExp : Expression
//printf("ComplexExp::ComplexExp(%s)\n", toChars());
}
- static ComplexExp create(const ref Loc loc, complex_t value, Type type)
+ static ComplexExp create(const ref Loc loc, complex_t value, Type type) @safe
{
return new ComplexExp(loc, value, type);
}
@@ -2358,13 +2361,13 @@ extern (C++) class IdentifierExp : Expression
Identifier ident;
bool parens; // if it appears as (identifier)
- extern (D) this(const ref Loc loc, Identifier ident) scope
+ extern (D) this(const ref Loc loc, Identifier ident) scope @safe
{
super(loc, EXP.identifier);
this.ident = ident;
}
- static IdentifierExp create(const ref Loc loc, Identifier ident)
+ static IdentifierExp create(const ref Loc loc, Identifier ident) @safe
{
return new IdentifierExp(loc, ident);
}
@@ -2411,7 +2414,7 @@ extern (C++) final class DsymbolExp : Expression
Dsymbol s;
bool hasOverloads;
- extern (D) this(const ref Loc loc, Dsymbol s, bool hasOverloads = true)
+ extern (D) this(const ref Loc loc, Dsymbol s, bool hasOverloads = true) @safe
{
super(loc, EXP.dSymbol);
this.s = s;
@@ -2441,13 +2444,13 @@ extern (C++) class ThisExp : Expression
{
VarDeclaration var;
- extern (D) this(const ref Loc loc)
+ extern (D) this(const ref Loc loc) @safe
{
super(loc, EXP.this_);
//printf("ThisExp::ThisExp() loc = %d\n", loc.linnum);
}
- this(const ref Loc loc, const EXP tok)
+ this(const ref Loc loc, const EXP tok) @safe
{
super(loc, tok);
//printf("ThisExp::ThisExp() loc = %d\n", loc.linnum);
@@ -2489,7 +2492,7 @@ extern (C++) class ThisExp : Expression
*/
extern (C++) final class SuperExp : ThisExp
{
- extern (D) this(const ref Loc loc)
+ extern (D) this(const ref Loc loc) @safe
{
super(loc, EXP.super_);
}
@@ -2519,7 +2522,7 @@ extern (C++) final class SuperExp : ThisExp
*/
extern (C++) final class NullExp : Expression
{
- extern (D) this(const ref Loc loc, Type type = null) scope
+ extern (D) this(const ref Loc loc, Type type = null) scope @safe
{
super(loc, EXP.null_);
this.type = type;
@@ -2983,7 +2986,7 @@ extern (C++) final class TupleExp : Expression
Expressions* exps;
- extern (D) this(const ref Loc loc, Expression e0, Expressions* exps)
+ extern (D) this(const ref Loc loc, Expression e0, Expressions* exps) @safe
{
super(loc, EXP.tuple);
//printf("TupleExp(this = %p)\n", this);
@@ -2991,7 +2994,7 @@ extern (C++) final class TupleExp : Expression
this.exps = exps;
}
- extern (D) this(const ref Loc loc, Expressions* exps)
+ extern (D) this(const ref Loc loc, Expressions* exps) @safe
{
super(loc, EXP.tuple);
//printf("TupleExp(this = %p)\n", this);
@@ -3032,7 +3035,7 @@ extern (C++) final class TupleExp : Expression
}
}
- static TupleExp create(const ref Loc loc, Expressions* exps)
+ static TupleExp create(const ref Loc loc, Expressions* exps) @safe
{
return new TupleExp(loc, exps);
}
@@ -3088,7 +3091,7 @@ extern (C++) final class ArrayLiteralExp : Expression
Expressions* elements;
- extern (D) this(const ref Loc loc, Type type, Expressions* elements)
+ extern (D) this(const ref Loc loc, Type type, Expressions* elements) @safe
{
super(loc, EXP.arrayLiteral);
this.type = type;
@@ -3103,7 +3106,7 @@ extern (C++) final class ArrayLiteralExp : Expression
elements.push(e);
}
- extern (D) this(const ref Loc loc, Type type, Expression basis, Expressions* elements)
+ extern (D) this(const ref Loc loc, Type type, Expression basis, Expressions* elements) @safe
{
super(loc, EXP.arrayLiteral);
this.type = type;
@@ -3111,7 +3114,7 @@ extern (C++) final class ArrayLiteralExp : Expression
this.elements = elements;
}
- static ArrayLiteralExp create(const ref Loc loc, Expressions* elements)
+ static ArrayLiteralExp create(const ref Loc loc, Expressions* elements) @safe
{
return new ArrayLiteralExp(loc, null, elements);
}
@@ -3248,7 +3251,7 @@ extern (C++) final class AssocArrayLiteralExp : Expression
Expressions* keys;
Expressions* values;
- extern (D) this(const ref Loc loc, Expressions* keys, Expressions* values)
+ extern (D) this(const ref Loc loc, Expressions* keys, Expressions* values) @safe
{
super(loc, EXP.assocArrayLiteral);
assert(keys.length == values.length);
@@ -3347,7 +3350,7 @@ extern (C++) final class StructLiteralExp : Expression
bool isOriginal = false; /// used when moving instances to indicate `this is this.origin`
OwnedBy ownedByCtfe = OwnedBy.code;
- extern (D) this(const ref Loc loc, StructDeclaration sd, Expressions* elements, Type stype = null)
+ extern (D) this(const ref Loc loc, StructDeclaration sd, Expressions* elements, Type stype = null) @safe
{
super(loc, EXP.structLiteral);
this.sd = sd;
@@ -3526,7 +3529,7 @@ extern (C++) final class CompoundLiteralExp : Expression
{
Initializer initializer; /// initializer-list
- extern (D) this(const ref Loc loc, Type type_name, Initializer initializer)
+ extern (D) this(const ref Loc loc, Type type_name, Initializer initializer) @safe
{
super(loc, EXP.compoundLiteral);
super.type = type_name;
@@ -3547,7 +3550,7 @@ extern (C++) final class TypeExp : Expression
{
bool parens; // if this is a parenthesized expression
- extern (D) this(const ref Loc loc, Type type)
+ extern (D) this(const ref Loc loc, Type type) @safe
{
super(loc, EXP.type);
//printf("TypeExp::TypeExp(%s)\n", type.toChars());
@@ -3589,7 +3592,7 @@ extern (C++) final class ScopeExp : Expression
{
ScopeDsymbol sds;
- extern (D) this(const ref Loc loc, ScopeDsymbol sds)
+ extern (D) this(const ref Loc loc, ScopeDsymbol sds) @safe
{
super(loc, EXP.scope_);
//printf("ScopeExp::ScopeExp(sds = '%s')\n", sds.toChars());
@@ -3644,7 +3647,7 @@ extern (C++) final class TemplateExp : Expression
TemplateDeclaration td;
FuncDeclaration fd;
- extern (D) this(const ref Loc loc, TemplateDeclaration td, FuncDeclaration fd = null)
+ extern (D) this(const ref Loc loc, TemplateDeclaration td, FuncDeclaration fd = null) @safe
{
super(loc, EXP.template_);
//printf("TemplateExp(): %s\n", td.toChars());
@@ -3705,7 +3708,7 @@ extern (C++) final class NewExp : Expression
/// The fields are still separate for backwards compatibility
extern (D) ArgumentList argumentList() { return ArgumentList(arguments, names); }
- extern (D) this(const ref Loc loc, Expression thisexp, Type newtype, Expressions* arguments, Identifiers* names = null)
+ extern (D) this(const ref Loc loc, Expression thisexp, Type newtype, Expressions* arguments, Identifiers* names = null) @safe
{
super(loc, EXP.new_);
this.thisexp = thisexp;
@@ -3714,7 +3717,7 @@ extern (C++) final class NewExp : Expression
this.names = names;
}
- static NewExp create(const ref Loc loc, Expression thisexp, Type newtype, Expressions* arguments)
+ static NewExp create(const ref Loc loc, Expression thisexp, Type newtype, Expressions* arguments) @safe
{
return new NewExp(loc, thisexp, newtype, arguments);
}
@@ -3743,7 +3746,7 @@ extern (C++) final class NewAnonClassExp : Expression
ClassDeclaration cd; // class being instantiated
Expressions* arguments; // Array of Expression's to call class constructor
- extern (D) this(const ref Loc loc, Expression thisexp, ClassDeclaration cd, Expressions* arguments)
+ extern (D) this(const ref Loc loc, Expression thisexp, ClassDeclaration cd, Expressions* arguments) @safe
{
super(loc, EXP.newAnonymousClass);
this.thisexp = thisexp;
@@ -3770,7 +3773,7 @@ extern (C++) class SymbolExp : Expression
Dsymbol originalScope; // original scope before inlining
bool hasOverloads;
- extern (D) this(const ref Loc loc, EXP op, Declaration var, bool hasOverloads)
+ extern (D) this(const ref Loc loc, EXP op, Declaration var, bool hasOverloads) @safe
{
super(loc, op);
assert(var);
@@ -3798,7 +3801,11 @@ extern (C++) final class SymOffExp : SymbolExp
// FIXME: This error report will never be handled anyone.
// It should be done before the SymOffExp construction.
if (v.needThis())
- .error(loc, "need `this` for address of `%s`", v.toChars());
+ {
+ auto t = v.isThis();
+ assert(t);
+ .error(loc, "taking the address of non-static variable `%s` requires an instance of `%s`", v.toChars(), t.toChars());
+ }
hasOverloads = false;
}
super(loc, EXP.symbolOffset, var, hasOverloads);
@@ -3822,7 +3829,7 @@ extern (C++) final class SymOffExp : SymbolExp
extern (C++) final class VarExp : SymbolExp
{
bool delegateWasExtracted;
- extern (D) this(const ref Loc loc, Declaration var, bool hasOverloads = true)
+ extern (D) this(const ref Loc loc, Declaration var, bool hasOverloads = true) @safe
{
if (var.isVarDeclaration())
hasOverloads = false;
@@ -3833,7 +3840,7 @@ extern (C++) final class VarExp : SymbolExp
this.type = var.type;
}
- static VarExp create(const ref Loc loc, Declaration var, bool hasOverloads = true)
+ static VarExp create(const ref Loc loc, Declaration var, bool hasOverloads = true) @safe
{
return new VarExp(loc, var, hasOverloads);
}
@@ -4242,7 +4249,7 @@ extern (C++) final class DeclarationExp : Expression
{
Dsymbol declaration;
- extern (D) this(const ref Loc loc, Dsymbol declaration)
+ extern (D) this(const ref Loc loc, Dsymbol declaration) @safe
{
super(loc, EXP.declaration);
this.declaration = declaration;
@@ -4275,7 +4282,7 @@ extern (C++) final class TypeidExp : Expression
{
RootObject obj;
- extern (D) this(const ref Loc loc, RootObject o)
+ extern (D) this(const ref Loc loc, RootObject o) @safe
{
super(loc, EXP.typeid_);
this.obj = o;
@@ -4300,7 +4307,7 @@ extern (C++) final class TraitsExp : Expression
Identifier ident;
Objects* args;
- extern (D) this(const ref Loc loc, Identifier ident, Objects* args)
+ extern (D) this(const ref Loc loc, Identifier ident, Objects* args) @safe
{
super(loc, EXP.traits);
this.ident = ident;
@@ -4325,7 +4332,7 @@ extern (C++) final class TraitsExp : Expression
*/
extern (C++) final class HaltExp : Expression
{
- extern (D) this(const ref Loc loc)
+ extern (D) this(const ref Loc loc) @safe
{
super(loc, EXP.halt);
}
@@ -4349,7 +4356,7 @@ extern (C++) final class IsExp : Expression
TOK tok; // ':' or '=='
TOK tok2; // 'struct', 'union', etc.
- extern (D) this(const ref Loc loc, Type targ, Identifier id, TOK tok, Type tspec, TOK tok2, TemplateParameters* parameters) scope
+ extern (D) this(const ref Loc loc, Type targ, Identifier id, TOK tok, Type tspec, TOK tok2, TemplateParameters* parameters) scope @safe
{
super(loc, EXP.is_);
this.targ = targ;
@@ -4388,7 +4395,7 @@ extern (C++) abstract class UnaExp : Expression
{
Expression e1;
- extern (D) this(const ref Loc loc, EXP op, Expression e1) scope
+ extern (D) this(const ref Loc loc, EXP op, Expression e1) scope @safe
{
super(loc, op);
this.e1 = e1;
@@ -4461,7 +4468,7 @@ extern (C++) abstract class BinExp : Expression
Type att1; // Save alias this type to detect recursion
Type att2; // Save alias this type to detect recursion
- extern (D) this(const ref Loc loc, EXP op, Expression e1, Expression e2) scope
+ extern (D) this(const ref Loc loc, EXP op, Expression e1, Expression e2) scope @safe
{
super(loc, op);
this.e1 = e1;
@@ -4752,7 +4759,7 @@ extern (C++) abstract class BinExp : Expression
*/
extern (C++) class BinAssignExp : BinExp
{
- extern (D) this(const ref Loc loc, EXP op, Expression e1, Expression e2) scope
+ extern (D) this(const ref Loc loc, EXP op, Expression e1, Expression e2) scope @safe
{
super(loc, op, e1, e2);
}
@@ -4789,7 +4796,7 @@ extern (C++) final class MixinExp : Expression
{
Expressions* exps;
- extern (D) this(const ref Loc loc, Expressions* exps)
+ extern (D) this(const ref Loc loc, Expressions* exps) @safe
{
super(loc, EXP.mixin_);
this.exps = exps;
@@ -4837,7 +4844,7 @@ extern (C++) final class MixinExp : Expression
*/
extern (C++) final class ImportExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e)
+ extern (D) this(const ref Loc loc, Expression e) @safe
{
super(loc, EXP.import_, e);
}
@@ -4857,7 +4864,7 @@ extern (C++) final class AssertExp : UnaExp
{
Expression msg;
- extern (D) this(const ref Loc loc, Expression e, Expression msg = null)
+ extern (D) this(const ref Loc loc, Expression e, Expression msg = null) @safe
{
super(loc, EXP.assert_, e);
this.msg = msg;
@@ -4908,13 +4915,13 @@ extern (C++) final class DotIdExp : UnaExp
bool wantsym; // do not replace Symbol with its initializer during semantic()
bool arrow; // ImportC: if -> instead of .
- extern (D) this(const ref Loc loc, Expression e, Identifier ident)
+ extern (D) this(const ref Loc loc, Expression e, Identifier ident) @safe
{
super(loc, EXP.dotIdentifier, e);
this.ident = ident;
}
- static DotIdExp create(const ref Loc loc, Expression e, Identifier ident)
+ static DotIdExp create(const ref Loc loc, Expression e, Identifier ident) @safe
{
return new DotIdExp(loc, e, ident);
}
@@ -4932,7 +4939,7 @@ extern (C++) final class DotTemplateExp : UnaExp
{
TemplateDeclaration td;
- extern (D) this(const ref Loc loc, Expression e, TemplateDeclaration td)
+ extern (D) this(const ref Loc loc, Expression e, TemplateDeclaration td) @safe
{
super(loc, EXP.dotTemplateDeclaration, e);
this.td = td;
@@ -4963,7 +4970,7 @@ extern (C++) final class DotVarExp : UnaExp
Declaration var;
bool hasOverloads;
- extern (D) this(const ref Loc loc, Expression e, Declaration var, bool hasOverloads = true)
+ extern (D) this(const ref Loc loc, Expression e, Declaration var, bool hasOverloads = true) @safe
{
if (var.isVarDeclaration())
hasOverloads = false;
@@ -5054,7 +5061,7 @@ extern (C++) final class DotTemplateInstanceExp : UnaExp
this.ti = new TemplateInstance(loc, name, tiargs);
}
- extern (D) this(const ref Loc loc, Expression e, TemplateInstance ti)
+ extern (D) this(const ref Loc loc, Expression e, TemplateInstance ti) @safe
{
super(loc, EXP.dotTemplateInstance, e);
this.ti = ti;
@@ -5147,7 +5154,7 @@ extern (C++) final class DelegateExp : UnaExp
bool hasOverloads;
VarDeclaration vthis2; // container for multi-context
- extern (D) this(const ref Loc loc, Expression e, FuncDeclaration f, bool hasOverloads = true, VarDeclaration vthis2 = null)
+ extern (D) this(const ref Loc loc, Expression e, FuncDeclaration f, bool hasOverloads = true, VarDeclaration vthis2 = null) @safe
{
super(loc, EXP.delegate_, e);
this.func = f;
@@ -5167,7 +5174,7 @@ extern (C++) final class DotTypeExp : UnaExp
{
Dsymbol sym; // symbol that represents a type
- extern (D) this(const ref Loc loc, Expression e, Dsymbol s)
+ extern (D) this(const ref Loc loc, Expression e, Dsymbol s) @safe
{
super(loc, EXP.dotType, e);
this.sym = s;
@@ -5222,14 +5229,14 @@ extern (C++) final class CallExp : UnaExp
/// The fields are still separate for backwards compatibility
extern (D) ArgumentList argumentList() { return ArgumentList(arguments, names); }
- extern (D) this(const ref Loc loc, Expression e, Expressions* exps, Identifiers* names = null)
+ extern (D) this(const ref Loc loc, Expression e, Expressions* exps, Identifiers* names = null) @safe
{
super(loc, EXP.call, e);
this.arguments = exps;
this.names = names;
}
- extern (D) this(const ref Loc loc, Expression e)
+ extern (D) this(const ref Loc loc, Expression e) @safe
{
super(loc, EXP.call, e);
}
@@ -5264,12 +5271,12 @@ extern (C++) final class CallExp : UnaExp
this.f = fd;
}
- static CallExp create(const ref Loc loc, Expression e, Expressions* exps)
+ static CallExp create(const ref Loc loc, Expression e, Expressions* exps) @safe
{
return new CallExp(loc, e, exps);
}
- static CallExp create(const ref Loc loc, Expression e)
+ static CallExp create(const ref Loc loc, Expression e) @safe
{
return new CallExp(loc, e);
}
@@ -5377,7 +5384,7 @@ TypeFunction calledFunctionType(CallExp ce)
return null;
}
-FuncDeclaration isFuncAddress(Expression e, bool* hasOverloads = null)
+FuncDeclaration isFuncAddress(Expression e, bool* hasOverloads = null) @safe
{
if (auto ae = e.isAddrExp())
{
@@ -5418,12 +5425,12 @@ FuncDeclaration isFuncAddress(Expression e, bool* hasOverloads = null)
*/
extern (C++) final class AddrExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e)
+ extern (D) this(const ref Loc loc, Expression e) @safe
{
super(loc, EXP.address, e);
}
- extern (D) this(const ref Loc loc, Expression e, Type t)
+ extern (D) this(const ref Loc loc, Expression e, Type t) @safe
{
this(loc, e);
type = t;
@@ -5440,14 +5447,14 @@ extern (C++) final class AddrExp : UnaExp
*/
extern (C++) final class PtrExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e)
+ extern (D) this(const ref Loc loc, Expression e) @safe
{
super(loc, EXP.star, e);
//if (e.type)
// type = ((TypePointer *)e.type).next;
}
- extern (D) this(const ref Loc loc, Expression e, Type t)
+ extern (D) this(const ref Loc loc, Expression e, Type t) @safe
{
super(loc, EXP.star, e);
type = t;
@@ -5493,7 +5500,7 @@ extern (C++) final class PtrExp : UnaExp
*/
extern (C++) final class NegExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e)
+ extern (D) this(const ref Loc loc, Expression e) @safe
{
super(loc, EXP.negate, e);
}
@@ -5509,7 +5516,7 @@ extern (C++) final class NegExp : UnaExp
*/
extern (C++) final class UAddExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e) scope
+ extern (D) this(const ref Loc loc, Expression e) scope @safe
{
super(loc, EXP.uadd, e);
}
@@ -5525,7 +5532,7 @@ extern (C++) final class UAddExp : UnaExp
*/
extern (C++) final class ComExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e)
+ extern (D) this(const ref Loc loc, Expression e) @safe
{
super(loc, EXP.tilde, e);
}
@@ -5541,7 +5548,7 @@ extern (C++) final class ComExp : UnaExp
*/
extern (C++) final class NotExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e)
+ extern (D) this(const ref Loc loc, Expression e) @safe
{
super(loc, EXP.not, e);
}
@@ -5561,7 +5568,7 @@ extern (C++) final class DeleteExp : UnaExp
{
bool isRAII; // true if called automatically as a result of scoped destruction
- extern (D) this(const ref Loc loc, Expression e, bool isRAII)
+ extern (D) this(const ref Loc loc, Expression e, bool isRAII) @safe
{
super(loc, EXP.delete_, e);
this.isRAII = isRAII;
@@ -5585,7 +5592,7 @@ extern (C++) final class CastExp : UnaExp
Type to; // type to cast to
ubyte mod = cast(ubyte)~0; // MODxxxxx
- extern (D) this(const ref Loc loc, Expression e, Type t)
+ extern (D) this(const ref Loc loc, Expression e, Type t) @safe
{
super(loc, EXP.cast_, e);
this.to = t;
@@ -5593,7 +5600,7 @@ extern (C++) final class CastExp : UnaExp
/* For cast(const) and cast(immutable)
*/
- extern (D) this(const ref Loc loc, Expression e, ubyte mod)
+ extern (D) this(const ref Loc loc, Expression e, ubyte mod) @safe
{
super(loc, EXP.cast_, e);
this.mod = mod;
@@ -5647,14 +5654,14 @@ extern (C++) final class VectorExp : UnaExp
uint dim = ~0; // number of elements in the vector
OwnedBy ownedByCtfe = OwnedBy.code;
- extern (D) this(const ref Loc loc, Expression e, Type t)
+ extern (D) this(const ref Loc loc, Expression e, Type t) @safe
{
super(loc, EXP.vector, e);
assert(t.ty == Tvector);
to = cast(TypeVector)t;
}
- static VectorExp create(const ref Loc loc, Expression e, Type t)
+ static VectorExp create(const ref Loc loc, Expression e, Type t) @safe
{
return new VectorExp(loc, e, t);
}
@@ -5683,7 +5690,7 @@ extern (C++) final class VectorExp : UnaExp
*/
extern (C++) final class VectorArrayExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e1)
+ extern (D) this(const ref Loc loc, Expression e1) @safe
{
super(loc, EXP.vectorArray, e1);
}
@@ -5727,14 +5734,14 @@ extern (C++) final class SliceExp : UnaExp
mixin(generateBitFields!(BitFields, ubyte));
/************************************************************/
- extern (D) this(const ref Loc loc, Expression e1, IntervalExp ie)
+ extern (D) this(const ref Loc loc, Expression e1, IntervalExp ie) @safe
{
super(loc, EXP.slice, e1);
this.upr = ie ? ie.upr : null;
this.lwr = ie ? ie.lwr : null;
}
- extern (D) this(const ref Loc loc, Expression e1, Expression lwr, Expression upr)
+ extern (D) this(const ref Loc loc, Expression e1, Expression lwr, Expression upr) @safe
{
super(loc, EXP.slice, e1);
this.upr = upr;
@@ -5784,7 +5791,7 @@ extern (C++) final class SliceExp : UnaExp
*/
extern (C++) final class ArrayLengthExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e1)
+ extern (D) this(const ref Loc loc, Expression e1) @safe
{
super(loc, EXP.arrayLength, e1);
}
@@ -5815,7 +5822,7 @@ extern (C++) final class ArrayExp : UnaExp
arguments.push(index);
}
- extern (D) this(const ref Loc loc, Expression e1, Expressions* args)
+ extern (D) this(const ref Loc loc, Expression e1, Expressions* args) @safe
{
super(loc, EXP.array, e1);
arguments = args;
@@ -5852,7 +5859,7 @@ extern (C++) final class ArrayExp : UnaExp
*/
extern (C++) final class DotExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.dot, e1, e2);
}
@@ -5878,7 +5885,7 @@ extern (C++) final class CommaExp : BinExp
bool allowCommaExp;
- extern (D) this(const ref Loc loc, Expression e1, Expression e2, bool generated = true)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2, bool generated = true) @safe
{
super(loc, EXP.comma, e1, e2);
allowCommaExp = isGenerated = generated;
@@ -5931,7 +5938,7 @@ extern (C++) final class CommaExp : BinExp
* exp = An expression that discards its result.
* If the argument is null or not a CommaExp, nothing happens.
*/
- static void allow(Expression exp)
+ static void allow(Expression exp) @safe
{
if (exp)
if (auto ce = exp.isCommaExp())
@@ -5947,7 +5954,7 @@ extern (C++) final class IntervalExp : Expression
Expression lwr;
Expression upr;
- extern (D) this(const ref Loc loc, Expression lwr, Expression upr)
+ extern (D) this(const ref Loc loc, Expression lwr, Expression upr) @safe
{
super(loc, EXP.interval);
this.lwr = lwr;
@@ -5972,7 +5979,7 @@ extern (C++) final class IntervalExp : Expression
*/
extern (C++) final class DelegatePtrExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e1)
+ extern (D) this(const ref Loc loc, Expression e1) @safe
{
super(loc, EXP.delegatePointer, e1);
}
@@ -6010,7 +6017,7 @@ extern (C++) final class DelegatePtrExp : UnaExp
*/
extern (C++) final class DelegateFuncptrExp : UnaExp
{
- extern (D) this(const ref Loc loc, Expression e1)
+ extern (D) this(const ref Loc loc, Expression e1) @safe
{
super(loc, EXP.delegateFunctionPointer, e1);
}
@@ -6050,13 +6057,13 @@ extern (C++) final class IndexExp : BinExp
bool modifiable = false; // assume it is an rvalue
bool indexIsInBounds; // true if 0 <= e2 && e2 <= e1.length - 1
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.index, e1, e2);
//printf("IndexExp::IndexExp('%s')\n", toChars());
}
- extern (D) this(const ref Loc loc, Expression e1, Expression e2, bool indexIsInBounds)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2, bool indexIsInBounds) @safe
{
super(loc, EXP.index, e1, e2);
this.indexIsInBounds = indexIsInBounds;
@@ -6150,7 +6157,7 @@ extern (C++) final class PostExp : BinExp
*/
extern (C++) final class PreExp : UnaExp
{
- extern (D) this(EXP op, const ref Loc loc, Expression e)
+ extern (D) this(EXP op, const ref Loc loc, Expression e) @safe
{
super(loc, op, e);
assert(op == EXP.preMinusMinus || op == EXP.prePlusPlus);
@@ -6180,12 +6187,12 @@ extern (C++) class AssignExp : BinExp
/************************************************************/
/* op can be EXP.assign, EXP.construct, or EXP.blit */
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.assign, e1, e2);
}
- this(const ref Loc loc, EXP tok, Expression e1, Expression e2)
+ this(const ref Loc loc, EXP tok, Expression e1, Expression e2) @safe
{
super(loc, tok, e1, e2);
}
@@ -6231,7 +6238,7 @@ extern (C++) class AssignExp : BinExp
extern (C++) final class LoweredAssignExp : AssignExp
{
Expression lowering;
- extern (D) this(AssignExp exp, Expression lowering)
+ extern (D) this(AssignExp exp, Expression lowering) @safe
{
super(exp.loc, EXP.loweredAssignExp, exp.e1, exp.e2);
this.lowering = lowering;
@@ -6251,14 +6258,14 @@ extern (C++) final class LoweredAssignExp : AssignExp
*/
extern (C++) final class ConstructExp : AssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.construct, e1, e2);
}
// Internal use only. If `v` is a reference variable, the assignment
// will become a reference initialization automatically.
- extern (D) this(const ref Loc loc, VarDeclaration v, Expression e2)
+ extern (D) this(const ref Loc loc, VarDeclaration v, Expression e2) @safe
{
auto ve = new VarExp(loc, v);
assert(v.type && ve.type);
@@ -6280,14 +6287,14 @@ extern (C++) final class ConstructExp : AssignExp
*/
extern (C++) final class BlitExp : AssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.blit, e1, e2);
}
// Internal use only. If `v` is a reference variable, the assinment
// will become a reference rebinding automatically.
- extern (D) this(const ref Loc loc, VarDeclaration v, Expression e2)
+ extern (D) this(const ref Loc loc, VarDeclaration v, Expression e2) @safe
{
auto ve = new VarExp(loc, v);
assert(v.type && ve.type);
@@ -6309,7 +6316,7 @@ extern (C++) final class BlitExp : AssignExp
*/
extern (C++) final class AddAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.addAssign, e1, e2);
}
@@ -6325,7 +6332,7 @@ extern (C++) final class AddAssignExp : BinAssignExp
*/
extern (C++) final class MinAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.minAssign, e1, e2);
}
@@ -6341,7 +6348,7 @@ extern (C++) final class MinAssignExp : BinAssignExp
*/
extern (C++) final class MulAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.mulAssign, e1, e2);
}
@@ -6357,7 +6364,7 @@ extern (C++) final class MulAssignExp : BinAssignExp
*/
extern (C++) final class DivAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.divAssign, e1, e2);
}
@@ -6373,7 +6380,7 @@ extern (C++) final class DivAssignExp : BinAssignExp
*/
extern (C++) final class ModAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.modAssign, e1, e2);
}
@@ -6389,7 +6396,7 @@ extern (C++) final class ModAssignExp : BinAssignExp
*/
extern (C++) final class AndAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.andAssign, e1, e2);
}
@@ -6405,7 +6412,7 @@ extern (C++) final class AndAssignExp : BinAssignExp
*/
extern (C++) final class OrAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.orAssign, e1, e2);
}
@@ -6421,7 +6428,7 @@ extern (C++) final class OrAssignExp : BinAssignExp
*/
extern (C++) final class XorAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.xorAssign, e1, e2);
}
@@ -6437,7 +6444,7 @@ extern (C++) final class XorAssignExp : BinAssignExp
*/
extern (C++) final class PowAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.powAssign, e1, e2);
}
@@ -6453,7 +6460,7 @@ extern (C++) final class PowAssignExp : BinAssignExp
*/
extern (C++) final class ShlAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.leftShiftAssign, e1, e2);
}
@@ -6469,7 +6476,7 @@ extern (C++) final class ShlAssignExp : BinAssignExp
*/
extern (C++) final class ShrAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.rightShiftAssign, e1, e2);
}
@@ -6485,7 +6492,7 @@ extern (C++) final class ShrAssignExp : BinAssignExp
*/
extern (C++) final class UshrAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.unsignedRightShiftAssign, e1, e2);
}
@@ -6510,12 +6517,12 @@ extern (C++) final class UshrAssignExp : BinAssignExp
*/
extern (C++) class CatAssignExp : BinAssignExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.concatenateAssign, e1, e2);
}
- extern (D) this(const ref Loc loc, EXP tok, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, EXP tok, Expression e1, Expression e2) @safe
{
super(loc, tok, e1, e2);
}
@@ -6531,7 +6538,7 @@ extern (C++) class CatAssignExp : BinAssignExp
*/
extern (C++) final class CatElemAssignExp : CatAssignExp
{
- extern (D) this(const ref Loc loc, Type type, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Type type, Expression e1, Expression e2) @safe
{
super(loc, EXP.concatenateElemAssign, e1, e2);
this.type = type;
@@ -6548,7 +6555,7 @@ extern (C++) final class CatElemAssignExp : CatAssignExp
*/
extern (C++) final class CatDcharAssignExp : CatAssignExp
{
- extern (D) this(const ref Loc loc, Type type, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Type type, Expression e1, Expression e2) @safe
{
super(loc, EXP.concatenateDcharAssign, e1, e2);
this.type = type;
@@ -6567,7 +6574,7 @@ extern (C++) final class CatDcharAssignExp : CatAssignExp
*/
extern (C++) final class AddExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.add, e1, e2);
}
@@ -6585,7 +6592,7 @@ extern (C++) final class AddExp : BinExp
*/
extern (C++) final class MinExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.min, e1, e2);
}
@@ -6605,7 +6612,7 @@ extern (C++) final class CatExp : BinExp
{
Expression lowering; // call to druntime hook `_d_arraycatnTX`
- extern (D) this(const ref Loc loc, Expression e1, Expression e2) scope
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) scope @safe
{
super(loc, EXP.concatenate, e1, e2);
}
@@ -6630,7 +6637,7 @@ extern (C++) final class CatExp : BinExp
*/
extern (C++) final class MulExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.mul, e1, e2);
}
@@ -6648,7 +6655,7 @@ extern (C++) final class MulExp : BinExp
*/
extern (C++) final class DivExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.div, e1, e2);
}
@@ -6666,7 +6673,7 @@ extern (C++) final class DivExp : BinExp
*/
extern (C++) final class ModExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.mod, e1, e2);
}
@@ -6684,7 +6691,7 @@ extern (C++) final class ModExp : BinExp
*/
extern (C++) final class PowExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.pow, e1, e2);
}
@@ -6702,7 +6709,7 @@ extern (C++) final class PowExp : BinExp
*/
extern (C++) final class ShlExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.leftShift, e1, e2);
}
@@ -6720,7 +6727,7 @@ extern (C++) final class ShlExp : BinExp
*/
extern (C++) final class ShrExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.rightShift, e1, e2);
}
@@ -6738,7 +6745,7 @@ extern (C++) final class ShrExp : BinExp
*/
extern (C++) final class UshrExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.unsignedRightShift, e1, e2);
}
@@ -6756,7 +6763,7 @@ extern (C++) final class UshrExp : BinExp
*/
extern (C++) final class AndExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.and, e1, e2);
}
@@ -6774,7 +6781,7 @@ extern (C++) final class AndExp : BinExp
*/
extern (C++) final class OrExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.or, e1, e2);
}
@@ -6792,7 +6799,7 @@ extern (C++) final class OrExp : BinExp
*/
extern (C++) final class XorExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.xor, e1, e2);
}
@@ -6811,7 +6818,7 @@ extern (C++) final class XorExp : BinExp
*/
extern (C++) final class LogicalExp : BinExp
{
- extern (D) this(const ref Loc loc, EXP op, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, EXP op, Expression e1, Expression e2) @safe
{
super(loc, op, e1, e2);
assert(op == EXP.andAnd || op == EXP.orOr);
@@ -6833,7 +6840,7 @@ extern (C++) final class LogicalExp : BinExp
*/
extern (C++) final class CmpExp : BinExp
{
- extern (D) this(EXP op, const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(EXP op, const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, op, e1, e2);
assert(op == EXP.lessThan || op == EXP.lessOrEqual || op == EXP.greaterThan || op == EXP.greaterOrEqual);
@@ -6854,7 +6861,7 @@ extern (C++) final class CmpExp : BinExp
*/
extern (C++) final class InExp : BinExp
{
- extern (D) this(const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, EXP.in_, e1, e2);
}
@@ -6893,7 +6900,7 @@ extern (C++) final class RemoveExp : BinExp
*/
extern (C++) final class EqualExp : BinExp
{
- extern (D) this(EXP op, const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(EXP op, const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, op, e1, e2);
assert(op == EXP.equal || op == EXP.notEqual);
@@ -6914,7 +6921,7 @@ extern (C++) final class EqualExp : BinExp
*/
extern (C++) final class IdentityExp : BinExp
{
- extern (D) this(EXP op, const ref Loc loc, Expression e1, Expression e2)
+ extern (D) this(EXP op, const ref Loc loc, Expression e1, Expression e2) @safe
{
super(loc, op, e1, e2);
assert(op == EXP.identity || op == EXP.notIdentity);
@@ -6935,7 +6942,7 @@ extern (C++) final class CondExp : BinExp
{
Expression econd;
- extern (D) this(const ref Loc loc, Expression econd, Expression e1, Expression e2) scope
+ extern (D) this(const ref Loc loc, Expression econd, Expression e1, Expression e2) scope @safe
{
super(loc, EXP.question, e1, e2);
this.econd = econd;
@@ -6984,7 +6991,7 @@ extern (C++) final class CondExp : BinExp
VarDeclaration vcond;
bool isThen;
- extern (D) this(Scope* sc, CondExp ce)
+ extern (D) this(Scope* sc, CondExp ce) @safe
{
this.sc = sc;
this.ce = ce;
@@ -7075,7 +7082,7 @@ bool isDefaultInitOp(EXP op) pure nothrow @safe @nogc
*/
extern (C++) class DefaultInitExp : Expression
{
- extern (D) this(const ref Loc loc, EXP op)
+ extern (D) this(const ref Loc loc, EXP op) @safe
{
super(loc, op);
}
@@ -7091,7 +7098,7 @@ extern (C++) class DefaultInitExp : Expression
*/
extern (C++) final class FileInitExp : DefaultInitExp
{
- extern (D) this(const ref Loc loc, EXP tok)
+ extern (D) this(const ref Loc loc, EXP tok) @safe
{
super(loc, tok);
}
@@ -7120,7 +7127,7 @@ extern (C++) final class FileInitExp : DefaultInitExp
*/
extern (C++) final class LineInitExp : DefaultInitExp
{
- extern (D) this(const ref Loc loc)
+ extern (D) this(const ref Loc loc) @safe
{
super(loc, EXP.line);
}
@@ -7142,7 +7149,7 @@ extern (C++) final class LineInitExp : DefaultInitExp
*/
extern (C++) final class ModuleInitExp : DefaultInitExp
{
- extern (D) this(const ref Loc loc)
+ extern (D) this(const ref Loc loc) @safe
{
super(loc, EXP.moduleString);
}
@@ -7165,7 +7172,7 @@ extern (C++) final class ModuleInitExp : DefaultInitExp
*/
extern (C++) final class FuncInitExp : DefaultInitExp
{
- extern (D) this(const ref Loc loc)
+ extern (D) this(const ref Loc loc) @safe
{
super(loc, EXP.functionString);
}
@@ -7194,7 +7201,7 @@ extern (C++) final class FuncInitExp : DefaultInitExp
*/
extern (C++) final class PrettyFuncInitExp : DefaultInitExp
{
- extern (D) this(const ref Loc loc)
+ extern (D) this(const ref Loc loc) @safe
{
super(loc, EXP.prettyFunction);
}
@@ -7262,7 +7269,7 @@ extern (C++) final class GenericExp : Expression
Types* types; /// type-names for generic associations (null entry for `default`)
Expressions* exps; /// 1:1 mapping of typeNames to exps
- extern (D) this(const ref Loc loc, Expression cntlExp, Types* types, Expressions* exps)
+ extern (D) this(const ref Loc loc, Expression cntlExp, Types* types, Expressions* exps) @safe
{
super(loc, EXP._Generic);
this.cntlExp = cntlExp;
diff --git a/gcc/d/dmd/expression.h b/gcc/d/dmd/expression.h
index 8c6393f..1f04c6c 100644
--- a/gcc/d/dmd/expression.h
+++ b/gcc/d/dmd/expression.h
@@ -955,6 +955,7 @@ public:
private:
uint8_t bitFields;
+public:
SliceExp *syntaxCopy() override;
bool isLvalue() override;
Expression *toLvalue(Scope *sc, Expression *e) override;
diff --git a/gcc/d/dmd/expressionsem.d b/gcc/d/dmd/expressionsem.d
index 25f755b..69999cb 100644
--- a/gcc/d/dmd/expressionsem.d
+++ b/gcc/d/dmd/expressionsem.d
@@ -875,6 +875,13 @@ Lagain:
if (sc.setUnsafePreview(global.params.systemVariables, false, loc,
"cannot access `@system` variable `%s` in @safe code", sd))
{
+ if (auto v = sd.isVarDeclaration())
+ {
+ if (v.systemInferred)
+ errorSupplemental(v.loc, "`%s` is inferred to be `@system` from its initializer here", v.toChars());
+ else
+ errorSupplemental(v.loc, "`%s` is declared here", v.toChars());
+ }
return ErrorExp.get();
}
}
@@ -1582,7 +1589,7 @@ private Type arrayExpressionToCommonType(Scope* sc, ref Expressions exps)
return t0;
}
-private Expression opAssignToOp(const ref Loc loc, EXP op, Expression e1, Expression e2)
+private Expression opAssignToOp(const ref Loc loc, EXP op, Expression e1, Expression e2) @safe
{
Expression e;
switch (op)
@@ -2609,7 +2616,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
Scope* sc;
Expression result;
- this(Scope* sc) scope
+ this(Scope* sc) scope @safe
{
this.sc = sc;
}
@@ -2619,6 +2626,14 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
result = ErrorExp.get();
}
+ private void needThisError(Loc loc, FuncDeclaration f)
+ {
+ auto t = f.isThis();
+ assert(t);
+ .error(loc, "calling non-static function `%s` requires an instance of type `%s`", f.toChars(), t.toChars());
+ setError();
+ }
+
/**************************
* Semantically analyze Expression.
* Determine types, fold constants, etc.
@@ -3721,12 +3736,13 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
if (cd.isAbstract())
{
exp.error("cannot create instance of abstract class `%s`", cd.toChars());
+ errorSupplemental(cd.loc, "class `%s` is declared here", cd.toChars());
for (size_t i = 0; i < cd.vtbl.length; i++)
{
FuncDeclaration fd = cd.vtbl[i].isFuncDeclaration();
if (fd && fd.isAbstract())
{
- errorSupplemental(exp.loc, "function `%s` is not implemented",
+ errorSupplemental(fd.loc, "function `%s` is not implemented",
fd.toFullSignature());
}
}
@@ -5242,8 +5258,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
}
else if (isNeedThisScope(sc, exp.f))
{
- exp.error("need `this` for `%s` of type `%s`", exp.f.toChars(), exp.f.type.toChars());
- return setError();
+ return needThisError(exp.loc, exp.f);
}
}
exp.e1 = new VarExp(exp.e1.loc, exp.f, false);
@@ -5386,8 +5401,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
// If no error is printed, it means that `f` is the single matching overload
// and it needs `this`.
- exp.error("need `this` for `%s` of type `%s`", exp.f.toChars(), exp.f.type.toChars());
- return setError();
+ return needThisError(exp.loc, exp.f);
}
}
@@ -5958,18 +5972,20 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
break;
case TOK.function_:
+ if (e.targ.ty != Tfunction)
+ return no();
+ goto case;
case TOK.parameters:
{
- if (e.targ.ty != Tfunction)
+ if (auto tf = e.targ.isFunction_Delegate_PtrToFunction())
+ tded = tf;
+ else
return no();
- tded = e.targ;
/* Generate tuple from function parameter types.
*/
- assert(tded.ty == Tfunction);
- auto tdedf = tded.isTypeFunction();
auto args = new Parameters();
- foreach (i, arg; tdedf.parameterList)
+ foreach (i, arg; tded.isTypeFunction().parameterList)
{
assert(arg && arg.type);
/* If one of the default arguments was an error,
@@ -6267,7 +6283,10 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
if (p.token.value != TOK.endOfFile)
{
- exp.error("incomplete mixin expression `%s`", str.ptr);
+ e.error("unexpected token `%s` after %s expression",
+ p.token.toChars(), EXPtoString(e.op).ptr);
+ e.errorSupplemental("while parsing string mixin expression `%s`",
+ str.ptr);
return null;
}
return e;
@@ -6632,7 +6651,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
else
{
OutBuffer buf;
- buf.printf("%s failed", exp.toChars());
+ buf.printf("`%s` failed", exp.toChars());
exp.msg = new StringExp(Loc.initial, buf.extractSlice());
goto LSkip;
}
@@ -12911,7 +12930,7 @@ private Expression dotIdSemanticPropX(DotIdExp exp, Scope* sc)
}
}
OutBuffer buf;
- mangleToBuffer(ds, &buf);
+ mangleToBuffer(ds, buf);
Expression e = new StringExp(loc, buf.extractSlice());
return e.expressionSemantic(sc);
}
diff --git a/gcc/d/dmd/foreachvar.d b/gcc/d/dmd/foreachvar.d
index 1293057..8af2a95 100644
--- a/gcc/d/dmd/foreachvar.d
+++ b/gcc/d/dmd/foreachvar.d
@@ -56,7 +56,7 @@ void foreachVar(Expression e, void delegate(VarDeclaration) dgVar)
alias visit = typeof(super).visit;
extern (D) void delegate(VarDeclaration) dgVar;
- extern (D) this(void delegate(VarDeclaration) dgVar) scope
+ extern (D) this(void delegate(VarDeclaration) dgVar) scope @safe
{
this.dgVar = dgVar;
}
diff --git a/gcc/d/dmd/func.d b/gcc/d/dmd/func.d
index 6045735..73f1ba7 100644
--- a/gcc/d/dmd/func.d
+++ b/gcc/d/dmd/func.d
@@ -2509,7 +2509,7 @@ extern (C++) class FuncDeclaration : Declaration
* Returns:
* true found an 'out' contract
*/
- static bool needsFensure(FuncDeclaration fd)
+ static bool needsFensure(FuncDeclaration fd) @safe
{
if (fd.fensures)
return true;
@@ -4558,9 +4558,10 @@ bool setUnsafe(Scope* sc,
.error(loc, fmt, arg0 ? arg0.toChars() : "", arg1 ? arg1.toChars() : "", arg2 ? arg2.toChars() : "");
return true;
}
- else if (!(sc.varDecl.storage_class & STC.system))
+ else if (!(sc.varDecl.storage_class & STC.trusted))
{
sc.varDecl.storage_class |= STC.system;
+ sc.varDecl.systemInferred = true;
}
}
return false;
@@ -4606,6 +4607,7 @@ bool setUnsafe(Scope* sc,
bool setUnsafePreview(Scope* sc, FeatureState fs, bool gag, Loc loc, const(char)* msg,
RootObject arg0 = null, RootObject arg1 = null, RootObject arg2 = null)
{
+ //printf("setUnsafePreview() fs:%d %s\n", fs, msg);
with (FeatureState) final switch (fs)
{
case disabled:
@@ -4620,9 +4622,10 @@ bool setUnsafePreview(Scope* sc, FeatureState fs, bool gag, Loc loc, const(char)
if (sc.func.isSafeBypassingInference())
{
if (!gag)
- previewErrorFunc(sc.isDeprecated(), fs)(
- loc, msg, arg0 ? arg0.toChars() : "", arg1 ? arg1.toChars() : "", arg2 ? arg2.toChars() : ""
- );
+ {
+ if (!sc.isDeprecated() && global.params.obsolete)
+ warning(loc, msg, arg0 ? arg0.toChars() : "", arg1 ? arg1.toChars() : "", arg2 ? arg2.toChars() : "");
+ }
}
else if (!sc.func.safetyViolation)
{
@@ -4706,9 +4709,9 @@ void errorSupplementalInferredAttr(FuncDeclaration fd, int maxDepth, bool deprec
s.arg0 ? s.arg0.toChars() : "", s.arg1 ? s.arg1.toChars() : "", s.arg2 ? s.arg2.toChars() : "");
}
}
- else if (s.arg0.dyncast() == DYNCAST.dsymbol)
+ else if (auto sa = s.arg0.isDsymbol())
{
- if (FuncDeclaration fd2 = (cast(Dsymbol) s.arg0).isFuncDeclaration())
+ if (FuncDeclaration fd2 = sa.isFuncDeclaration())
{
if (maxDepth > 0)
{
diff --git a/gcc/d/dmd/globals.d b/gcc/d/dmd/globals.d
index 9071e6a..af711a0 100644
--- a/gcc/d/dmd/globals.d
+++ b/gcc/d/dmd/globals.d
@@ -133,7 +133,7 @@ extern (C++) struct Param
bool useModuleInfo = true; // generate runtime module information
bool useTypeInfo = true; // generate runtime type information
bool useExceptions = true; // support exception handling
- bool useGC = true; // support features that require the GC
+ bool useGC = true; // support features that require the D runtime GC
bool betterC; // be a "better C" compiler; no dependency on D runtime
bool addMain; // add a default main() function
bool allInst; // generate code for all template instantiations
@@ -297,7 +297,7 @@ extern (C++) struct Global
*
* Returns: the current number of gagged errors, which should later be passed to `endGagging`
*/
- extern (C++) uint startGagging()
+ extern (C++) uint startGagging() @safe
{
++gag;
gaggedWarnings = 0;
@@ -311,7 +311,7 @@ extern (C++) struct Global
* oldGagged = the previous number of errors, as returned by `startGagging`
* Returns: true if errors occurred while gagged.
*/
- extern (C++) bool endGagging(uint oldGagged)
+ extern (C++) bool endGagging(uint oldGagged) @safe
{
bool anyErrs = (gaggedErrors != oldGagged);
--gag;
@@ -327,7 +327,7 @@ extern (C++) struct Global
*
* An error message may or may not have been printed.
*/
- extern (C++) void increaseErrorCount()
+ extern (C++) void increaseErrorCount() @safe
{
if (gag)
++gaggedErrors;
@@ -344,8 +344,8 @@ extern (C++) struct Global
compileEnv.vendor = "Digital Mars D";
// -color=auto is the default value
- import dmd.console : detectTerminal;
- params.color = detectTerminal();
+ import dmd.console : detectTerminal, detectColorPreference;
+ params.color = detectTerminal() && detectColorPreference();
}
else version (IN_GCC)
{
@@ -397,7 +397,7 @@ extern (C++) struct Global
/**
* Computes the version number __VERSION__ from the compiler version string.
*/
- extern (D) private static uint parseVersionNumber(string version_)
+ extern (D) private static uint parseVersionNumber(string version_) @safe
{
//
// parse _version
@@ -429,7 +429,7 @@ extern (C++) struct Global
/**
Returns: the version as the number that would be returned for __VERSION__
*/
- extern(C++) uint versionNumber()
+ extern(C++) uint versionNumber() @safe
{
return compileEnv.versionNumber;
}
@@ -437,7 +437,7 @@ extern (C++) struct Global
/**
Returns: compiler version string.
*/
- extern(D) string versionString()
+ extern(D) string versionString() @safe
{
return _version;
}
diff --git a/gcc/d/dmd/globals.h b/gcc/d/dmd/globals.h
index 0dad5dd..0ef9eed 100644
--- a/gcc/d/dmd/globals.h
+++ b/gcc/d/dmd/globals.h
@@ -128,7 +128,7 @@ struct Param
d_bool useModuleInfo; // generate runtime module information
d_bool useTypeInfo; // generate runtime type information
d_bool useExceptions; // support exception handling
- d_bool useGC; // support features that require the GC
+ d_bool useGC; // support features that require the D runtime GC
d_bool betterC; // be a "better C" compiler; no dependency on D runtime
d_bool addMain; // add a default main() function
d_bool allInst; // generate code for all template instantiations
diff --git a/gcc/d/dmd/hdrgen.d b/gcc/d/dmd/hdrgen.d
index 62e0d49..33cbc19 100644
--- a/gcc/d/dmd/hdrgen.d
+++ b/gcc/d/dmd/hdrgen.d
@@ -805,7 +805,7 @@ public:
OutBuffer* buf;
HdrGenState* hgs;
- extern (D) this(OutBuffer* buf, HdrGenState* hgs) scope
+ extern (D) this(OutBuffer* buf, HdrGenState* hgs) scope @safe
{
this.buf = buf;
this.hgs = hgs;
@@ -2775,7 +2775,7 @@ public:
OutBuffer* buf;
HdrGenState* hgs;
- extern (D) this(OutBuffer* buf, HdrGenState* hgs) scope
+ extern (D) this(OutBuffer* buf, HdrGenState* hgs) scope @safe
{
this.buf = buf;
this.hgs = hgs;
@@ -2856,7 +2856,7 @@ public:
OutBuffer* buf;
HdrGenState* hgs;
- extern (D) this(OutBuffer* buf, HdrGenState* hgs) scope
+ extern (D) this(OutBuffer* buf, HdrGenState* hgs) scope @safe
{
this.buf = buf;
this.hgs = hgs;
@@ -2920,7 +2920,7 @@ void toCBuffer(const Initializer iz, OutBuffer* buf, HdrGenState* hgs)
initializerToBuffer(cast() iz, buf, hgs);
}
-bool stcToBuffer(OutBuffer* buf, StorageClass stc)
+bool stcToBuffer(OutBuffer* buf, StorageClass stc) @safe
{
//printf("stc: %llx\n", stc);
bool result = false;
@@ -2980,7 +2980,7 @@ bool stcToBuffer(OutBuffer* buf, StorageClass stc)
* and return a string representation of it.
* stc is reduced by the one picked.
*/
-string stcToString(ref StorageClass stc)
+string stcToString(ref StorageClass stc) @safe
{
static struct SCstring
{
@@ -3039,7 +3039,7 @@ string stcToString(ref StorageClass stc)
return null;
}
-private void linkageToBuffer(OutBuffer* buf, LINK linkage)
+private void linkageToBuffer(OutBuffer* buf, LINK linkage) @safe
{
const s = linkageToString(linkage);
if (s.length)
@@ -3056,7 +3056,7 @@ const(char)* linkageToChars(LINK linkage)
return linkageToString(linkage).ptr;
}
-string linkageToString(LINK linkage) pure nothrow
+string linkageToString(LINK linkage) pure nothrow @safe
{
final switch (linkage)
{
@@ -3099,7 +3099,7 @@ const(char)* visibilityToChars(Visibility.Kind kind)
}
/// Ditto
-extern (D) string visibilityToString(Visibility.Kind kind) nothrow pure
+extern (D) string visibilityToString(Visibility.Kind kind) nothrow pure @safe
{
final switch (kind)
{
diff --git a/gcc/d/dmd/id.d b/gcc/d/dmd/id.d
index a2daf60..43b2e5f 100644
--- a/gcc/d/dmd/id.d
+++ b/gcc/d/dmd/id.d
@@ -575,7 +575,7 @@ struct Msgtable
* Returns: the name to use in the D executable, `name_` if non-empty,
* otherwise `ident`
*/
- string name()
+ string name() @safe
{
return name_ ? name_ : ident;
}
@@ -602,19 +602,19 @@ string generate(immutable(Msgtable)[] msgtable, string function(Msgtable) dg)
}
// Used to generate the code for each identifier.
-string identifier(Msgtable m)
+string identifier(Msgtable m) @safe
{
return "Identifier " ~ m.ident ~ ";";
}
// Used to generate the code for each initializer.
-string initializer(Msgtable m)
+string initializer(Msgtable m) @safe
{
return m.ident ~ ` = Identifier.idPool("` ~ m.name ~ `");`;
}
// Used to generate the code for each deinitializer.
-string deinitializer(Msgtable m)
+string deinitializer(Msgtable m) @safe
{
return m.ident ~ " = Identifier.init;";
}
diff --git a/gcc/d/dmd/identifier.d b/gcc/d/dmd/identifier.d
index b1c421c..3173445 100644
--- a/gcc/d/dmd/identifier.d
+++ b/gcc/d/dmd/identifier.d
@@ -64,13 +64,13 @@ nothrow:
}
/// ditto
- extern (D) this(const(char)[] name, int value)
+ extern (D) this(const(char)[] name, int value) @safe
{
//printf("Identifier('%.*s', %d)\n", cast(int)name.length, name.ptr, value);
this(name, value, false);
}
- extern (D) private this(const(char)[] name, int value, bool isAnonymous)
+ extern (D) private this(const(char)[] name, int value, bool isAnonymous) @safe
{
//printf("Identifier('%.*s', %d, %d)\n", cast(int)name.length, name.ptr, value, isAnonymous);
this.name = name;
@@ -315,7 +315,7 @@ nothrow:
/**********************************
* ditto
*/
- extern (D) static bool isValidIdentifier(const(char)[] str)
+ extern (D) static bool isValidIdentifier(const(char)[] str) @safe
{
if (str.length == 0 ||
(str[0] >= '0' && str[0] <= '9')) // beware of isdigit() on signed chars
diff --git a/gcc/d/dmd/imphint.d b/gcc/d/dmd/imphint.d
index 913de9f..9e9466a 100644
--- a/gcc/d/dmd/imphint.d
+++ b/gcc/d/dmd/imphint.d
@@ -20,7 +20,7 @@ module dmd.imphint;
* Not meant to be a comprehensive list of names in each module,
* just the most common ones.
*/
-const(char)[] importHint(const(char)[] s)
+const(char)[] importHint(const(char)[] s) @safe
{
if (auto entry = s in hints)
return *entry;
diff --git a/gcc/d/dmd/init.d b/gcc/d/dmd/init.d
index 6f20a3c..e7cf905 100644
--- a/gcc/d/dmd/init.d
+++ b/gcc/d/dmd/init.d
@@ -51,7 +51,7 @@ extern (C++) class Initializer : ASTNode
}
- extern (D) this(const ref Loc loc, InitKind kind)
+ extern (D) this(const ref Loc loc, InitKind kind) @safe
{
this.loc = loc;
this.kind = kind;
@@ -108,7 +108,7 @@ extern (C++) final class VoidInitializer : Initializer
{
Type type; // type that this will initialize to
- extern (D) this(const ref Loc loc)
+ extern (D) this(const ref Loc loc) @safe
{
super(loc, InitKind.void_);
}
@@ -123,7 +123,7 @@ extern (C++) final class VoidInitializer : Initializer
*/
extern (C++) final class ErrorInitializer : Initializer
{
- extern (D) this()
+ extern (D) this() @safe
{
super(Loc.initial, InitKind.error);
}
@@ -206,7 +206,7 @@ extern (C++) final class ExpInitializer : Initializer
bool expandTuples;
Expression exp;
- extern (D) this(const ref Loc loc, Expression exp)
+ extern (D) this(const ref Loc loc, Expression exp) @safe
{
super(loc, InitKind.exp);
this.exp = exp;
@@ -226,8 +226,8 @@ struct Designator
Expression exp; /// [ constant-expression ]
Identifier ident; /// . identifier
- this(Expression exp) { this.exp = exp; }
- this(Identifier ident) { this.ident = ident; }
+ this(Expression exp) @safe { this.exp = exp; }
+ this(Identifier ident) @safe { this.ident = ident; }
}
/*********************************************
@@ -377,7 +377,7 @@ mixin template VisitInitializer(Result)
* handler = string for the name of the visit handler
* Returns: boilerplate code for a case
*/
-pure string visitCase(string handler)
+string visitCase(string handler) pure @safe
{
if (__ctfe)
{
diff --git a/gcc/d/dmd/intrange.d b/gcc/d/dmd/intrange.d
index d67e0f5..442668f 100644
--- a/gcc/d/dmd/intrange.d
+++ b/gcc/d/dmd/intrange.d
@@ -18,7 +18,7 @@ import dmd.mtype;
import dmd.expression;
import dmd.globals;
-private uinteger_t copySign(uinteger_t x, bool sign)
+private uinteger_t copySign(uinteger_t x, bool sign) @safe
{
// return sign ? -x : x;
return (x - cast(uinteger_t)sign) ^ -cast(uinteger_t)sign;
@@ -29,37 +29,37 @@ struct SignExtendedNumber
uinteger_t value;
bool negative;
- static SignExtendedNumber fromInteger(uinteger_t value_)
+ static SignExtendedNumber fromInteger(uinteger_t value_) @safe
{
return SignExtendedNumber(value_, value_ >> 63);
}
- static SignExtendedNumber extreme(bool minimum)
+ static SignExtendedNumber extreme(bool minimum) @safe
{
return SignExtendedNumber(minimum - 1, minimum);
}
- static SignExtendedNumber max()
+ static SignExtendedNumber max() @safe
{
return SignExtendedNumber(ulong.max, false);
}
- static SignExtendedNumber min()
+ static SignExtendedNumber min() @safe
{
return SignExtendedNumber(0, true);
}
- bool isMinimum() const
+ bool isMinimum() const @safe
{
return negative && value == 0;
}
- bool opEquals(const ref SignExtendedNumber a) const
+ bool opEquals(const ref SignExtendedNumber a) const @safe
{
return value == a.value && negative == a.negative;
}
- int opCmp(const ref SignExtendedNumber a) const
+ int opCmp(const ref SignExtendedNumber a) const @safe
{
if (negative != a.negative)
{
@@ -297,19 +297,19 @@ struct IntRange
{
SignExtendedNumber imin, imax;
- this(IntRange another)
+ this(IntRange another) @safe
{
imin = another.imin;
imax = another.imax;
}
- this(SignExtendedNumber a)
+ this(SignExtendedNumber a) @safe
{
imin = a;
imax = a;
}
- this(SignExtendedNumber lower, SignExtendedNumber upper)
+ this(SignExtendedNumber lower, SignExtendedNumber upper) @safe
{
imin = lower;
imax = upper;
@@ -358,12 +358,12 @@ struct IntRange
return ab;
}
- static IntRange widest()
+ static IntRange widest() @safe
{
return IntRange(SignExtendedNumber.min(), SignExtendedNumber.max());
}
- IntRange castSigned(uinteger_t mask)
+ IntRange castSigned(uinteger_t mask) @safe
{
// .... 0x1e7f ] [0x1e80 .. 0x1f7f] [0x1f80 .. 0x7f] [0x80 .. 0x17f] [0x180 ....
//
@@ -405,7 +405,7 @@ struct IntRange
return this;
}
- IntRange castUnsigned(uinteger_t mask)
+ IntRange castUnsigned(uinteger_t mask) @safe
{
// .... 0x1eff ] [0x1f00 .. 0x1fff] [0 .. 0xff] [0x100 .. 0x1ff] [0x200 ....
//
@@ -430,7 +430,7 @@ struct IntRange
return this;
}
- IntRange castDchar()
+ IntRange castDchar() @safe
{
// special case for dchar. Casting to dchar means "I'll ignore all
// invalid characters."
@@ -464,18 +464,18 @@ struct IntRange
return castUnsigned(type.sizemask());
}
- bool contains(IntRange a)
+ bool contains(IntRange a) @safe
{
return imin <= a.imin && imax >= a.imax;
}
- bool containsZero() const
+ bool containsZero() const @safe
{
return (imin.negative && !imax.negative)
|| (!imin.negative && imin.value == 0);
}
- IntRange absNeg() const
+ IntRange absNeg() const @safe
{
if (imax.negative)
return this;
@@ -489,13 +489,13 @@ struct IntRange
}
}
- IntRange unionWith(const ref IntRange other) const
+ IntRange unionWith(const ref IntRange other) const @safe
{
return IntRange(imin < other.imin ? imin : other.imin,
imax > other.imax ? imax : other.imax);
}
- void unionOrAssign(IntRange other, ref bool union_)
+ void unionOrAssign(IntRange other, ref bool union_) @safe
{
if (!union_ || imin > other.imin)
imin = other.imin;
@@ -513,7 +513,7 @@ struct IntRange
return this;
}
- void splitBySign(ref IntRange negRange, ref bool hasNegRange, ref IntRange nonNegRange, ref bool hasNonNegRange) const
+ void splitBySign(ref IntRange negRange, ref bool hasNegRange, ref IntRange nonNegRange, ref bool hasNonNegRange) const @safe
{
hasNegRange = imin.negative;
if (hasNegRange)
@@ -785,7 +785,7 @@ struct IntRange
private:
// Credits to Timon Gehr maxOr, minOr, maxAnd, minAnd
// https://github.com/tgehr/d-compiler/blob/master/vrange.d
- static SignExtendedNumber maxOr(const IntRange lhs, const IntRange rhs)
+ static SignExtendedNumber maxOr(const IntRange lhs, const IntRange rhs) @safe
{
uinteger_t x = 0;
auto sign = false;
@@ -856,14 +856,14 @@ private:
// Credits to Timon Gehr maxOr, minOr, maxAnd, minAnd
// https://github.com/tgehr/d-compiler/blob/master/vrange.d
- static SignExtendedNumber minOr(const IntRange lhs, const IntRange rhs)
+ static SignExtendedNumber minOr(const IntRange lhs, const IntRange rhs) @safe
{
return ~maxAnd(~lhs, ~rhs);
}
// Credits to Timon Gehr maxOr, minOr, maxAnd, minAnd
// https://github.com/tgehr/d-compiler/blob/master/vrange.d
- static SignExtendedNumber maxAnd(const IntRange lhs, const IntRange rhs)
+ static SignExtendedNumber maxAnd(const IntRange lhs, const IntRange rhs) @safe
{
uinteger_t x = 0;
bool sign = false;
@@ -905,7 +905,7 @@ private:
// Credits to Timon Gehr maxOr, minOr, maxAnd, minAnd
// https://github.com/tgehr/d-compiler/blob/master/vrange.d
- static SignExtendedNumber minAnd(const IntRange lhs, const IntRange rhs)
+ static SignExtendedNumber minAnd(const IntRange lhs, const IntRange rhs) @safe
{
return ~maxOr(~lhs, ~rhs);
}
diff --git a/gcc/d/dmd/json.d b/gcc/d/dmd/json.d
index dcf53b8..9689986 100644
--- a/gcc/d/dmd/json.d
+++ b/gcc/d/dmd/json.d
@@ -54,7 +54,7 @@ public:
int indentLevel;
const(char)[] filename;
- extern (D) this(OutBuffer* buf) scope
+ extern (D) this(OutBuffer* buf) scope @safe
{
this.buf = buf;
}
diff --git a/gcc/d/dmd/lambdacomp.d b/gcc/d/dmd/lambdacomp.d
index 885a27a..ec070d8 100644
--- a/gcc/d/dmd/lambdacomp.d
+++ b/gcc/d/dmd/lambdacomp.d
@@ -395,7 +395,7 @@ public:
if (s)
{
OutBuffer mangledName;
- mangleToBuffer(s, &mangledName);
+ mangleToBuffer(s, mangledName);
buf.writestring(mangledName[]);
buf.writeByte('_');
}
diff --git a/gcc/d/dmd/lexer.d b/gcc/d/dmd/lexer.d
index 9cce7c5..c28fe5c 100644
--- a/gcc/d/dmd/lexer.d
+++ b/gcc/d/dmd/lexer.d
@@ -193,7 +193,7 @@ class Lexer
/******************
* Used for unittests for a mock Lexer
*/
- this(ErrorSink errorSink) scope { assert(errorSink); this.eSink = errorSink; }
+ this(ErrorSink errorSink) scope @safe { assert(errorSink); this.eSink = errorSink; }
/**************************************
* Reset lexer to lex #define's
diff --git a/gcc/d/dmd/location.d b/gcc/d/dmd/location.d
index b2b3661..0f3b9a7 100644
--- a/gcc/d/dmd/location.d
+++ b/gcc/d/dmd/location.d
@@ -64,7 +64,7 @@ nothrow:
this.messageStyle = messageStyle;
}
- extern (D) this(const(char)* filename, uint linnum, uint charnum)
+ extern (D) this(const(char)* filename, uint linnum, uint charnum) @safe
{
this._linnum = linnum;
this._charnum = cast(ushort) charnum;
@@ -108,7 +108,7 @@ nothrow:
* Params:
* name = file name for location, null for no file name
*/
- extern (C++) void filename(const(char)* name)
+ extern (C++) void filename(const(char)* name) @trusted
{
if (name)
{
@@ -205,7 +205,7 @@ nothrow:
* Returns:
* true if Loc has been set to other than the default initialization
*/
- bool isValid() const pure
+ bool isValid() const pure @safe
{
return fileIndex != 0;
}
diff --git a/gcc/d/dmd/mangle.h b/gcc/d/dmd/mangle.h
index 37953c2..aa24698 100644
--- a/gcc/d/dmd/mangle.h
+++ b/gcc/d/dmd/mangle.h
@@ -28,7 +28,7 @@ const char *cppTypeInfoMangleMSVC(Dsymbol *s);
// In dmangle.d
const char *mangleExact(FuncDeclaration *fd);
-void mangleToBuffer(Type *s, OutBuffer *buf);
-void mangleToBuffer(Expression *s, OutBuffer *buf);
-void mangleToBuffer(Dsymbol *s, OutBuffer *buf);
-void mangleToBuffer(TemplateInstance *s, OutBuffer *buf);
+void mangleToBuffer(Type *s, OutBuffer& buf);
+void mangleToBuffer(Expression *s, OutBuffer& buf);
+void mangleToBuffer(Dsymbol *s, OutBuffer& buf);
+void mangleToBuffer(TemplateInstance *s, OutBuffer& buf);
diff --git a/gcc/d/dmd/mtype.d b/gcc/d/dmd/mtype.d
index 7ecd402..9d83db1 100644
--- a/gcc/d/dmd/mtype.d
+++ b/gcc/d/dmd/mtype.d
@@ -157,7 +157,7 @@ MOD MODmerge(MOD mod1, MOD mod2) pure nothrow @nogc @safe
/*********************************
* Store modifier name into buf.
*/
-void MODtoBuffer(OutBuffer* buf, MOD mod) nothrow
+void MODtoBuffer(OutBuffer* buf, MOD mod) nothrow @safe
{
buf.writestring(MODtoString(mod));
}
@@ -174,7 +174,7 @@ const(char)* MODtoChars(MOD mod) nothrow pure
}
/// Ditto
-string MODtoString(MOD mod) nothrow pure
+string MODtoString(MOD mod) nothrow pure @safe
{
final switch (mod)
{
@@ -457,7 +457,7 @@ extern (C++) abstract class Type : ASTNode
return sizeTy;
}();
- final extern (D) this(TY ty) scope
+ final extern (D) this(TY ty) scope @safe
{
this.ty = ty;
}
@@ -2434,7 +2434,7 @@ extern (C++) abstract class Type : ASTNode
// _init_10TypeInfo_%s
OutBuffer buf;
buf.reserve(32);
- mangleToBuffer(this, &buf);
+ mangleToBuffer(this, buf);
const slice = buf[];
@@ -2780,7 +2780,7 @@ extern (C++) abstract class Type : ASTNode
*/
extern (C++) final class TypeError : Type
{
- extern (D) this()
+ extern (D) this() @safe
{
super(Terror);
}
@@ -2818,7 +2818,7 @@ extern (C++) abstract class TypeNext : Type
{
Type next;
- final extern (D) this(TY ty, Type next)
+ final extern (D) this(TY ty, Type next) @safe
{
super(ty);
this.next = next;
@@ -3517,13 +3517,13 @@ extern (C++) final class TypeVector : Type
{
Type basetype;
- extern (D) this(Type basetype)
+ extern (D) this(Type basetype) @safe
{
super(Tvector);
this.basetype = basetype;
}
- static TypeVector create(Type basetype)
+ static TypeVector create(Type basetype) @safe
{
return new TypeVector(basetype);
}
@@ -3632,7 +3632,7 @@ extern (C++) final class TypeVector : Type
*/
extern (C++) abstract class TypeArray : TypeNext
{
- final extern (D) this(TY ty, Type next)
+ final extern (D) this(TY ty, Type next) @safe
{
super(ty, next);
}
@@ -3650,7 +3650,7 @@ extern (C++) final class TypeSArray : TypeArray
{
Expression dim;
- extern (D) this(Type t, Expression dim)
+ extern (D) this(Type t, Expression dim) @safe
{
super(Tsarray, t);
//printf("TypeSArray(%s)\n", dim.toChars());
@@ -3874,7 +3874,7 @@ extern (C++) final class TypeSArray : TypeArray
*/
extern (C++) final class TypeDArray : TypeArray
{
- extern (D) this(Type t)
+ extern (D) this(Type t) @safe
{
super(Tarray, t);
//printf("TypeDArray(t = %p)\n", t);
@@ -3972,13 +3972,13 @@ extern (C++) final class TypeAArray : TypeArray
Type index; // key type
Loc loc;
- extern (D) this(Type t, Type index)
+ extern (D) this(Type t, Type index) @safe
{
super(Taarray, t);
this.index = index;
}
- static TypeAArray create(Type t, Type index)
+ static TypeAArray create(Type t, Type index) @safe
{
return new TypeAArray(t, index);
}
@@ -4066,12 +4066,12 @@ extern (C++) final class TypeAArray : TypeArray
*/
extern (C++) final class TypePointer : TypeNext
{
- extern (D) this(Type t)
+ extern (D) this(Type t) @safe
{
super(Tpointer, t);
}
- static TypePointer create(Type t)
+ static TypePointer create(Type t) @safe
{
return new TypePointer(t);
}
@@ -4173,7 +4173,7 @@ extern (C++) final class TypePointer : TypeNext
*/
extern (C++) final class TypeReference : TypeNext
{
- extern (D) this(Type t)
+ extern (D) this(Type t) @safe
{
super(Treference, t);
// BUG: what about references to static arrays?
@@ -4263,7 +4263,7 @@ extern (C++) final class TypeFunction : TypeNext
byte inuse;
Expressions* fargs; // function arguments
- extern (D) this(ParameterList pl, Type treturn, LINK linkage, StorageClass stc = 0)
+ extern (D) this(ParameterList pl, Type treturn, LINK linkage, StorageClass stc = 0) @safe
{
super(Tfunction, treturn);
//if (!treturn) *(char*)0=0;
@@ -4305,7 +4305,7 @@ extern (C++) final class TypeFunction : TypeNext
this.trust = TRUST.trusted;
}
- static TypeFunction create(Parameters* parameters, Type treturn, ubyte varargs, LINK linkage, StorageClass stc = 0)
+ static TypeFunction create(Parameters* parameters, Type treturn, ubyte varargs, LINK linkage, StorageClass stc = 0) @safe
{
return new TypeFunction(ParameterList(parameters, cast(VarArg)varargs), treturn, linkage, stc);
}
@@ -5013,13 +5013,13 @@ extern (C++) final class TypeDelegate : TypeNext
{
// .next is a TypeFunction
- extern (D) this(TypeFunction t)
+ extern (D) this(TypeFunction t) @safe
{
super(Tfunction, t);
ty = Tdelegate;
}
- static TypeDelegate create(TypeFunction t)
+ static TypeDelegate create(TypeFunction t) @safe
{
return new TypeDelegate(t);
}
@@ -5114,7 +5114,7 @@ extern (C++) final class TypeTraits : Type
/// Cached type/symbol after semantic analysis.
RootObject obj;
- final extern (D) this(const ref Loc loc, TraitsExp exp)
+ final extern (D) this(const ref Loc loc, TraitsExp exp) @safe
{
super(Ttraits);
this.loc = loc;
@@ -5170,7 +5170,7 @@ extern (C++) final class TypeMixin : Type
Expressions* exps;
RootObject obj; // cached result of semantic analysis.
- extern (D) this(const ref Loc loc, Expressions* exps)
+ extern (D) this(const ref Loc loc, Expressions* exps) @safe
{
super(Tmixin);
this.loc = loc;
@@ -5494,13 +5494,13 @@ extern (C++) final class TypeStruct : Type
AliasThisRec att = AliasThisRec.fwdref;
bool inuse = false; // struct currently subject of recursive method call
- extern (D) this(StructDeclaration sym)
+ extern (D) this(StructDeclaration sym) @safe
{
super(Tstruct);
this.sym = sym;
}
- static TypeStruct create(StructDeclaration sym)
+ static TypeStruct create(StructDeclaration sym) @safe
{
return new TypeStruct(sym);
}
@@ -5830,7 +5830,7 @@ extern (C++) final class TypeEnum : Type
{
EnumDeclaration sym;
- extern (D) this(EnumDeclaration sym)
+ extern (D) this(EnumDeclaration sym) @safe
{
super(Tenum);
this.sym = sym;
@@ -6008,7 +6008,7 @@ extern (C++) final class TypeClass : Type
AliasThisRec att = AliasThisRec.fwdref;
CPPMANGLE cppmangle = CPPMANGLE.def;
- extern (D) this(ClassDeclaration sym)
+ extern (D) this(ClassDeclaration sym) @safe
{
super(Tclass);
this.sym = sym;
@@ -6184,7 +6184,7 @@ extern (C++) final class TypeTuple : Type
Parameters* arguments; // types making up the tuple
- extern (D) this(Parameters* arguments)
+ extern (D) this(Parameters* arguments) @safe
{
super(Ttuple);
//printf("TypeTuple(this = %p)\n", this);
@@ -6226,7 +6226,7 @@ extern (C++) final class TypeTuple : Type
//printf("TypeTuple() %p, %s\n", this, toChars());
}
- static TypeTuple create(Parameters* arguments)
+ static TypeTuple create(Parameters* arguments) @safe
{
return new TypeTuple(arguments);
}
@@ -6234,7 +6234,7 @@ extern (C++) final class TypeTuple : Type
/*******************************************
* Type tuple with 0, 1 or 2 types in it.
*/
- extern (D) this()
+ extern (D) this() @safe
{
super(Ttuple);
arguments = new Parameters();
@@ -6255,7 +6255,7 @@ extern (C++) final class TypeTuple : Type
arguments.push(new Parameter(0, t2, null, null, null));
}
- static TypeTuple create()
+ static TypeTuple create() @safe
{
return new TypeTuple();
}
@@ -6343,7 +6343,7 @@ extern (C++) final class TypeSlice : TypeNext
Expression lwr;
Expression upr;
- extern (D) this(Type next, Expression lwr, Expression upr)
+ extern (D) this(Type next, Expression lwr, Expression upr) @safe
{
super(Tslice, next);
//printf("TypeSlice[%s .. %s]\n", lwr.toChars(), upr.toChars());
@@ -6373,7 +6373,7 @@ extern (C++) final class TypeSlice : TypeNext
*/
extern (C++) final class TypeNull : Type
{
- extern (D) this()
+ extern (D) this() @safe
{
//printf("TypeNull %p\n", this);
super(Tnull);
@@ -6438,7 +6438,7 @@ extern (C++) final class TypeNull : Type
*/
extern (C++) final class TypeNoreturn : Type
{
- extern (D) this()
+ extern (D) this() @safe
{
//printf("TypeNoreturn %p\n", this);
super(Tnoreturn);
@@ -6520,7 +6520,7 @@ extern (C++) final class TypeTag : Type
/// struct S { int a; } s1, *s2;
MOD mod; /// modifiers to apply after type is resolved (only MODFlags.const_ at the moment)
- extern (D) this(const ref Loc loc, TOK tok, Identifier id, structalign_t packalign, Type base, Dsymbols* members)
+ extern (D) this(const ref Loc loc, TOK tok, Identifier id, structalign_t packalign, Type base, Dsymbols* members) @safe
{
//printf("TypeTag ctor %s %p\n", id ? id.toChars() : "null".ptr, this);
super(Ttag);
@@ -6564,7 +6564,7 @@ extern (C++) struct ParameterList
VarArg varargs = VarArg.none;
bool hasIdentifierList; // true if C identifier-list style
- this(Parameters* parameters, VarArg varargs = VarArg.none, StorageClass stc = 0)
+ this(Parameters* parameters, VarArg varargs = VarArg.none, StorageClass stc = 0) @safe
{
this.parameters = parameters;
this.varargs = varargs;
@@ -6667,7 +6667,7 @@ extern (C++) final class Parameter : ASTNode
Expression defaultArg;
UserAttributeDeclaration userAttribDecl; // user defined attributes
- extern (D) this(StorageClass storageClass, Type type, Identifier ident, Expression defaultArg, UserAttributeDeclaration userAttribDecl)
+ extern (D) this(StorageClass storageClass, Type type, Identifier ident, Expression defaultArg, UserAttributeDeclaration userAttribDecl) @safe
{
this.type = type;
this.ident = ident;
@@ -6676,7 +6676,7 @@ extern (C++) final class Parameter : ASTNode
this.userAttribDecl = userAttribDecl;
}
- static Parameter create(StorageClass storageClass, Type type, Identifier ident, Expression defaultArg, UserAttributeDeclaration userAttribDecl)
+ static Parameter create(StorageClass storageClass, Type type, Identifier ident, Expression defaultArg, UserAttributeDeclaration userAttribDecl) @safe
{
return new Parameter(storageClass, type, ident, defaultArg, userAttribDecl);
}
@@ -7646,7 +7646,7 @@ mixin template VisitType(Result)
* handler = string for the name of the visit handler
* Returns: boilerplate code for a case
*/
-pure string visitTYCase(string handler)
+pure string visitTYCase(string handler) @safe
{
if (__ctfe)
{
diff --git a/gcc/d/dmd/mtype.h b/gcc/d/dmd/mtype.h
index fbfd766..457b91f 100644
--- a/gcc/d/dmd/mtype.h
+++ b/gcc/d/dmd/mtype.h
@@ -123,8 +123,9 @@ enum VarArgValues
{
VARARGnone = 0, /// fixed number of arguments
VARARGvariadic = 1, /// T t, ...) can be C-style (core.stdc.stdarg) or D-style (core.vararg)
- VARARGtypesafe = 2 /// T t ...) typesafe https://dlang.org/spec/function.html#typesafe_variadic_functions
+ VARARGtypesafe = 2, /// T t ...) typesafe https://dlang.org/spec/function.html#typesafe_variadic_functions
/// or https://dlang.org/spec/function.html#typesafe_variadic_functions
+ VARARGKRvariadic = 3 /// K+R C style variadics (no function prototype)
};
typedef unsigned char VarArg;
diff --git a/gcc/d/dmd/mustuse.d b/gcc/d/dmd/mustuse.d
index 11cc3b8d..844f719 100644
--- a/gcc/d/dmd/mustuse.d
+++ b/gcc/d/dmd/mustuse.d
@@ -18,11 +18,11 @@ import dmd.identifier;
import dmd.location;
// Used in isIncrementOrDecrement
-private static const StringExp plusPlus, minusMinus;
+private const StringExp plusPlus, minusMinus;
// Loc.initial cannot be used in static initializers, so
// these need a static constructor.
-static this()
+shared static this()
{
plusPlus = new StringExp(Loc.initial, "++");
minusMinus = new StringExp(Loc.initial, "--");
diff --git a/gcc/d/dmd/nogc.d b/gcc/d/dmd/nogc.d
index d7a2820..01a6832 100644
--- a/gcc/d/dmd/nogc.d
+++ b/gcc/d/dmd/nogc.d
@@ -19,6 +19,7 @@ import dmd.aggregate;
import dmd.astenums;
import dmd.declaration;
import dmd.dscope;
+import dmd.dtemplate : isDsymbol;
import dmd.errors;
import dmd.expression;
import dmd.func;
@@ -40,7 +41,7 @@ public:
bool checkOnly; // don't print errors
bool err;
- extern (D) this(FuncDeclaration f) scope
+ extern (D) this(FuncDeclaration f) scope @safe
{
this.f = f;
}
@@ -263,6 +264,7 @@ private FuncDeclaration stripHookTraceImpl(FuncDeclaration fd)
// Get the Hook from the second template parameter
auto templateInstance = fd.parent.isTemplateInstance;
RootObject hook = (*templateInstance.tiargs)[1];
- assert(hook.dyncast() == DYNCAST.dsymbol, "Expected _d_HookTraceImpl's second template parameter to be an alias to the hook!");
- return (cast(Dsymbol)hook).isFuncDeclaration;
+ Dsymbol s = hook.isDsymbol();
+ assert(s, "Expected _d_HookTraceImpl's second template parameter to be an alias to the hook!");
+ return s.isFuncDeclaration;
}
diff --git a/gcc/d/dmd/ob.d b/gcc/d/dmd/ob.d
index 56243a0..4774d1f 100644
--- a/gcc/d/dmd/ob.d
+++ b/gcc/d/dmd/ob.d
@@ -145,7 +145,7 @@ enum ObType : ubyte
fend,
}
-string toString(ObType obtype)
+string toString(ObType obtype) @safe
{
return obtype == ObType.goto_ ? "goto " :
obtype == ObType.return_ ? "ret " :
@@ -202,7 +202,7 @@ const(char)* toChars(PtrState state)
return toString(state).ptr;
}
-string toString(PtrState state)
+string toString(PtrState state) @safe
{
return ["Initial", "Undefined", "Owner", "Borrowed", "Readonly"][state];
}
@@ -1012,7 +1012,7 @@ void insertFinallyBlockGotos(ref ObNodes obnodes)
* Set the `index` field of each ObNode
* to its index in the `obnodes[]` array.
*/
-void numberNodes(ref ObNodes obnodes)
+void numberNodes(ref ObNodes obnodes) @safe
{
//printf("numberNodes()\n");
foreach (i, ob; obnodes)
diff --git a/gcc/d/dmd/objc.d b/gcc/d/dmd/objc.d
index c493323..623a362 100644
--- a/gcc/d/dmd/objc.d
+++ b/gcc/d/dmd/objc.d
@@ -58,7 +58,7 @@ struct ObjcSelector
stringtable._init();
}
- extern (D) this(const(char)* sv, size_t len, size_t pcount)
+ extern (D) this(const(char)* sv, size_t len, size_t pcount) @safe
{
stringvalue = sv;
stringlen = len;
@@ -119,7 +119,7 @@ struct ObjcSelector
buf.writeByte('_');
foreach (i, fparam; ftype.parameterList)
{
- mangleToBuffer(fparam.type, &buf);
+ mangleToBuffer(fparam.type, buf);
buf.writeByte(':');
}
}
@@ -167,12 +167,12 @@ extern (C++) struct ObjcClassDeclaration
/// List of non-inherited methods.
FuncDeclaration[] methodList;
- extern (D) this(ClassDeclaration classDeclaration)
+ extern (D) this(ClassDeclaration classDeclaration) @safe
{
this.classDeclaration = classDeclaration;
}
- bool isRootClass() const
+ bool isRootClass() const @safe
{
return classDeclaration.classKind == ClassKind.objc &&
!metaclass &&
diff --git a/gcc/d/dmd/opover.d b/gcc/d/dmd/opover.d
index 8b42a91..457e8b6 100644
--- a/gcc/d/dmd/opover.d
+++ b/gcc/d/dmd/opover.d
@@ -43,7 +43,7 @@ import dmd.visitor;
* Determine if operands of binary op can be reversed
* to fit operator overload.
*/
-bool isCommutative(EXP op)
+bool isCommutative(EXP op) @safe
{
switch (op)
{
@@ -1840,7 +1840,7 @@ private bool matchParamsToOpApply(TypeFunction tf, Parameters* parameters, bool
* Returns:
* reverse of op
*/
-private EXP reverseRelation(EXP op) pure
+private EXP reverseRelation(EXP op) pure @safe
{
switch (op)
{
diff --git a/gcc/d/dmd/parse.d b/gcc/d/dmd/parse.d
index d15e448..13bba4f 100644
--- a/gcc/d/dmd/parse.d
+++ b/gcc/d/dmd/parse.d
@@ -1222,7 +1222,10 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
(orig & STC.scope_) ? "scope".ptr : "ref".ptr);
}
else if (added & STC.ref_)
- deprecation("using `in ref` is deprecated, use `-preview=in` and `in` instead");
+ {
+ // accept for legacy compatibility
+ //deprecation("using `in ref` is deprecated, use `-preview=in` and `in` instead");
+ }
else
error("attribute `scope` cannot be applied with `in`, use `-preview=in` instead");
return orig;
@@ -1240,7 +1243,10 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
stc_str, stc_str);
}
else if (orig & STC.ref_)
- deprecation("using `ref in` is deprecated, use `-preview=in` and `in` instead");
+ {
+ // accept for legacy compatibility
+ //deprecation("using `in ref` is deprecated, use `-preview=in` and `in` instead");
+ }
else
error("attribute `in` cannot be added after `scope`: remove `scope` and use `-preview=in`");
return orig;
@@ -3042,7 +3048,6 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
else if (token.value == TOK.leftCurly)
{
bool isAnonymousEnum = !id;
- TOK prevTOK;
//printf("enum definition\n");
e.members = new AST.Dsymbols();
@@ -3065,9 +3070,8 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
StorageClass stc;
AST.Expression deprecationMessage;
enum attributeErrorMessage = "`%s` is not a valid attribute for enum members";
- while(token.value != TOK.rightCurly
- && token.value != TOK.comma
- && token.value != TOK.assign)
+ Lattrs:
+ while (1)
{
switch (token.value)
{
@@ -3082,7 +3086,6 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
AST.stcToBuffer(&buf, _stc);
error(attributeErrorMessage, buf.peekChars());
}
- prevTOK = token.value;
nextToken();
}
break;
@@ -3090,94 +3093,86 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
stc |= STC.deprecated_;
if (!parseDeprecatedAttribute(deprecationMessage))
{
- prevTOK = token.value;
- nextToken();
- }
- break;
- case TOK.identifier:
- const tv = peekNext();
- if (tv == TOK.assign || tv == TOK.comma || tv == TOK.rightCurly)
- {
- ident = token.ident;
- type = null;
- prevTOK = token.value;
nextToken();
}
- else
- {
- if (isAnonymousEnum)
- goto default; // maybe `Type identifier`
-
- prevTOK = token.value;
- nextToken();
- error("expected `,` or `=` after identifier, not `%s`", token.toChars());
- }
break;
default:
- if (isAnonymousEnum)
- {
- if (type)
- {
- error("expected identifier after type, not `%s`", token.toChars());
- type = null;
- break;
- }
- type = parseType(&ident, null);
- if (type == AST.Type.terror)
- {
- type = null;
- prevTOK = token.value;
- nextToken();
- }
- else
- {
- prevTOK = TOK.identifier;
- const tv = token.value;
- if (ident && tv != TOK.assign && tv != TOK.comma && tv != TOK.rightCurly)
- {
- error("expected `,` or `=` after identifier, not `%s`", token.toChars());
- }
- }
- }
- else
- {
- error(attributeErrorMessage, token.toChars());
- prevTOK = token.value;
- nextToken();
- }
- break;
+ break Lattrs;
}
- if (token.value == TOK.comma)
+ }
+ if (token.value == TOK.identifier)
+ {
+ const tv = peekNext();
+ if (tv == TOK.assign || tv == TOK.comma || tv == TOK.rightCurly)
{
- prevTOK = token.value;
+ ident = token.ident;
+ type = null;
+ nextToken();
}
- }
+ else
+ {
+ if (isAnonymousEnum)
+ goto Ltype;
- if (type && type != AST.Type.terror)
- {
- if (!ident)
- error("no identifier for declarator `%s`", type.toChars());
- if (!isAnonymousEnum)
- error("type only allowed if anonymous enum and no enum type");
+ nextToken();
+ error("expected `,` or `=` after identifier, not `%s`", token.toChars());
+ }
}
- AST.Expression value;
- if (token.value == TOK.assign)
+ else
{
- if (prevTOK == TOK.identifier)
+ if (isAnonymousEnum)
{
- nextToken();
- value = parseAssignExp();
+ Ltype:
+ // Type identifier
+ type = parseType(&ident, null);
+ if (type == AST.Type.terror)
+ {
+ type = null;
+ nextToken();
+ }
+ else if (!ident)
+ {
+ error("no identifier for declarator `%s`", type.toChars());
+ type = null;
+ }
+ else
+ {
+ const tv = token.value;
+ if (tv != TOK.assign && tv != TOK.comma && tv != TOK.rightCurly)
+ {
+ error("expected `,` or `=` after identifier, not `%s`", token.toChars());
+ nextToken();
+ }
+ }
}
else
{
- error("assignment must be preceded by an identifier");
- nextToken();
+ Token* t = &token;
+ if (isBasicType(&t))
+ {
+ error("named enum cannot declare member with type", (*t).toChars());
+ nextToken();
+ }
+ else
+ check(TOK.identifier);
+
+ // avoid extra error messages
+ const tv = token.value;
+ if (tv != TOK.assign && tv != TOK.comma && tv != TOK.rightCurly && tv != TOK.endOfFile)
+ continue;
}
}
+
+ AST.Expression value;
+ if (token.value == TOK.assign)
+ {
+ nextToken();
+ value = parseAssignExp();
+ }
else
{
value = null;
- if (type && type != AST.Type.terror && isAnonymousEnum)
+ if (type && isAnonymousEnum)
error("initializer required after `%s` when type is specified", ident.toChars());
}
@@ -3197,10 +3192,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
em.userAttribDecl = uad;
}
- if (token.value == TOK.rightCurly)
- {
- }
- else
+ if (token.value != TOK.rightCurly)
{
addComment(em, comment);
comment = null;
@@ -3218,8 +3210,10 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
nextToken();
}
else
- error("enum declaration is invalid");
-
+ {
+ nextToken();
+ error("expected `{`, not `%s` for enum declaration", token.toChars());
+ }
//printf("-parseEnum() %s\n", e.toChars());
return e;
}
@@ -4611,6 +4605,13 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
*/
if (tpl)
{
+ // @@@DEPRECATED_2.114@@@
+ // Both deprecated in 2.104, change to error
+ if (storage_class & STC.override_)
+ deprecation(loc, "a function template is not virtual so cannot be marked `override`");
+ else if (storage_class & STC.abstract_)
+ deprecation(loc, "a function template is not virtual so cannot be marked `abstract`");
+
// Wrap a template around the function declaration
auto decldefs = new AST.Dsymbols();
decldefs.push(s);
@@ -5622,60 +5623,61 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
AST.Parameter param = null;
StorageClass storageClass = 0;
StorageClass stc = 0;
-LagainStc:
- if (stc)
- {
- storageClass = appendStorageClass(storageClass, stc);
- nextToken();
- }
- switch (token.value)
+ Lwhile:
+ while (1)
{
- case TOK.ref_:
- stc = STC.ref_;
- goto LagainStc;
+ switch (token.value)
+ {
+ // parse ref for better error
+ case TOK.ref_:
+ stc = STC.ref_;
+ break;
- case TOK.scope_:
- stc = STC.scope_;
- goto LagainStc;
+ case TOK.scope_:
+ stc = STC.scope_;
+ break;
- case TOK.auto_:
- stc = STC.auto_;
- goto LagainStc;
+ case TOK.auto_:
+ stc = STC.auto_;
+ break;
- case TOK.const_:
- if (peekNext() != TOK.leftParenthesis)
- {
- stc = STC.const_;
- goto LagainStc;
- }
- break;
+ case TOK.const_:
+ if (peekNext() != TOK.leftParenthesis)
+ {
+ stc = STC.const_;
+ break;
+ }
+ goto default;
- case TOK.immutable_:
- if (peekNext() != TOK.leftParenthesis)
- {
- stc = STC.immutable_;
- goto LagainStc;
- }
- break;
+ case TOK.immutable_:
+ if (peekNext() != TOK.leftParenthesis)
+ {
+ stc = STC.immutable_;
+ break;
+ }
+ goto default;
- case TOK.shared_:
- if (peekNext() != TOK.leftParenthesis)
- {
- stc = STC.shared_;
- goto LagainStc;
- }
- break;
+ case TOK.shared_:
+ if (peekNext() != TOK.leftParenthesis)
+ {
+ stc = STC.shared_;
+ break;
+ }
+ goto default;
- case TOK.inout_:
- if (peekNext() != TOK.leftParenthesis)
- {
- stc = STC.wild;
- goto LagainStc;
- }
- break;
+ case TOK.inout_:
+ if (peekNext() != TOK.leftParenthesis)
+ {
+ stc = STC.wild;
+ break;
+ }
+ goto default;
- default:
- break;
+ default:
+ break Lwhile;
+ }
+ storageClass = appendStorageClass(storageClass, stc);
+ nextToken();
}
auto n = peek(&token);
if (storageClass != 0 && token.value == TOK.identifier && n.value == TOK.assign)
@@ -8709,7 +8711,8 @@ LagainStc:
nextToken();
if (token.value != TOK.identifier)
{
- error("identifier expected following `(type)`.");
+ error("identifier expected following `%s.`, not `%s`",
+ t.toChars(), token.toChars());
return AST.ErrorExp.get();
}
e = new AST.DotIdExp(loc, new AST.TypeExp(loc, t), token.ident);
@@ -8721,7 +8724,8 @@ LagainStc:
e = new AST.TypeExp(loc, t);
if (token.value != TOK.leftParenthesis)
{
- error("`(arguments)` expected following `%s`", t.toChars());
+ error("`(arguments)` expected following `%s`, not `%s`",
+ t.toChars(), token.toChars());
return e;
}
e = new AST.CallExp(loc, e, parseArguments());
diff --git a/gcc/d/dmd/postordervisitor.d b/gcc/d/dmd/postordervisitor.d
index a0c7115..70bd130 100644
--- a/gcc/d/dmd/postordervisitor.d
+++ b/gcc/d/dmd/postordervisitor.d
@@ -40,7 +40,7 @@ private extern (C++) final class PostorderExpressionVisitor : StoppableVisitor
public:
StoppableVisitor v;
- extern (D) this(StoppableVisitor v) scope
+ extern (D) this(StoppableVisitor v) scope @safe
{
this.v = v;
}
diff --git a/gcc/d/dmd/printast.d b/gcc/d/dmd/printast.d
index 8c01095..e43ffad 100644
--- a/gcc/d/dmd/printast.d
+++ b/gcc/d/dmd/printast.d
@@ -39,7 +39,7 @@ extern (C++) final class PrintASTVisitor : Visitor
int indent;
- extern (D) this(int indent) scope
+ extern (D) this(int indent) scope @safe
{
this.indent = indent;
}
diff --git a/gcc/d/dmd/root/complex.d b/gcc/d/dmd/root/complex.d
index fc93bd7..57d1e34 100644
--- a/gcc/d/dmd/root/complex.d
+++ b/gcc/d/dmd/root/complex.d
@@ -29,7 +29,7 @@ extern (C++) struct complex_t
this(re, CTFloat.zero);
}
- this(real_t re, real_t im)
+ this(real_t re, real_t im) @safe
{
this.re = re;
this.im = im;
@@ -99,18 +99,18 @@ extern (C++) struct complex_t
return re || im;
}
- int opEquals(complex_t y) const
+ int opEquals(complex_t y) const @safe
{
return re == y.re && im == y.im;
}
}
-extern (C++) real_t creall(complex_t x)
+extern (C++) real_t creall(complex_t x) @safe
{
return x.re;
}
-extern (C++) real_t cimagl(complex_t x)
+extern (C++) real_t cimagl(complex_t x) @safe
{
return x.im;
}
diff --git a/gcc/d/dmd/root/filename.d b/gcc/d/dmd/root/filename.d
index 3873615..987c793 100644
--- a/gcc/d/dmd/root/filename.d
+++ b/gcc/d/dmd/root/filename.d
@@ -41,9 +41,6 @@ version (Windows)
extern (Windows) DWORD GetFullPathNameW(LPCWSTR, DWORD, LPWSTR, LPWSTR*) nothrow @nogc;
extern (Windows) void SetLastError(DWORD) nothrow @nogc;
extern (C) char* getcwd(char* buffer, size_t maxlen) nothrow;
-
- // assume filenames encoded in system default Windows ANSI code page
- private enum CodePage = CP_ACP;
}
version (CRuntime_Glibc)
@@ -127,7 +124,7 @@ nothrow:
}
/// Ditto
- extern (D) static bool absolute(const(char)[] name) pure @nogc
+ extern (D) static bool absolute(const(char)[] name) pure @nogc @safe
{
if (!name.length)
return false;
@@ -280,7 +277,7 @@ nothrow:
}
/// Ditto
- extern (D) static const(char)[] name(const(char)[] str) pure @nogc
+ extern (D) static const(char)[] name(const(char)[] str) pure @nogc @safe
{
foreach_reverse (idx, char e; str)
{
@@ -1147,6 +1144,8 @@ version(Windows)
*/
char[] toNarrowStringz(const(wchar)[] wide, char[] buffer = null) nothrow
{
+ import dmd.common.file : CodePage;
+
if (wide is null)
return null;
diff --git a/gcc/d/dmd/root/longdouble.d b/gcc/d/dmd/root/longdouble.d
index 5bbed22..8702365 100644
--- a/gcc/d/dmd/root/longdouble.d
+++ b/gcc/d/dmd/root/longdouble.d
@@ -25,12 +25,15 @@ import core.stdc.stdint;
extern(C++):
nothrow:
@nogc:
+pure:
+@trusted:
// Type used by the front-end for compile-time reals
struct longdouble
{
nothrow:
@nogc:
+pure:
extern (D) this(T)(T r)
{
this.set(cast(SetType!T)r);
diff --git a/gcc/d/dmd/root/rmem.d b/gcc/d/dmd/root/rmem.d
index 9b1d9fb..cff5c4c 100644
--- a/gcc/d/dmd/root/rmem.d
+++ b/gcc/d/dmd/root/rmem.d
@@ -110,7 +110,7 @@ extern (C++) struct Mem
* Returns:
* p if not null
*/
- static void* check(void* p) pure nothrow @nogc
+ static void* check(void* p) pure nothrow @nogc @safe
{
return p ? p : error();
}
diff --git a/gcc/d/dmd/root/utf.d b/gcc/d/dmd/root/utf.d
index c9781a4..d7ba17f 100644
--- a/gcc/d/dmd/root/utf.d
+++ b/gcc/d/dmd/root/utf.d
@@ -11,7 +11,7 @@
module dmd.root.utf;
-nothrow pure @nogc:
+@nogc nothrow pure @safe:
/// The Unicode code space is the range of code points [0x000000,0x10FFFF]
/// except the UTF-16 surrogate pairs in the range [0xD800,0xDFFF]
@@ -337,7 +337,7 @@ int utf_codeLength(int sz, dchar c)
return 1;
}
-void utf_encodeChar(char* s, dchar c)
+void utf_encodeChar(char* s, dchar c) @system
{
assert(s !is null);
assert(utf_isValidDchar(c));
@@ -367,7 +367,7 @@ void utf_encodeChar(char* s, dchar c)
assert(0);
}
-void utf_encodeWchar(wchar* s, dchar c)
+void utf_encodeWchar(wchar* s, dchar c) @system
{
assert(s !is null);
assert(utf_isValidDchar(c));
@@ -382,7 +382,7 @@ void utf_encodeWchar(wchar* s, dchar c)
}
}
-void utf_encode(int sz, void* s, dchar c)
+void utf_encode(int sz, void* s, dchar c) @system
{
if (sz == 1)
utf_encodeChar(cast(char*)s, c);
@@ -399,7 +399,7 @@ void utf_encode(int sz, void* s, dchar c)
* Checks whether an Unicode code point is a bidirectional
* control character.
*/
-@safe bool isBidiControl(dchar c)
+bool isBidiControl(dchar c)
{
// Source: https://www.unicode.org/versions/Unicode15.0.0, table 23-3.
switch(c)
diff --git a/gcc/d/dmd/sapply.d b/gcc/d/dmd/sapply.d
index ef01516..13fe691 100644
--- a/gcc/d/dmd/sapply.d
+++ b/gcc/d/dmd/sapply.d
@@ -37,7 +37,7 @@ private extern (C++) final class PostorderStatementVisitor : StoppableVisitor
public:
StoppableVisitor v;
- extern (D) this(StoppableVisitor v) scope
+ extern (D) this(StoppableVisitor v) scope @safe
{
this.v = v;
}
diff --git a/gcc/d/dmd/scope.h b/gcc/d/dmd/scope.h
index da11428..3c4ae49 100644
--- a/gcc/d/dmd/scope.h
+++ b/gcc/d/dmd/scope.h
@@ -10,6 +10,7 @@
#pragma once
+class ErrorSink;
class Identifier;
class Module;
class Statement;
@@ -85,6 +86,7 @@ struct Scope
d_bool inLoop; // true if inside a loop (where constructor calls aren't allowed)
int intypeof; // in typeof(exp)
VarDeclaration *lastVar; // Previous symbol used to prevent goto-skips-init
+ ErrorSink *eSink; // sink for error messages
/* If minst && !tinst, it's in definitely non-speculative scope (eg. module member scope).
* If !minst && !tinst, it's in definitely speculative scope (eg. template constraint).
diff --git a/gcc/d/dmd/semantic2.d b/gcc/d/dmd/semantic2.d
index 3cbf14f..53c8714 100644
--- a/gcc/d/dmd/semantic2.d
+++ b/gcc/d/dmd/semantic2.d
@@ -83,7 +83,7 @@ private extern(C++) final class Semantic2Visitor : Visitor
{
alias visit = Visitor.visit;
Scope* sc;
- this(Scope* sc) scope
+ this(Scope* sc) scope @safe
{
this.sc = sc;
}
@@ -245,8 +245,9 @@ private extern(C++) final class Semantic2Visitor : Visitor
return;
//printf("VarDeclaration::semantic2('%s')\n", toChars());
+ sc = sc.push();
sc.varDecl = vd;
- scope(exit) sc.varDecl = null;
+ scope(exit) sc = sc.pop();
if (vd.aliasTuple) // if it's a tuple
{
@@ -345,7 +346,7 @@ private extern(C++) final class Semantic2Visitor : Visitor
// Note that modules get their own scope, from scratch.
// This is so regardless of where in the syntax a module
// gets imported, it is unaffected by context.
- Scope* sc = Scope.createGlobal(mod); // create root scope
+ Scope* sc = Scope.createGlobal(mod, global.errorSink); // create root scope
//printf("Module = %p\n", sc.scopesym);
if (mod.members)
{
diff --git a/gcc/d/dmd/semantic3.d b/gcc/d/dmd/semantic3.d
index c7d1219..bff89f8 100644
--- a/gcc/d/dmd/semantic3.d
+++ b/gcc/d/dmd/semantic3.d
@@ -88,7 +88,7 @@ private extern(C++) final class Semantic3Visitor : Visitor
alias visit = Visitor.visit;
Scope* sc;
- this(Scope* sc) scope
+ this(Scope* sc) scope @safe
{
this.sc = sc;
}
@@ -193,7 +193,7 @@ private extern(C++) final class Semantic3Visitor : Visitor
// Note that modules get their own scope, from scratch.
// This is so regardless of where in the syntax a module
// gets imported, it is unaffected by context.
- Scope* sc = Scope.createGlobal(mod); // create root scope
+ Scope* sc = Scope.createGlobal(mod, global.errorSink); // create root scope
//printf("Module = %p\n", sc.scopesym);
if (mod.members)
{
@@ -705,7 +705,7 @@ private extern(C++) final class Semantic3Visitor : Visitor
}
sc2.ctorflow.freeFieldinit();
- if (cd && !(sc2.ctorflow.callSuper & CSX.any_ctor) && cd.baseClass && cd.baseClass.ctor)
+ if (cd && !(sc2.ctorflow.callSuper & (CSX.any_ctor | CSX.halt)) && cd.baseClass && cd.baseClass.ctor)
{
sc2.ctorflow.callSuper = CSX.none;
@@ -1423,7 +1423,7 @@ private extern(C++) final class Semantic3Visitor : Visitor
*/
AggregateDeclaration ad = ctor.isMemberDecl();
if (!ctor.fbody || !ad || !ad.fieldDtor ||
- global.params.dtorFields == FeatureState.disabled || !global.params.useExceptions || ctor.type.toTypeFunction.isnothrow)
+ global.params.dtorFields == FeatureState.disabled || !global.params.useExceptions || ctor.type.toTypeFunction.isnothrow)
return visit(cast(FuncDeclaration)ctor);
/* Generate:
@@ -1602,7 +1602,7 @@ private struct FuncDeclSem3
// Scope of analysis
Scope* sc;
- this(FuncDeclaration fd,Scope* s) scope
+ this(FuncDeclaration fd,Scope* s) scope @safe
{
funcdecl = fd;
sc = s;
diff --git a/gcc/d/dmd/sideeffect.d b/gcc/d/dmd/sideeffect.d
index 90b86df..30921c6 100644
--- a/gcc/d/dmd/sideeffect.d
+++ b/gcc/d/dmd/sideeffect.d
@@ -37,7 +37,7 @@ extern (C++) bool isTrivialExp(Expression e)
{
alias visit = typeof(super).visit;
public:
- extern (D) this() scope
+ extern (D) this() scope @safe
{
}
@@ -75,7 +75,7 @@ extern (C++) bool hasSideEffect(Expression e, bool assumeImpureCalls = false)
{
alias visit = typeof(super).visit;
public:
- extern (D) this() scope
+ extern (D) this() scope @safe
{
}
diff --git a/gcc/d/dmd/statement.d b/gcc/d/dmd/statement.d
index 3ccf228..607dd51 100644
--- a/gcc/d/dmd/statement.d
+++ b/gcc/d/dmd/statement.d
@@ -84,7 +84,7 @@ extern (C++) abstract class Statement : ASTNode
return DYNCAST.statement;
}
- final extern (D) this(const ref Loc loc, STMT stmt)
+ final extern (D) this(const ref Loc loc, STMT stmt) @safe
{
this.loc = loc;
this.stmt = stmt;
@@ -129,7 +129,7 @@ extern (C++) abstract class Statement : ASTNode
{
va_list ap;
va_start(ap, format);
- .verror(loc, format, ap);
+ .verrorReport(loc, format, ap, ErrorKind.error);
va_end(ap);
}
@@ -137,7 +137,7 @@ extern (C++) abstract class Statement : ASTNode
{
va_list ap;
va_start(ap, format);
- .vwarning(loc, format, ap);
+ .verrorReport(loc, format, ap, ErrorKind.warning);
va_end(ap);
}
@@ -145,7 +145,7 @@ extern (C++) abstract class Statement : ASTNode
{
va_list ap;
va_start(ap, format);
- .vdeprecation(loc, format, ap);
+ .verrorReport(loc, format, ap, ErrorKind.deprecation);
va_end(ap);
}
}
@@ -155,7 +155,7 @@ extern (C++) abstract class Statement : ASTNode
{
va_list ap;
va_start(ap, format);
- .verror(loc, format, ap);
+ .verrorReport(loc, format, ap, ErrorKind.error);
va_end(ap);
}
@@ -163,7 +163,7 @@ extern (C++) abstract class Statement : ASTNode
{
va_list ap;
va_start(ap, format);
- .vwarning(loc, format, ap);
+ .verrorReport(loc, format, ap, ErrorKind.warning);
va_end(ap);
}
@@ -171,7 +171,7 @@ extern (C++) abstract class Statement : ASTNode
{
va_list ap;
va_start(ap, format);
- .vdeprecation(loc, format, ap);
+ .verrorReport(loc, format, ap, ErrorKind.deprecation);
va_end(ap);
}
}
@@ -447,7 +447,7 @@ extern (C++) final class PeelStatement : Statement
{
Statement s;
- extern (D) this(Statement s)
+ extern (D) this(Statement s) @safe
{
super(s.loc, STMT.Peel);
this.s = s;
@@ -467,25 +467,25 @@ extern (C++) class ExpStatement : Statement
{
Expression exp;
- final extern (D) this(const ref Loc loc, Expression exp)
+ final extern (D) this(const ref Loc loc, Expression exp) @safe
{
super(loc, STMT.Exp);
this.exp = exp;
}
- final extern (D) this(const ref Loc loc, Expression exp, STMT stmt)
+ final extern (D) this(const ref Loc loc, Expression exp, STMT stmt) @safe
{
super(loc, stmt);
this.exp = exp;
}
- final extern (D) this(const ref Loc loc, Dsymbol declaration)
+ final extern (D) this(const ref Loc loc, Dsymbol declaration) @safe
{
super(loc, STMT.Exp);
this.exp = new DeclarationExp(loc, declaration);
}
- static ExpStatement create(const ref Loc loc, Expression exp)
+ static ExpStatement create(const ref Loc loc, Expression exp) @safe
{
return new ExpStatement(loc, exp);
}
@@ -508,7 +508,7 @@ extern (C++) final class DtorExpStatement : ExpStatement
// Wraps an expression that is the destruction of 'var'
VarDeclaration var;
- extern (D) this(const ref Loc loc, Expression exp, VarDeclaration var)
+ extern (D) this(const ref Loc loc, Expression exp, VarDeclaration var) @safe
{
super(loc, exp, STMT.DtorExp);
this.var = var;
@@ -540,7 +540,7 @@ extern (C++) final class MixinStatement : Statement
this(loc, exps);
}
- extern (D) this(const ref Loc loc, Expressions* exps)
+ extern (D) this(const ref Loc loc, Expressions* exps) @safe
{
super(loc, STMT.Mixin);
this.exps = exps;
@@ -571,13 +571,13 @@ extern (C++) class CompoundStatement : Statement
* loc = Instantiation information
* statements = An array of `Statement`s, that will referenced by this class
*/
- final extern (D) this(const ref Loc loc, Statements* statements)
+ final extern (D) this(const ref Loc loc, Statements* statements) @safe
{
super(loc, STMT.Compound);
this.statements = statements;
}
- final extern (D) this(const ref Loc loc, Statements* statements, STMT stmt)
+ final extern (D) this(const ref Loc loc, Statements* statements, STMT stmt) @safe
{
super(loc, stmt);
this.statements = statements;
@@ -649,7 +649,7 @@ extern (C++) class CompoundStatement : Statement
*/
extern (C++) final class CompoundDeclarationStatement : CompoundStatement
{
- extern (D) this(const ref Loc loc, Statements* statements)
+ extern (D) this(const ref Loc loc, Statements* statements) @safe
{
super(loc, statements, STMT.CompoundDeclaration);
}
@@ -678,7 +678,7 @@ extern (C++) final class UnrolledLoopStatement : Statement
{
Statements* statements;
- extern (D) this(const ref Loc loc, Statements* statements)
+ extern (D) this(const ref Loc loc, Statements* statements) @safe
{
super(loc, STMT.UnrolledLoop);
this.statements = statements;
@@ -717,7 +717,7 @@ extern (C++) final class ScopeStatement : Statement
Statement statement;
Loc endloc; // location of closing curly bracket
- extern (D) this(const ref Loc loc, Statement statement, Loc endloc)
+ extern (D) this(const ref Loc loc, Statement statement, Loc endloc) @safe
{
super(loc, STMT.Scope);
this.statement = statement;
@@ -767,7 +767,7 @@ extern (C++) final class ForwardingStatement : Statement
/// The wrapped statement.
Statement statement;
- extern (D) this(const ref Loc loc, ForwardingScopeDsymbol sym, Statement statement)
+ extern (D) this(const ref Loc loc, ForwardingScopeDsymbol sym, Statement statement) @safe
{
super(loc, STMT.Forwarding);
this.sym = sym;
@@ -775,7 +775,7 @@ extern (C++) final class ForwardingStatement : Statement
this.statement = statement;
}
- extern (D) this(const ref Loc loc, Statement statement)
+ extern (D) this(const ref Loc loc, Statement statement) @safe
{
auto sym = new ForwardingScopeDsymbol();
sym.symtab = new DsymbolTable();
@@ -804,7 +804,7 @@ extern (C++) final class WhileStatement : Statement
Statement _body;
Loc endloc; // location of closing curly bracket
- extern (D) this(const ref Loc loc, Expression condition, Statement _body, Loc endloc, Parameter param = null)
+ extern (D) this(const ref Loc loc, Expression condition, Statement _body, Loc endloc, Parameter param = null) @safe
{
super(loc, STMT.While);
this.condition = condition;
@@ -846,7 +846,7 @@ extern (C++) final class DoStatement : Statement
Expression condition;
Loc endloc; // location of ';' after while
- extern (D) this(const ref Loc loc, Statement _body, Expression condition, Loc endloc)
+ extern (D) this(const ref Loc loc, Statement _body, Expression condition, Loc endloc) @safe
{
super(loc, STMT.Do);
this._body = _body;
@@ -894,7 +894,7 @@ extern (C++) final class ForStatement : Statement
// treat that label as referring to this loop.
Statement relatedLabeled;
- extern (D) this(const ref Loc loc, Statement _init, Expression condition, Expression increment, Statement _body, Loc endloc)
+ extern (D) this(const ref Loc loc, Statement _init, Expression condition, Expression increment, Statement _body, Loc endloc) @safe
{
super(loc, STMT.For);
this._init = _init;
@@ -955,7 +955,7 @@ extern (C++) final class ForeachStatement : Statement
Statements* cases; // put breaks, continues, gotos and returns here
ScopeStatements* gotos; // forward referenced goto's go here
- extern (D) this(const ref Loc loc, TOK op, Parameters* parameters, Expression aggr, Statement _body, Loc endloc)
+ extern (D) this(const ref Loc loc, TOK op, Parameters* parameters, Expression aggr, Statement _body, Loc endloc) @safe
{
super(loc, STMT.Foreach);
this.op = op;
@@ -1004,7 +1004,7 @@ extern (C++) final class ForeachRangeStatement : Statement
VarDeclaration key;
- extern (D) this(const ref Loc loc, TOK op, Parameter prm, Expression lwr, Expression upr, Statement _body, Loc endloc)
+ extern (D) this(const ref Loc loc, TOK op, Parameter prm, Expression lwr, Expression upr, Statement _body, Loc endloc) @safe
{
super(loc, STMT.ForeachRange);
this.op = op;
@@ -1048,7 +1048,7 @@ extern (C++) final class IfStatement : Statement
VarDeclaration match; // for MatchExpression results
Loc endloc; // location of closing curly bracket
- extern (D) this(const ref Loc loc, Parameter prm, Expression condition, Statement ifbody, Statement elsebody, Loc endloc)
+ extern (D) this(const ref Loc loc, Parameter prm, Expression condition, Statement ifbody, Statement elsebody, Loc endloc) @safe
{
super(loc, STMT.If);
this.prm = prm;
@@ -1093,7 +1093,7 @@ extern (C++) final class ConditionalStatement : Statement
Statement ifbody;
Statement elsebody;
- extern (D) this(const ref Loc loc, Condition condition, Statement ifbody, Statement elsebody)
+ extern (D) this(const ref Loc loc, Condition condition, Statement ifbody, Statement elsebody) @safe
{
super(loc, STMT.Conditional);
this.condition = condition;
@@ -1128,7 +1128,7 @@ extern (C++) final class StaticForeachStatement : Statement
{
StaticForeach sfe;
- extern (D) this(const ref Loc loc, StaticForeach sfe)
+ extern (D) this(const ref Loc loc, StaticForeach sfe) @safe
{
super(loc, STMT.StaticForeach);
this.sfe = sfe;
@@ -1154,7 +1154,7 @@ extern (C++) final class PragmaStatement : Statement
Expressions* args; // array of Expression's
Statement _body;
- extern (D) this(const ref Loc loc, const Identifier ident, Expressions* args, Statement _body)
+ extern (D) this(const ref Loc loc, const Identifier ident, Expressions* args, Statement _body) @safe
{
super(loc, STMT.Pragma);
this.ident = ident;
@@ -1180,7 +1180,7 @@ extern (C++) final class StaticAssertStatement : Statement
{
StaticAssert sa;
- extern (D) this(StaticAssert sa)
+ extern (D) this(StaticAssert sa) @safe
{
super(sa.loc, STMT.StaticAssert);
this.sa = sa;
@@ -1291,7 +1291,7 @@ extern (C++) final class CaseStatement : Statement
VarDeclaration lastVar;
void* extra; // for use by Statement_toIR()
- extern (D) this(const ref Loc loc, Expression exp, Statement statement)
+ extern (D) this(const ref Loc loc, Expression exp, Statement statement) @safe
{
super(loc, STMT.Case);
this.exp = exp;
@@ -1318,7 +1318,7 @@ extern (C++) final class CaseRangeStatement : Statement
Expression last;
Statement statement;
- extern (D) this(const ref Loc loc, Expression first, Expression last, Statement statement)
+ extern (D) this(const ref Loc loc, Expression first, Expression last, Statement statement) @safe
{
super(loc, STMT.CaseRange);
this.first = first;
@@ -1346,7 +1346,7 @@ extern (C++) final class DefaultStatement : Statement
VarDeclaration lastVar;
- extern (D) this(const ref Loc loc, Statement statement)
+ extern (D) this(const ref Loc loc, Statement statement) @safe
{
super(loc, STMT.Default);
this.statement = statement;
@@ -1370,7 +1370,7 @@ extern (C++) final class GotoDefaultStatement : Statement
{
SwitchStatement sw;
- extern (D) this(const ref Loc loc)
+ extern (D) this(const ref Loc loc) @safe
{
super(loc, STMT.GotoDefault);
}
@@ -1395,7 +1395,7 @@ extern (C++) final class GotoCaseStatement : Statement
CaseStatement cs; // case statement it resolves to
- extern (D) this(const ref Loc loc, Expression exp)
+ extern (D) this(const ref Loc loc, Expression exp) @safe
{
super(loc, STMT.GotoCase);
this.exp = exp;
@@ -1418,12 +1418,12 @@ extern (C++) final class SwitchErrorStatement : Statement
{
Expression exp;
- extern (D) this(const ref Loc loc)
+ extern (D) this(const ref Loc loc) @safe
{
super(loc, STMT.SwitchError);
}
- final extern (D) this(const ref Loc loc, Expression exp)
+ final extern (D) this(const ref Loc loc, Expression exp) @safe
{
super(loc, STMT.SwitchError);
this.exp = exp;
@@ -1443,7 +1443,7 @@ extern (C++) final class ReturnStatement : Statement
Expression exp;
size_t caseDim;
- extern (D) this(const ref Loc loc, Expression exp)
+ extern (D) this(const ref Loc loc, Expression exp) @safe
{
super(loc, STMT.Return);
this.exp = exp;
@@ -1472,7 +1472,7 @@ extern (C++) final class BreakStatement : Statement
{
Identifier ident;
- extern (D) this(const ref Loc loc, Identifier ident)
+ extern (D) this(const ref Loc loc, Identifier ident) @safe
{
super(loc, STMT.Break);
this.ident = ident;
@@ -1496,7 +1496,7 @@ extern (C++) final class ContinueStatement : Statement
{
Identifier ident;
- extern (D) this(const ref Loc loc, Identifier ident)
+ extern (D) this(const ref Loc loc, Identifier ident) @safe
{
super(loc, STMT.Continue);
this.ident = ident;
@@ -1521,7 +1521,7 @@ extern (C++) final class SynchronizedStatement : Statement
Expression exp;
Statement _body;
- extern (D) this(const ref Loc loc, Expression exp, Statement _body)
+ extern (D) this(const ref Loc loc, Expression exp, Statement _body) @safe
{
super(loc, STMT.Synchronized);
this.exp = exp;
@@ -1559,7 +1559,7 @@ extern (C++) final class WithStatement : Statement
VarDeclaration wthis;
Loc endloc;
- extern (D) this(const ref Loc loc, Expression exp, Statement _body, Loc endloc)
+ extern (D) this(const ref Loc loc, Expression exp, Statement _body, Loc endloc) @safe
{
super(loc, STMT.With);
this.exp = exp;
@@ -1588,7 +1588,7 @@ extern (C++) final class TryCatchStatement : Statement
Statement tryBody; /// set to enclosing TryCatchStatement or TryFinallyStatement if in _body portion
- extern (D) this(const ref Loc loc, Statement _body, Catches* catches)
+ extern (D) this(const ref Loc loc, Statement _body, Catches* catches) @safe
{
super(loc, STMT.TryCatch);
this._body = _body;
@@ -1632,7 +1632,7 @@ extern (C++) final class Catch : RootObject
// was generated by the compiler, wasn't present in source code
bool internalCatch;
- extern (D) this(const ref Loc loc, Type type, Identifier ident, Statement handler)
+ extern (D) this(const ref Loc loc, Type type, Identifier ident, Statement handler) @safe
{
//printf("Catch(%s, loc = %s)\n", id.toChars(), loc.toChars());
this.loc = loc;
@@ -1660,7 +1660,7 @@ extern (C++) final class TryFinallyStatement : Statement
Statement tryBody; /// set to enclosing TryCatchStatement or TryFinallyStatement if in _body portion
bool bodyFallsThru; /// true if _body falls through to finally
- extern (D) this(const ref Loc loc, Statement _body, Statement finalbody)
+ extern (D) this(const ref Loc loc, Statement _body, Statement finalbody) @safe
{
super(loc, STMT.TryFinally);
this._body = _body;
@@ -1668,7 +1668,7 @@ extern (C++) final class TryFinallyStatement : Statement
this.bodyFallsThru = true; // assume true until statementSemantic()
}
- static TryFinallyStatement create(const ref Loc loc, Statement _body, Statement finalbody)
+ static TryFinallyStatement create(const ref Loc loc, Statement _body, Statement finalbody) @safe
{
return new TryFinallyStatement(loc, _body, finalbody);
}
@@ -1702,7 +1702,7 @@ extern (C++) final class ScopeGuardStatement : Statement
TOK tok;
Statement statement;
- extern (D) this(const ref Loc loc, TOK tok, Statement statement)
+ extern (D) this(const ref Loc loc, TOK tok, Statement statement) @safe
{
super(loc, STMT.ScopeGuard);
this.tok = tok;
@@ -1730,7 +1730,7 @@ extern (C++) final class ThrowStatement : Statement
// was generated by the compiler, wasn't present in source code
bool internalThrow;
- extern (D) this(const ref Loc loc, Expression exp)
+ extern (D) this(const ref Loc loc, Expression exp) @safe
{
super(loc, STMT.Throw);
this.exp = exp;
@@ -1755,7 +1755,7 @@ extern (C++) final class DebugStatement : Statement
{
Statement statement;
- extern (D) this(const ref Loc loc, Statement statement)
+ extern (D) this(const ref Loc loc, Statement statement) @safe
{
super(loc, STMT.Debug);
this.statement = statement;
@@ -1785,7 +1785,7 @@ extern (C++) final class GotoStatement : Statement
VarDeclaration lastVar;
bool inCtfeBlock; /// set if goto is inside an `if (__ctfe)` block
- extern (D) this(const ref Loc loc, Identifier ident)
+ extern (D) this(const ref Loc loc, Identifier ident) @safe
{
super(loc, STMT.Goto);
this.ident = ident;
@@ -1900,7 +1900,7 @@ extern (C++) final class LabelStatement : Statement
bool breaks; // someone did a 'break ident'
bool inCtfeBlock; // inside a block dominated by `if (__ctfe)`
- extern (D) this(const ref Loc loc, Identifier ident, Statement statement)
+ extern (D) this(const ref Loc loc, Identifier ident, Statement statement) @safe
{
super(loc, STMT.Label);
this.ident = ident;
@@ -1927,12 +1927,16 @@ extern (C++) final class LabelDsymbol : Dsymbol
bool deleted; // set if rewritten to return in foreach delegate
bool iasm; // set if used by inline assembler
- extern (D) this(Identifier ident, const ref Loc loc = Loc.initial)
+ // set if label was defined multiple times, to avoid duplicate errors
+ // can be removed if generic error message deduplication is implemented
+ bool duplicated;
+
+ extern (D) this(Identifier ident, const ref Loc loc = Loc.initial) @safe
{
super(loc, ident);
}
- static LabelDsymbol create(Identifier ident)
+ static LabelDsymbol create(Identifier ident) @safe
{
return new LabelDsymbol(ident);
}
@@ -1956,13 +1960,13 @@ extern (C++) class AsmStatement : Statement
{
Token* tokens;
- extern (D) this(const ref Loc loc, Token* tokens)
+ extern (D) this(const ref Loc loc, Token* tokens) @safe
{
super(loc, STMT.Asm);
this.tokens = tokens;
}
- extern (D) this(const ref Loc loc, Token* tokens, STMT stmt)
+ extern (D) this(const ref Loc loc, Token* tokens, STMT stmt) @safe
{
super(loc, stmt);
this.tokens = tokens;
@@ -1990,7 +1994,7 @@ extern (C++) final class InlineAsmStatement : AsmStatement
bool refparam; // true if function parameter is referenced
bool naked; // true if function is to be naked
- extern (D) this(const ref Loc loc, Token* tokens)
+ extern (D) this(const ref Loc loc, Token* tokens) @safe
{
super(loc, tokens, STMT.InlineAsm);
}
@@ -2022,7 +2026,7 @@ extern (C++) final class GccAsmStatement : AsmStatement
Identifiers* labels; // list of goto labels
GotoStatements* gotos; // of the goto labels, the equivalent statements they represent
- extern (D) this(const ref Loc loc, Token* tokens)
+ extern (D) this(const ref Loc loc, Token* tokens) @safe
{
super(loc, tokens, STMT.GccAsm);
}
@@ -2045,7 +2049,7 @@ extern (C++) final class CompoundAsmStatement : CompoundStatement
{
StorageClass stc; // postfix attributes like nothrow/pure/@trusted
- extern (D) this(const ref Loc loc, Statements* statements, StorageClass stc)
+ extern (D) this(const ref Loc loc, Statements* statements, StorageClass stc) @safe
{
super(loc, statements, STMT.CompoundAsm);
this.stc = stc;
@@ -2074,7 +2078,7 @@ extern (C++) final class ImportStatement : Statement
{
Dsymbols* imports; // Array of Import's
- extern (D) this(const ref Loc loc, Dsymbols* imports)
+ extern (D) this(const ref Loc loc, Dsymbols* imports) @safe
{
super(loc, STMT.Import);
this.imports = imports;
@@ -2157,7 +2161,7 @@ mixin template VisitStatement(Result)
* handler = string for the name of the visit handler
* Returns: boilerplate code for a case
*/
-pure string visitStmtCase(string handler)
+pure string visitStmtCase(string handler) @safe
{
if (__ctfe)
{
diff --git a/gcc/d/dmd/statement.h b/gcc/d/dmd/statement.h
index b7403b5..eb4849d 100644
--- a/gcc/d/dmd/statement.h
+++ b/gcc/d/dmd/statement.h
@@ -699,6 +699,7 @@ public:
d_bool deleted; // set if rewritten to return in foreach delegate
d_bool iasm; // set if used by inline assembler
+ d_bool duplicated; // set if multiply defined, to avoid duplicate error messages
static LabelDsymbol *create(Identifier *ident);
LabelDsymbol *isLabel() override;
diff --git a/gcc/d/dmd/statementsem.d b/gcc/d/dmd/statementsem.d
index 2def253..178cef5 100644
--- a/gcc/d/dmd/statementsem.d
+++ b/gcc/d/dmd/statementsem.d
@@ -21,7 +21,6 @@ import dmd.arrayop;
import dmd.arraytypes;
import dmd.astcodegen;
import dmd.astenums;
-import dmd.ast_node;
import dmd.attrib;
import dmd.blockexit;
import dmd.clone;
@@ -39,7 +38,6 @@ import dmd.dsymbol;
import dmd.dsymbolsem;
import dmd.dtemplate;
import dmd.errors;
-import dmd.errorsink;
import dmd.escape;
import dmd.expression;
import dmd.expressionsem;
@@ -57,7 +55,6 @@ import dmd.mustuse;
import dmd.nogc;
import dmd.opover;
import dmd.parse;
-import dmd.printast;
import dmd.common.outbuffer;
import dmd.root.string;
import dmd.semantic2;
@@ -68,7 +65,6 @@ import dmd.target;
import dmd.tokens;
import dmd.typesem;
import dmd.visitor;
-import dmd.compiler;
version (DMDLIB)
{
@@ -109,7 +105,7 @@ private Identifier fixupLabelName(Scope* sc, Identifier ident)
* Returns:
* if `true`, then the `LabelStatement`, otherwise `null`
*/
-private LabelStatement checkLabeledLoop(Scope* sc, Statement statement)
+private LabelStatement checkLabeledLoop(Scope* sc, Statement statement) @safe
{
if (sc.slabel && sc.slabel.statement == statement)
{
@@ -142,6 +138,8 @@ private Expression checkAssignmentAsCondition(Expression e, Scope* sc)
// Performs semantic analysis in Statement AST nodes
extern(C++) Statement statementSemantic(Statement s, Scope* sc)
{
+ import dmd.compiler;
+
version (CallbackAPI)
Compiler.onStatementSemanticStart(s, sc);
@@ -2758,6 +2756,12 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
{
if (e0)
rs.error("expected return type of `%s`, not `%s`", tret.toChars(), resType.toChars());
+ else if (tbret.isTypeNoreturn())
+ {
+ rs.error("cannot return from `noreturn` function");
+ .errorSupplemental(rs.loc,
+ "Consider adding an endless loop, `assert(0)`, or another `noreturn` expression");
+ }
else
rs.error("`return` expression expected");
}
@@ -3547,9 +3551,19 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
ls.inCtfeBlock = (sc.flags & SCOPE.ctfeBlock) != 0;
LabelDsymbol ls2 = fd.searchLabel(ls.ident, ls.loc);
- if (ls2.statement)
+ if (ls2.statement && !ls2.duplicated)
{
- ls.error("label `%s` already defined", ls2.toChars());
+ if (ls.loc == ls2.loc)
+ {
+ ls2.duplicated = true;
+ ls.error("label `%s` is duplicated", ls2.toChars());
+ .errorSupplemental(ls2.loc, "labels cannot be used in a static foreach with more than 1 iteration");
+ }
+ else
+ {
+ ls.error("label `%s` is already defined", ls2.toChars());
+ .errorSupplemental(ls2.loc, "first definition is here");
+ }
return setError();
}
else
@@ -4068,8 +4082,8 @@ void catchSemantic(Catch c, Scope* sc)
}
else if (!c.type.isNaked() && !c.type.isConst())
{
- // @@@DEPRECATED_2.113@@@
- // Deprecated in 2.103, change into an error & uncomment in 2.113
+ // @@@DEPRECATED_2.115@@@
+ // Deprecated in 2.105, change into an error & uncomment assign in 2.115
deprecation(c.loc, "can only catch mutable or const qualified types, not `%s`", c.type.toChars());
//c.errors = true;
}
diff --git a/gcc/d/dmd/target.d b/gcc/d/dmd/target.d
index 81ff84f..aba3319 100644
--- a/gcc/d/dmd/target.d
+++ b/gcc/d/dmd/target.d
@@ -159,7 +159,7 @@ extern (C++) struct Target
* This can be used to restore the state set by `_init` to its original
* state.
*/
- void deinitialize()
+ void deinitialize() @safe
{
this = this.init;
}
@@ -203,7 +203,7 @@ extern (C++) struct Target
* 2 vector element type is not supported
* 3 vector size is not supported
*/
- extern (C++) int isVectorTypeSupported(int sz, Type type);
+ extern (C++) int isVectorTypeSupported(int sz, Type type) @safe;
/**
* Checks whether the target supports the given operation for vectors.
@@ -221,7 +221,7 @@ extern (C++) struct Target
* Returns:
* `LINK` to use for `extern(System)`
*/
- extern (C++) LINK systemLinkage();
+ extern (C++) LINK systemLinkage() @safe;
/**
* Describes how an argument type is passed to a function on target.
@@ -270,7 +270,7 @@ extern (C++) struct Target
* tf = type of function being called
* Returns: `true` if the callee invokes destructors for arguments.
*/
- extern (C++) bool isCalleeDestroyingArgs(TypeFunction tf);
+ extern (C++) bool isCalleeDestroyingArgs(TypeFunction tf) @safe;
/**
* Returns true if the implementation for object monitors is always defined
@@ -288,7 +288,7 @@ extern (C++) struct Target
* Returns:
* `false` if the target does not support `pragma(linkerDirective)`.
*/
- extern (C++) bool supportsLinkerDirective() const;
+ extern (C++) bool supportsLinkerDirective() const @safe;
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/gcc/d/dmd/templateparamsem.d b/gcc/d/dmd/templateparamsem.d
index 1a9d252..6b8f949 100644
--- a/gcc/d/dmd/templateparamsem.d
+++ b/gcc/d/dmd/templateparamsem.d
@@ -50,7 +50,7 @@ private extern (C++) final class TemplateParameterSemanticVisitor : Visitor
TemplateParameters* parameters;
bool result;
- this(Scope* sc, TemplateParameters* parameters) scope
+ this(Scope* sc, TemplateParameters* parameters) scope @safe
{
this.sc = sc;
this.parameters = parameters;
diff --git a/gcc/d/dmd/tokens.d b/gcc/d/dmd/tokens.d
index 5871762..950c830 100644
--- a/gcc/d/dmd/tokens.d
+++ b/gcc/d/dmd/tokens.d
@@ -898,7 +898,7 @@ extern (C++) struct Token
nothrow:
- int isKeyword() const
+ int isKeyword() const @safe
{
foreach (kw; keywords)
{
diff --git a/gcc/d/dmd/typesem.d b/gcc/d/dmd/typesem.d
index d092395..a80aa80 100644
--- a/gcc/d/dmd/typesem.d
+++ b/gcc/d/dmd/typesem.d
@@ -530,12 +530,10 @@ extern(C++) Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
}
RootObject o = (*tup.objects)[cast(size_t)d];
- if (o.dyncast() != DYNCAST.type)
- {
- .error(loc, "`%s` is not a type", mtype.toChars());
- return error();
- }
- return (cast(Type)o).addMod(mtype.mod);
+ if (auto tt = o.isType())
+ return tt.addMod(mtype.mod);
+ .error(loc, "`%s` is not a type", mtype.toChars());
+ return error();
}
if (t && t.ty == Terror)
@@ -2006,7 +2004,7 @@ extern (C++) Type merge(Type type)
OutBuffer buf;
buf.reserve(32);
- mangleToBuffer(type, &buf);
+ mangleToBuffer(type, buf);
auto sv = type.stringtable.update(buf[]);
if (sv.value)
@@ -5015,7 +5013,10 @@ RootObject compileTypeMixin(TypeMixin tm, ref const Loc loc, Scope* sc)
}
if (p.token.value != TOK.endOfFile)
{
- .error(loc, "incomplete mixin type `%s`", str.ptr);
+ .error(loc, "unexpected token `%s` after type `%s`",
+ p.token.toChars(), o.toChars());
+ .errorSupplemental(loc, "while parsing string mixin type `%s`",
+ str.ptr);
return null;
}
diff --git a/gcc/d/dmd/visitor.d b/gcc/d/dmd/visitor.d
index 7b059a0..591d3c0 100644
--- a/gcc/d/dmd/visitor.d
+++ b/gcc/d/dmd/visitor.d
@@ -255,7 +255,7 @@ extern (C++) class StoppableVisitor : Visitor
public:
bool stop;
- final extern (D) this() scope
+ final extern (D) this() scope @safe
{
}
}
diff --git a/gcc/d/intrinsics.cc b/gcc/d/intrinsics.cc
index aaf04e5..583d5a9 100644
--- a/gcc/d/intrinsics.cc
+++ b/gcc/d/intrinsics.cc
@@ -123,7 +123,7 @@ maybe_set_intrinsic (FuncDeclaration *decl)
return;
OutBuffer buf;
- mangleToBuffer (fd->type, &buf);
+ mangleToBuffer (fd->type, buf);
tdeco = buf.extractChars ();
}
diff --git a/gcc/testsuite/gdc.test/compilable/test23145.d b/gcc/testsuite/gdc.test/compilable/test23145.d
index 45235dc..18eabfb 100644
--- a/gcc/testsuite/gdc.test/compilable/test23145.d
+++ b/gcc/testsuite/gdc.test/compilable/test23145.d
@@ -1,8 +1,9 @@
-/* TEST_OUTPUT:
+/* REQUIRED_ARGS: -wo -wi
+TEST_OUTPUT:
---
-compilable/test23145.d(117): Deprecation: `scope` allocation of `c` requires that constructor be annotated with `scope`
+compilable/test23145.d(117): Warning: `scope` allocation of `c` requires that constructor be annotated with `scope`
compilable/test23145.d(111): is the location of the constructor
-compilable/test23145.d(124): Deprecation: `scope` allocation of `c` requires that constructor be annotated with `scope`
+compilable/test23145.d(124): Warning: `scope` allocation of `c` requires that constructor be annotated with `scope`
compilable/test23145.d(111): is the location of the constructor
---
*/
@@ -24,7 +25,7 @@ class C
this(D d) @safe @nogc;
}
-C foo(D d)@nogc @safe
+C foo(D d) @nogc @safe
{
scope e = new C(1); // ok
scope c = new C(d); // deprecation
@@ -37,3 +38,8 @@ C bax(D d) @safe
scope c = new C(d); // deprecation
return c.d.c;
}
+
+void inferred(D d)
+{
+ scope c = new C(d); // ok
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/biterrors3.d b/gcc/testsuite/gdc.test/fail_compilation/biterrors3.d
index c5031a4..09d7be6 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/biterrors3.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/biterrors3.d
@@ -3,8 +3,8 @@
---
fail_compilation/biterrors3.d(103): Error: storage class not allowed for bit-field declaration
fail_compilation/biterrors3.d(106): Error: expected `,` or `=` after identifier, not `:`
-fail_compilation/biterrors3.d(106): Error: `:` is not a valid attribute for enum members
-fail_compilation/biterrors3.d(106): Error: `3` is not a valid attribute for enum members
+fail_compilation/biterrors3.d(106): Error: found `:` when expecting `,`
+fail_compilation/biterrors3.d(106): Error: found `3` when expecting `identifier`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/bug8891.d b/gcc/testsuite/gdc.test/fail_compilation/bug8891.d
index e7316c3..7b927f9 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/bug8891.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/bug8891.d
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
-fail_compilation/bug8891.d(21): Error: need `this` for `opCall` of type `S(int n)`
+fail_compilation/bug8891.d(21): Error: calling non-static function `opCall` requires an instance of type `S`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/deprecatedinref.d b/gcc/testsuite/gdc.test/fail_compilation/deprecatedinref.d
deleted file mode 100644
index 20c3666..0000000
--- a/gcc/testsuite/gdc.test/fail_compilation/deprecatedinref.d
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
-REQUIRED_ARGS: -de
-TEST_OUTPUT:
----
-fail_compilation/deprecatedinref.d(9): Deprecation: using `in ref` is deprecated, use `-preview=in` and `in` instead
-fail_compilation/deprecatedinref.d(10): Deprecation: using `ref in` is deprecated, use `-preview=in` and `in` instead
----
-*/
-void foo(in ref int);
-void foor(ref in int);
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag15209.d b/gcc/testsuite/gdc.test/fail_compilation/diag15209.d
index 9a4f396..bd6d723 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/diag15209.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/diag15209.d
@@ -1,8 +1,8 @@
/*
TEST_OUTPUT:
---
-fail_compilation/diag15209.d(18): Error: need `this` for `x` of type `int`
-fail_compilation/diag15209.d(21): Error: need `this` for `x` of type `int`
+fail_compilation/diag15209.d(18): Error: accessing non-static variable `x` requires an instance of `C1`
+fail_compilation/diag15209.d(21): Error: accessing non-static variable `x` requires an instance of `S2`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag9451.d b/gcc/testsuite/gdc.test/fail_compilation/diag9451.d
index ffec627..980c689 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/diag9451.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/diag9451.d
@@ -1,11 +1,12 @@
/*
TEST_OUTPUT:
---
-fail_compilation/diag9451.d(26): Error: cannot create instance of abstract class `C2`
-fail_compilation/diag9451.d(26): function `void f1()` is not implemented
-fail_compilation/diag9451.d(26): function `void f2(int)` is not implemented
-fail_compilation/diag9451.d(26): function `void f2(float) const` is not implemented
-fail_compilation/diag9451.d(26): function `int f2(float) pure` is not implemented
+fail_compilation/diag9451.d(27): Error: cannot create instance of abstract class `C2`
+fail_compilation/diag9451.d(21): class `C2` is declared here
+fail_compilation/diag9451.d(15): function `void f1()` is not implemented
+fail_compilation/diag9451.d(16): function `void f2(int)` is not implemented
+fail_compilation/diag9451.d(17): function `void f2(float) const` is not implemented
+fail_compilation/diag9451.d(18): function `int f2(float) pure` is not implemented
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/diag9635.d b/gcc/testsuite/gdc.test/fail_compilation/diag9635.d
index fe142ad..9794c8f 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/diag9635.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/diag9635.d
@@ -2,8 +2,8 @@
/*
TEST_OUTPUT:
---
-fail_compilation/diag9635.d(17): Error: need `this` for `i` of type `int`
-fail_compilation/diag9635.d(18): Error: need `this` for `foo` of type `pure nothrow @nogc @safe void()`
+fail_compilation/diag9635.d(17): Error: accessing non-static variable `i` requires an instance of `Foo`
+fail_compilation/diag9635.d(18): Error: calling non-static function `foo` requires an instance of type `Foo`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/dip1000_deprecation.d b/gcc/testsuite/gdc.test/fail_compilation/dip1000_deprecation.d
index 6117439..e591a14 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/dip1000_deprecation.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/dip1000_deprecation.d
@@ -1,5 +1,5 @@
/*
-REQUIRED_ARGS: -de
+REQUIRED_ARGS: -de -wo
TEST_OUTPUT:
---
fail_compilation/dip1000_deprecation.d(20): Deprecation: `@safe` function `main` calling `inferred`
@@ -9,17 +9,17 @@ fail_compilation/dip1000_deprecation.d(22): Deprecation: `@safe` function `main`
fail_compilation/dip1000_deprecation.d(39): which calls `dip1000_deprecation.inferred`
fail_compilation/dip1000_deprecation.d(28): which wouldn't be `@safe` because of:
fail_compilation/dip1000_deprecation.d(28): scope variable `x0` may not be returned
-fail_compilation/dip1000_deprecation.d(54): Deprecation: escaping reference to stack allocated value returned by `S(null)`
-fail_compilation/dip1000_deprecation.d(55): Deprecation: escaping reference to stack allocated value returned by `createS()`
-fail_compilation/dip1000_deprecation.d(58): Deprecation: returning `s.incorrectReturnRef()` escapes a reference to local variable `s`
+fail_compilation/dip1000_deprecation.d(54): Warning: escaping reference to stack allocated value returned by `S(null)`
+fail_compilation/dip1000_deprecation.d(55): Warning: escaping reference to stack allocated value returned by `createS()`
+fail_compilation/dip1000_deprecation.d(58): Warning: returning `s.incorrectReturnRef()` escapes a reference to local variable `s`
---
*/
void main() @safe
{
- inferred();
- inferredB(); // no deprecation, trusted
- inferredC(); // nested deprecation
+ cast(void)inferred();
+ cast(void)inferredB(); // no deprecation, trusted
+ cast(void)inferredC(); // nested deprecation
}
auto inferred()
@@ -49,10 +49,10 @@ struct S
S createS() { return S.init; }
-int* escape()
+int* escape(int i)
{
- return S().incorrectReturnRef();
- return createS().incorrectReturnRef();
+ if (i) return S().incorrectReturnRef();
+ if (i) return createS().incorrectReturnRef();
S s;
return s.incorrectReturnRef();
diff --git a/gcc/testsuite/gdc.test/fail_compilation/e15876_6.d b/gcc/testsuite/gdc.test/fail_compilation/e15876_6.d
index 7547b38..6b060fd 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/e15876_6.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/e15876_6.d
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
-fail_compilation/e15876_6.d(7): Error: identifier expected following `(type)`.
+fail_compilation/e15876_6.d(7): Error: identifier expected following `immutable(int).`, not `;`
---
*/
auto unaryExParseError = immutable(int).;
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail10285.d b/gcc/testsuite/gdc.test/fail_compilation/fail10285.d
index c88e306..1087125 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail10285.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail10285.d
@@ -1,11 +1,14 @@
/*
TEST_OUTPUT:
---
-fail_compilation/fail10285.d(13): Error: no identifier for declarator `int`
-fail_compilation/fail10285.d(14): Error: expected `,` or `=` after identifier, not `y`
-fail_compilation/fail10285.d(15): Error: expected identifier after type, not `bool`
-fail_compilation/fail10285.d(16): Error: expected identifier after type, not `int`
-fail_compilation/fail10285.d(18): Error: initializer required after `z` when type is specified
+fail_compilation/fail10285.d(16): Error: no identifier for declarator `int`
+fail_compilation/fail10285.d(17): Error: expected `,` or `=` after identifier, not `y`
+fail_compilation/fail10285.d(17): Error: initializer required after `x` when type is specified
+fail_compilation/fail10285.d(18): Error: no identifier for declarator `int`
+fail_compilation/fail10285.d(18): Error: found `bool` when expecting `,`
+fail_compilation/fail10285.d(19): Error: no identifier for declarator `j`
+fail_compilation/fail10285.d(19): Error: found `int` when expecting `,`
+fail_compilation/fail10285.d(21): Error: initializer required after `z` when type is specified
---
*/
enum
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail11545.d b/gcc/testsuite/gdc.test/fail_compilation/fail11545.d
index a576817..01d8e93 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail11545.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail11545.d
@@ -1,8 +1,8 @@
/*
TEST_OUTPUT:
---
-fail_compilation/fail11545.d(14): Error: need `this` for `x` of type `int`
-fail_compilation/fail11545.d(18): Error: need `this` for `x` of type `int`
+fail_compilation/fail11545.d(14): Error: accessing non-static variable `x` requires an instance of `C`
+fail_compilation/fail11545.d(18): Error: accessing non-static variable `x` requires an instance of `C`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail120.d b/gcc/testsuite/gdc.test/fail_compilation/fail120.d
index c9d67a4..f9ede04 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail120.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail120.d
@@ -1,8 +1,8 @@
/*
TEST_OUTPUT:
---
-fail_compilation/fail120.d(12): Error: need `this` for `nodes` of type `int[2]`
-fail_compilation/fail120.d(13): Error: need `this` for `nodes` of type `int[2]`
+fail_compilation/fail120.d(12): Error: accessing non-static variable `nodes` requires an instance of `Foo`
+fail_compilation/fail120.d(13): Error: accessing non-static variable `nodes` requires an instance of `Foo`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail142.d b/gcc/testsuite/gdc.test/fail_compilation/fail142.d
index 343b2e3..c31a317 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail142.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail142.d
@@ -1,8 +1,9 @@
/*
TEST_OUTPUT:
---
-fail_compilation/fail142.d(20): Error: cannot create instance of abstract class `B`
-fail_compilation/fail142.d(20): function `void test()` is not implemented
+fail_compilation/fail142.d(21): Error: cannot create instance of abstract class `B`
+fail_compilation/fail142.d(15): class `B` is declared here
+fail_compilation/fail142.d(12): function `void test()` is not implemented
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail143.d b/gcc/testsuite/gdc.test/fail_compilation/fail143.d
index 6df232f..e5ccb0f 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail143.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail143.d
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
-fail_compilation/fail143.d(23): Error: need `this` for `next` of type `uint()`
+fail_compilation/fail143.d(23): Error: calling non-static function `next` requires an instance of type `Quux`
fail_compilation/fail143.d(30): Error: template instance `fail143.Foo!int` error instantiating
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail144.d b/gcc/testsuite/gdc.test/fail_compilation/fail144.d
index 6e73d3b..4977e4d 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail144.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail144.d
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
-fail_compilation/fail144.d(13): Error: `"message"`
+fail_compilation/fail144.d(13): Error: message
fail_compilation/fail144.d(26): called from here: `bar(7)`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail145.d b/gcc/testsuite/gdc.test/fail_compilation/fail145.d
index 5a7a4ca..1e90237 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail145.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail145.d
@@ -2,7 +2,7 @@
REQUIRED_ARGS: -checkaction=context
TEST_OUTPUT:
---
-fail_compilation/fail145.d(14): Error: `"assert(i && (i < 0)) failed"`
+fail_compilation/fail145.d(14): Error: `assert(i && (i < 0))` failed
fail_compilation/fail145.d(27): called from here: `bar(7)`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail17955.d b/gcc/testsuite/gdc.test/fail_compilation/fail17955.d
index 0832919..43ce5cc 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail17955.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail17955.d
@@ -2,19 +2,20 @@
/*
TEST_OUTPUT:
---
-fail_compilation/fail17955.d(81): Error: cannot create instance of abstract class `SimpleTimeZone`
-fail_compilation/fail17955.d(81): function `bool hasDST()` is not implemented
-fail_compilation/fail17955.d(93): Error: template instance `fail17955.SimpleTimeZone.fromISOExtString!dstring` error instantiating
-fail_compilation/fail17955.d(25): instantiated from here: `fromISOExtString!string`
-fail_compilation/fail17955.d(56): instantiated from here: `isISOExtStringSerializable!(SysTime)`
-fail_compilation/fail17955.d(49): instantiated from here: `toRedis!(SysTime)`
-fail_compilation/fail17955.d(40): ... (2 instantiations, -v to show) ...
-fail_compilation/fail17955.d(32): instantiated from here: `indicesOf!(isRedisType, resetCodeExpireTime)`
-fail_compilation/fail17955.d(67): instantiated from here: `RedisStripped!(User, true)`
-fail_compilation/fail17955.d(93): Error: need `this` for `fromISOExtString` of type `pure nothrow @nogc @safe immutable(SimpleTimeZone)(dstring __param_0)`
-fail_compilation/fail17955.d(95): Error: undefined identifier `DateTimeException`
-fail_compilation/fail17955.d(25): Error: variable `fail17955.isISOExtStringSerializable!(SysTime).isISOExtStringSerializable` - type `void` is inferred from initializer `fromISOExtString("")`, and variables cannot be of type `void`
-fail_compilation/fail17955.d(54): Error: function `fail17955.toRedis!(SysTime).toRedis` has no `return` statement, but is expected to return a value of type `string`
+fail_compilation/fail17955.d(82): Error: cannot create instance of abstract class `SimpleTimeZone`
+fail_compilation/fail17955.d(76): class `SimpleTimeZone` is declared here
+fail_compilation/fail17955.d(73): function `bool hasDST()` is not implemented
+fail_compilation/fail17955.d(94): Error: template instance `fail17955.SimpleTimeZone.fromISOExtString!dstring` error instantiating
+fail_compilation/fail17955.d(26): instantiated from here: `fromISOExtString!string`
+fail_compilation/fail17955.d(57): instantiated from here: `isISOExtStringSerializable!(SysTime)`
+fail_compilation/fail17955.d(50): instantiated from here: `toRedis!(SysTime)`
+fail_compilation/fail17955.d(41): ... (2 instantiations, -v to show) ...
+fail_compilation/fail17955.d(33): instantiated from here: `indicesOf!(isRedisType, resetCodeExpireTime)`
+fail_compilation/fail17955.d(68): instantiated from here: `RedisStripped!(User, true)`
+fail_compilation/fail17955.d(94): Error: calling non-static function `fromISOExtString` requires an instance of type `SimpleTimeZone`
+fail_compilation/fail17955.d(96): Error: undefined identifier `DateTimeException`
+fail_compilation/fail17955.d(26): Error: variable `fail17955.isISOExtStringSerializable!(SysTime).isISOExtStringSerializable` - type `void` is inferred from initializer `fromISOExtString("")`, and variables cannot be of type `void`
+fail_compilation/fail17955.d(55): Error: function `fail17955.toRedis!(SysTime).toRedis` has no `return` statement, but is expected to return a value of type `string`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail20538.d b/gcc/testsuite/gdc.test/fail_compilation/fail20538.d
index df7f142e..e07af6c 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail20538.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail20538.d
@@ -1,8 +1,9 @@
/*
TEST_OUTPUT:
---
-fail_compilation/fail20538.d(12): Error: assignment must be preceded by an identifier
-fail_compilation/fail20538.d(12): Error: found `1` when expecting `,`
+fail_compilation/fail20538.d(13): Error: found `=` when expecting `identifier`
+fail_compilation/fail20538.d(13): Error: found `1` when expecting `identifier`
+fail_compilation/fail20538.d(14): Error: named enum cannot declare member with type
---
*/
@@ -10,5 +11,6 @@ enum smth
{
a,
= 1,
+ int x = 1,
@disable b
}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail25.d b/gcc/testsuite/gdc.test/fail_compilation/fail25.d
index 11c0f0b..abb795e 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail25.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail25.d
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
-fail_compilation/fail25.d(14): Error: need `this` for `yuiop` of type `int`
+fail_compilation/fail25.d(14): Error: accessing non-static variable `yuiop` requires an instance of `Qwert`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail301.d b/gcc/testsuite/gdc.test/fail_compilation/fail301.d
index bf90f55..f527819 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail301.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail301.d
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
-fail_compilation/fail301.d(11): Error: need `this` for `guard` of type `int`
+fail_compilation/fail301.d(11): Error: accessing non-static variable `guard` requires an instance of `bug3305b`
fail_compilation/fail301.d(22): Error: template instance `fail301.bug3305!0` error instantiating
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail46.d b/gcc/testsuite/gdc.test/fail_compilation/fail46.d
index 9401b92..9d97ba1 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail46.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail46.d
@@ -2,7 +2,7 @@
/*
TEST_OUTPUT:
---
-fail_compilation/fail46.d(19): Error: need `this` for `bug` of type `int()`
+fail_compilation/fail46.d(19): Error: calling non-static function `bug` requires an instance of type `MyStruct`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail4923.d b/gcc/testsuite/gdc.test/fail_compilation/fail4923.d
index 3239cff..836b14a 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail4923.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail4923.d
@@ -1,13 +1,17 @@
/*
TEST_OUTPUT:
---
-fail_compilation/fail4923.d(4): Error: immutable variable `bar` initialization is not allowed in `static this`
-fail_compilation/fail4923.d(4): Use `shared static this` instead.
+fail_compilation/fail4923.d(5): Error: immutable variable `bar` initialization is not allowed in `static this`
+fail_compilation/fail4923.d(5): Use `shared static this` instead.
+fail_compilation/fail4923.d(6): Deprecation: const variable `baz` initialization is not allowed in `static this`
+fail_compilation/fail4923.d(6): Use `shared static this` instead.
---
*/
#line 1
immutable int bar;
+const int baz; // https://issues.dlang.org/show_bug.cgi?id=24056
static this()
{
bar = 42;
+ baz = 43;
}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail50.d b/gcc/testsuite/gdc.test/fail_compilation/fail50.d
index 36bf382..c6aa178 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail50.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail50.d
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
-fail_compilation/fail50.d(12): Error: need `this` for address of `a`
+fail_compilation/fail50.d(12): Error: taking the address of non-static variable `a` requires an instance of `Marko`
fail_compilation/fail50.d(12): Error: variable `a` cannot be read at compile time
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail61.d b/gcc/testsuite/gdc.test/fail_compilation/fail61.d
index 1386bd6..a2f01d7 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail61.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail61.d
@@ -4,7 +4,7 @@ TEST_OUTPUT:
fail_compilation/fail61.d(22): Error: no property `B` for type `fail61.A.B`
fail_compilation/fail61.d(23): Error: no property `B` for type `fail61.A.B`
fail_compilation/fail61.d(32): Error: no property `A2` for type `fail61.B2`
-fail_compilation/fail61.d(41): Error: need `this` for `foo` of type `void()`
+fail_compilation/fail61.d(41): Error: calling non-static function `foo` requires an instance of type `B3`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail66.d b/gcc/testsuite/gdc.test/fail_compilation/fail66.d
index 5820ca5..825074e 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail66.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail66.d
@@ -53,7 +53,7 @@ fail_compilation/fail66.d(59): Error: cannot modify `const` expression `x`
class C4
{
static const int x;
- static this() { x = 5; }
+ shared static this() { x = 5; }
void foo()
{
x = 4;
@@ -67,7 +67,7 @@ fail_compilation/fail66.d(73): Error: cannot modify `const` expression `z5`
---
*/
const int z5;
-static this() { z5 = 3; }
+shared static this() { z5 = 3; }
void test5()
{
z5 = 4;
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail7851.d b/gcc/testsuite/gdc.test/fail_compilation/fail7851.d
index 399192d..acc49f1 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail7851.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail7851.d
@@ -2,9 +2,9 @@
/*
TEST_OUTPUT:
---
-fail_compilation/fail7851.d(38): Error: need `this` for `__mem_field_0` of type `int`
-fail_compilation/fail7851.d(38): Error: need `this` for `__mem_field_1` of type `long`
-fail_compilation/fail7851.d(38): Error: need `this` for `__mem_field_2` of type `float`
+fail_compilation/fail7851.d(38): Error: accessing non-static variable `__mem_field_0` requires an instance of `Tuple`
+fail_compilation/fail7851.d(38): Error: accessing non-static variable `__mem_field_1` requires an instance of `Tuple`
+fail_compilation/fail7851.d(38): Error: accessing non-static variable `__mem_field_2` requires an instance of `Tuple`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail9613.d b/gcc/testsuite/gdc.test/fail_compilation/fail9613.d
index 31ca808..d88cd2f 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail9613.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail9613.d
@@ -2,7 +2,7 @@
/*
TEST_OUTPUT:
---
-fail_compilation/fail9613.d(12): Error: `(arguments)` expected following `const(byte)`
+fail_compilation/fail9613.d(12): Error: `(arguments)` expected following `const(byte)`, not `.`
fail_compilation/fail9613.d(12): Error: semicolon expected following auto declaration, not `.`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail_scope.d b/gcc/testsuite/gdc.test/fail_compilation/fail_scope.d
index f209592..8508b27 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail_scope.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail_scope.d
@@ -1,5 +1,5 @@
/*
-REQUIRED_ARGS:
+REQUIRED_ARGS: -wo
TEST_OUTPUT:
---
fail_compilation/fail_scope.d(30): Deprecation: scope parameter `da` may not be returned
@@ -16,7 +16,7 @@ fail_compilation/fail_scope.d(82): Error: returning `& string` escapes a referen
fail_compilation/fail_scope.d(92): Error: returning `cast(int[])a` escapes a reference to local variable `a`
fail_compilation/fail_scope.d(100): Error: returning `cast(int[])a` escapes a reference to local variable `a`
fail_compilation/fail_scope.d(108): Error: escaping reference to outer local variable `x`
-fail_compilation/fail_scope.d(127): Deprecation: returning `s.bar()` escapes a reference to local variable `s`
+fail_compilation/fail_scope.d(127): Warning: returning `s.bar()` escapes a reference to local variable `s`
fail_compilation/fail_scope.d(137): Error: returning `foo16226(i)` escapes a reference to local variable `i`
---
//fail_compilation/fail_scope.d(35): Error: scope variable `da` may not be returned
diff --git a/gcc/testsuite/gdc.test/fail_compilation/failcontracts.d b/gcc/testsuite/gdc.test/fail_compilation/failcontracts.d
index 9ba2970..51275d0 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/failcontracts.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/failcontracts.d
@@ -1,15 +1,14 @@
/* TEST_OUTPUT:
---
-fail_compilation/failcontracts.d(18): Error: missing `{ ... }` for function literal
-fail_compilation/failcontracts.d(18): Error: semicolon expected following auto declaration, not `bode`
-fail_compilation/failcontracts.d(19): Error: function declaration without return type. (Note that constructors are always named `this`)
-fail_compilation/failcontracts.d(19): Error: no identifier for declarator `test1()`
+fail_compilation/failcontracts.d(17): Error: missing `{ ... }` for function literal
+fail_compilation/failcontracts.d(17): Error: semicolon expected following auto declaration, not `bode`
+fail_compilation/failcontracts.d(18): Error: function declaration without return type. (Note that constructors are always named `this`)
+fail_compilation/failcontracts.d(18): Error: no identifier for declarator `test1()`
+fail_compilation/failcontracts.d(18): Error: semicolon expected following function declaration, not `bode`
fail_compilation/failcontracts.d(19): Error: semicolon expected following function declaration, not `bode`
-fail_compilation/failcontracts.d(20): Error: semicolon expected following function declaration, not `bode`
-fail_compilation/failcontracts.d(22): Error: unexpected `(` in declarator
-fail_compilation/failcontracts.d(22): Error: found `T` when expecting `)`
-fail_compilation/failcontracts.d(22): Error: enum declaration is invalid
-fail_compilation/failcontracts.d(22): Error: found `)` instead of statement
+fail_compilation/failcontracts.d(21): Error: unexpected `(` in declarator
+fail_compilation/failcontracts.d(21): Error: found `T` when expecting `)`
+fail_compilation/failcontracts.d(21): Error: expected `{`, not `;` for enum declaration
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice15332.d b/gcc/testsuite/gdc.test/fail_compilation/ice15332.d
index dbedc73..6789583 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/ice15332.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/ice15332.d
@@ -1,8 +1,8 @@
/*
TEST_OUTPUT:
---
-fail_compilation/ice15332.d(16): Error: need `this` for `fun` of type `int()`
-fail_compilation/ice15332.d(17): Error: need `this` for `var` of type `int`
+fail_compilation/ice15332.d(16): Error: calling non-static function `fun` requires an instance of type `C`
+fail_compilation/ice15332.d(17): Error: accessing non-static variable `var` requires an instance of `C`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice15922.d b/gcc/testsuite/gdc.test/fail_compilation/ice15922.d
index d98404c..624124b 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/ice15922.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/ice15922.d
@@ -4,7 +4,7 @@ TEST_OUTPUT:
fail_compilation/ice15922.d(23): Error: function `ice15922.ValidSparseDataStore!int.ValidSparseDataStore.correctedInsert!false.correctedInsert` has no `return` statement, but is expected to return a value of type `int`
fail_compilation/ice15922.d(21): Error: template instance `ice15922.ValidSparseDataStore!int.ValidSparseDataStore.correctedInsert!false` error instantiating
fail_compilation/ice15922.d(26): instantiated from here: `ValidSparseDataStore!int`
-fail_compilation/ice15922.d(14): Error: need `this` for `insert` of type `pure nothrow @nogc @safe int()`
+fail_compilation/ice15922.d(14): Error: calling non-static function `insert` requires an instance of type `ValidSparseDataStore`
fail_compilation/ice15922.d(26): Error: template instance `ice15922.StorageAttributes!(ValidSparseDataStore!int)` error instantiating
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice20056.d b/gcc/testsuite/gdc.test/fail_compilation/ice20056.d
index 1b991ca..519ada1 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/ice20056.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/ice20056.d
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
-fail_compilation/ice20056.d(19): Error: need `this` for `iter` of type `void()`
+fail_compilation/ice20056.d(19): Error: calling non-static function `iter` requires an instance of type `RangeWrapper`
---
*/
struct Def(alias fn)
diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice7645.d b/gcc/testsuite/gdc.test/fail_compilation/ice7645.d
index 379ac67..3fd332c 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/ice7645.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/ice7645.d
@@ -1,8 +1,8 @@
/*
TEST_OUTPUT:
---
-fail_compilation/ice7645.d(28): Error: need `this` for `t` of type `char`
-fail_compilation/ice7645.d(31): Error: need `this` for `fn` of type `pure nothrow @nogc @safe void()`
+fail_compilation/ice7645.d(28): Error: accessing non-static variable `t` requires an instance of `C2`
+fail_compilation/ice7645.d(31): Error: calling non-static function `fn` requires an instance of type `S2`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice9439.d b/gcc/testsuite/gdc.test/fail_compilation/ice9439.d
index 5b2a8b1..9f08e40 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/ice9439.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/ice9439.d
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
-fail_compilation/ice9439.d(12): Error: need `this` for `foo` of type `int()`
+fail_compilation/ice9439.d(12): Error: calling non-static function `foo` requires an instance of type `Derived`
fail_compilation/ice9439.d(12): while evaluating: `static assert(foo())`
fail_compilation/ice9439.d(19): Error: template instance `ice9439.Base.boo!(foo)` error instantiating
---
diff --git a/gcc/testsuite/gdc.test/fail_compilation/misc_parser_err_cov1.d b/gcc/testsuite/gdc.test/fail_compilation/misc_parser_err_cov1.d
index a719b12..57706b59 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/misc_parser_err_cov1.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/misc_parser_err_cov1.d
@@ -17,7 +17,7 @@ fail_compilation/misc_parser_err_cov1.d(38): Error: template argument expected f
fail_compilation/misc_parser_err_cov1.d(38): Error: missing closing `)` after `if (parseShift!()`
fail_compilation/misc_parser_err_cov1.d(38): Error: found `)` when expecting `(`
fail_compilation/misc_parser_err_cov1.d(39): Error: missing closing `)` after `if (`
-fail_compilation/misc_parser_err_cov1.d(39): Error: identifier expected following `(type)`.
+fail_compilation/misc_parser_err_cov1.d(39): Error: identifier expected following `immutable(int).`, not `+`
fail_compilation/misc_parser_err_cov1.d(39): Error: expression expected, not `;`
fail_compilation/misc_parser_err_cov1.d(40): Error: semicolon expected following auto declaration, not `auto`
fail_compilation/misc_parser_err_cov1.d(40): Error: identifier or `new` expected following `.`, not `+`
diff --git a/gcc/testsuite/gdc.test/fail_compilation/mixintype2.d b/gcc/testsuite/gdc.test/fail_compilation/mixintype2.d
index b18627d..13cc827 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/mixintype2.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/mixintype2.d
@@ -1,8 +1,11 @@
/* TEST_OUTPUT:
---
-fail_compilation/mixintype2.d(10): Error: alias `mixintype2.Foo.T` recursive alias declaration
-fail_compilation/mixintype2.d(16): Error: `mixin(0)` does not give a valid type
+fail_compilation/mixintype2.d(13): Error: alias `mixintype2.Foo.T` recursive alias declaration
+fail_compilation/mixintype2.d(19): Error: `mixin(0)` does not give a valid type
+fail_compilation/mixintype2.d(20): Error: unexpected token `{` after type `int()`
+fail_compilation/mixintype2.d(20): while parsing string mixin type `int() {}`
+fail_compilation/mixintype2.d(20): Error: `mixin(_error_)` does not give a valid type
---
*/
@@ -14,3 +17,4 @@ alias T2 = mixin("T1");
void func (T2 p) {}
enum mixin(0) a = 0;
+mixin("int() {}") f;
diff --git a/gcc/testsuite/gdc.test/fail_compilation/noreturn.d b/gcc/testsuite/gdc.test/fail_compilation/noreturn.d
index d47d449..087b9e7 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/noreturn.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/noreturn.d
@@ -3,18 +3,18 @@ REQUIRED_ARGS: -w -o-
TEST_OUTPUT:
---
-fail_compilation\noreturn.d(38): Error: `"Accessed expression of type `noreturn`"`
+fail_compilation\noreturn.d(38): Error: Accessed expression of type `noreturn`
fail_compilation\noreturn.d(42): called from here: `assign()`
-fail_compilation\noreturn.d(49): Error: `"Accessed expression of type `noreturn`"`
+fail_compilation\noreturn.d(49): Error: Accessed expression of type `noreturn`
fail_compilation\noreturn.d(49): called from here: `foo(n)`
fail_compilation\noreturn.d(53): called from here: `calling()`
-fail_compilation\noreturn.d(59): Error: `"Accessed expression of type `noreturn`"`
+fail_compilation\noreturn.d(59): Error: Accessed expression of type `noreturn`
fail_compilation\noreturn.d(62): called from here: `nested()`
-fail_compilation\noreturn.d(68): Error: `"Accessed expression of type `noreturn`"`
+fail_compilation\noreturn.d(68): Error: Accessed expression of type `noreturn`
fail_compilation\noreturn.d(78): called from here: `casting(0)`
-fail_compilation\noreturn.d(69): Error: `"Accessed expression of type `noreturn`"`
+fail_compilation\noreturn.d(69): Error: Accessed expression of type `noreturn`
fail_compilation\noreturn.d(79): called from here: `casting(1)`
-fail_compilation\noreturn.d(72): Error: `"Accessed expression of type `noreturn`"`
+fail_compilation\noreturn.d(72): Error: Accessed expression of type `noreturn`
fail_compilation\noreturn.d(80): called from here: `casting(2)`
fail_compilation/noreturn.d(120): Error: uncaught CTFE exception `object.Exception("")`
---
@@ -125,7 +125,7 @@ https://issues.dlang.org/show_bug.cgi?id=23063
TEST_OUTPUT:
---
-fail_compilation/noreturn.d(135): Error: `"Accessed expression of type `noreturn`"`
+fail_compilation/noreturn.d(135): Error: Accessed expression of type `noreturn`
fail_compilation/noreturn.d(138): called from here: `func()`
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/noreturn2.d b/gcc/testsuite/gdc.test/fail_compilation/noreturn2.d
index 7bb2fa9..66c1d52 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/noreturn2.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/noreturn2.d
@@ -139,3 +139,16 @@ int throwInvalid(int i) nothrow
UnkownException("")
;
}
+
+/+
+https://issues.dlang.org/show_bug.cgi?id=24054
+TEST_OUTPUT:
+---
+fail_compilation/noreturn2.d(153): Error: cannot return from `noreturn` function
+fail_compilation/noreturn2.d(153): Consider adding an endless loop, `assert(0)`, or another `noreturn` expression
+---
++/
+const(noreturn) f()
+{
+ return;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/systemvariables.d b/gcc/testsuite/gdc.test/fail_compilation/systemvariables.d
index 0079719..796eda6 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/systemvariables.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/systemvariables.d
@@ -2,15 +2,24 @@
REQUIRED_ARGS: -preview=systemVariables
TEST_OUTPUT:
---
-fail_compilation/systemvariables.d(30): Error: cannot access `@system` variable `gInt` in @safe code
-fail_compilation/systemvariables.d(31): Error: cannot access `@system` variable `gInt` in @safe code
-fail_compilation/systemvariables.d(32): Error: cannot access `@system` variable `gArr` in @safe code
-fail_compilation/systemvariables.d(33): Error: cannot access `@system` variable `gArr` in @safe code
-fail_compilation/systemvariables.d(34): Error: cannot access `@system` variable `gInt` in @safe code
-fail_compilation/systemvariables.d(37): Error: cannot access `@system` variable `lSys` in @safe code
-fail_compilation/systemvariables.d(38): Error: cannot access `@system` variable `lSys` in @safe code
-fail_compilation/systemvariables.d(39): Error: cannot access `@system` variable `lSys` in @safe code
-fail_compilation/systemvariables.d(41): Error: cannot access `@system` variable `eInt` in @safe code
+fail_compilation/systemvariables.d(39): Error: cannot access `@system` variable `gInt` in @safe code
+fail_compilation/systemvariables.d(29): `gInt` is declared here
+fail_compilation/systemvariables.d(40): Error: cannot access `@system` variable `gInt` in @safe code
+fail_compilation/systemvariables.d(29): `gInt` is declared here
+fail_compilation/systemvariables.d(41): Error: cannot access `@system` variable `gArr` in @safe code
+fail_compilation/systemvariables.d(31): `gArr` is declared here
+fail_compilation/systemvariables.d(42): Error: cannot access `@system` variable `gArr` in @safe code
+fail_compilation/systemvariables.d(31): `gArr` is declared here
+fail_compilation/systemvariables.d(43): Error: cannot access `@system` variable `gInt` in @safe code
+fail_compilation/systemvariables.d(29): `gInt` is declared here
+fail_compilation/systemvariables.d(46): Error: cannot access `@system` variable `lSys` in @safe code
+fail_compilation/systemvariables.d(45): `lSys` is declared here
+fail_compilation/systemvariables.d(47): Error: cannot access `@system` variable `lSys` in @safe code
+fail_compilation/systemvariables.d(45): `lSys` is declared here
+fail_compilation/systemvariables.d(48): Error: cannot access `@system` variable `lSys` in @safe code
+fail_compilation/systemvariables.d(45): `lSys` is declared here
+fail_compilation/systemvariables.d(50): Error: cannot access `@system` variable `eInt` in @safe code
+fail_compilation/systemvariables.d(30): `eInt` is declared here
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test13536.d b/gcc/testsuite/gdc.test/fail_compilation/test13536.d
index f4e2cac..4a4bb26 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test13536.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test13536.d
@@ -1,8 +1,8 @@
-/*
+/* REQUIRED_ARGS: -wo
TEST_OUTPUT:
---
fail_compilation/test13536.d(23): Error: field `U.sysDg` cannot access pointers in `@safe` code that overlap other fields
-fail_compilation/test13536.d(23): Deprecation: address of variable `s` assigned to `u` with longer lifetime
+fail_compilation/test13536.d(23): Warning: address of variable `s` assigned to `u` with longer lifetime
fail_compilation/test13536.d(24): Error: field `U.safeDg` cannot access pointers in `@safe` code that overlap other fields
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test16365.d b/gcc/testsuite/gdc.test/fail_compilation/test16365.d
index c987969..4d49365 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test16365.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test16365.d
@@ -1,9 +1,9 @@
-/*
+/* REQUIRED_ARGS: -wo
TEST_OUTPUT:
---
fail_compilation/test16365.d(21): Error: `this` reference necessary to take address of member `f1` in `@safe` function `main`
fail_compilation/test16365.d(23): Error: cannot implicitly convert expression `&f2` of type `void delegate() pure nothrow @nogc @safe` to `void function() @safe`
-fail_compilation/test16365.d(27): Deprecation: address of variable `s` assigned to `dg` with longer lifetime
+fail_compilation/test16365.d(27): Warning: address of variable `s` assigned to `dg` with longer lifetime
fail_compilation/test16365.d(28): Error: `dg.funcptr` cannot be used in `@safe` code
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test21008.d b/gcc/testsuite/gdc.test/fail_compilation/test21008.d
index 7d5bb37..9949107 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test21008.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test21008.d
@@ -2,8 +2,8 @@
TEST_OUTPUT:
---
fail_compilation/test21008.d(110): Error: function `test21008.C.after` circular reference to class `C`
-fail_compilation/test21008.d(117): Error: need `this` for `toString` of type `string()`
-fail_compilation/test21008.d(117): Error: need `this` for `toHash` of type `nothrow @trusted $?:32=uint|64=ulong$()`
+fail_compilation/test21008.d(117): Error: calling non-static function `toString` requires an instance of type `Object`
+fail_compilation/test21008.d(117): Error: calling non-static function `toHash` requires an instance of type `Object`
fail_compilation/test21008.d(117): Error: function `object.Object.opCmp(Object o)` is not callable using argument types `()`
fail_compilation/test21008.d(117): too few arguments, expected 1, got 0
fail_compilation/test21008.d(117): Error: function `object.Object.opEquals(Object o)` is not callable using argument types `()`
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test9701.d b/gcc/testsuite/gdc.test/fail_compilation/test9701.d
index a0310c4..67f38fc 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test9701.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test9701.d
@@ -5,27 +5,27 @@ fail_compilation/test9701.d(38): Error: `@safe` is not a valid attribute for enu
fail_compilation/test9701.d(39): Error: `@system` is not a valid attribute for enum members
fail_compilation/test9701.d(40): Error: `@trusted` is not a valid attribute for enum members
fail_compilation/test9701.d(41): Error: `@nogc` is not a valid attribute for enum members
-fail_compilation/test9701.d(42): Error: `pure` is not a valid attribute for enum members
-fail_compilation/test9701.d(43): Error: `shared` is not a valid attribute for enum members
-fail_compilation/test9701.d(44): Error: `inout` is not a valid attribute for enum members
-fail_compilation/test9701.d(45): Error: `immutable` is not a valid attribute for enum members
-fail_compilation/test9701.d(46): Error: `const` is not a valid attribute for enum members
-fail_compilation/test9701.d(47): Error: `synchronized` is not a valid attribute for enum members
-fail_compilation/test9701.d(48): Error: `scope` is not a valid attribute for enum members
-fail_compilation/test9701.d(49): Error: `auto` is not a valid attribute for enum members
-fail_compilation/test9701.d(50): Error: `ref` is not a valid attribute for enum members
-fail_compilation/test9701.d(51): Error: `__gshared` is not a valid attribute for enum members
-fail_compilation/test9701.d(52): Error: `final` is not a valid attribute for enum members
-fail_compilation/test9701.d(53): Error: `extern` is not a valid attribute for enum members
-fail_compilation/test9701.d(54): Error: `export` is not a valid attribute for enum members
-fail_compilation/test9701.d(55): Error: `nothrow` is not a valid attribute for enum members
-fail_compilation/test9701.d(56): Error: `public` is not a valid attribute for enum members
-fail_compilation/test9701.d(57): Error: `private` is not a valid attribute for enum members
-fail_compilation/test9701.d(58): Error: `package` is not a valid attribute for enum members
-fail_compilation/test9701.d(59): Error: `static` is not a valid attribute for enum members
-fail_compilation/test9701.d(60): Error: `static` is not a valid attribute for enum members
-fail_compilation/test9701.d(61): Error: `static` is not a valid attribute for enum members
-fail_compilation/test9701.d(62): Error: `static` is not a valid attribute for enum members
+fail_compilation/test9701.d(42): Error: found `pure` when expecting `identifier`
+fail_compilation/test9701.d(43): Error: found `shared` when expecting `identifier`
+fail_compilation/test9701.d(44): Error: found `inout` when expecting `identifier`
+fail_compilation/test9701.d(45): Error: found `immutable` when expecting `identifier`
+fail_compilation/test9701.d(46): Error: found `const` when expecting `identifier`
+fail_compilation/test9701.d(47): Error: found `synchronized` when expecting `identifier`
+fail_compilation/test9701.d(48): Error: found `scope` when expecting `identifier`
+fail_compilation/test9701.d(49): Error: found `auto` when expecting `identifier`
+fail_compilation/test9701.d(50): Error: found `ref` when expecting `identifier`
+fail_compilation/test9701.d(51): Error: found `__gshared` when expecting `identifier`
+fail_compilation/test9701.d(52): Error: found `final` when expecting `identifier`
+fail_compilation/test9701.d(53): Error: found `extern` when expecting `identifier`
+fail_compilation/test9701.d(54): Error: found `export` when expecting `identifier`
+fail_compilation/test9701.d(55): Error: found `nothrow` when expecting `identifier`
+fail_compilation/test9701.d(56): Error: found `public` when expecting `identifier`
+fail_compilation/test9701.d(57): Error: found `private` when expecting `identifier`
+fail_compilation/test9701.d(58): Error: found `package` when expecting `identifier`
+fail_compilation/test9701.d(59): Error: found `static` when expecting `identifier`
+fail_compilation/test9701.d(60): Error: found `static` when expecting `identifier`
+fail_compilation/test9701.d(61): Error: found `static` when expecting `identifier`
+fail_compilation/test9701.d(62): Error: found `static` when expecting `identifier`
---
*/
diff --git a/gcc/testsuite/gdc.test/runnable/aliasthis.d b/gcc/testsuite/gdc.test/runnable/aliasthis.d
index 50e5c4d..db5913c 100644
--- a/gcc/testsuite/gdc.test/runnable/aliasthis.d
+++ b/gcc/testsuite/gdc.test/runnable/aliasthis.d
@@ -1,16 +1,7 @@
/*
TEST_OUTPUT:
---
-runnable/aliasthis.d(103): Deprecation: alias this for classes/interfaces is deprecated
-runnable/aliasthis.d(291): Deprecation: alias this for classes/interfaces is deprecated
-runnable/aliasthis.d(292): Deprecation: alias this for classes/interfaces is deprecated
-runnable/aliasthis.d(294): Deprecation: alias this for classes/interfaces is deprecated
-runnable/aliasthis.d(465): Deprecation: alias this for classes/interfaces is deprecated
-runnable/aliasthis.d(466): Deprecation: alias this for classes/interfaces is deprecated
-runnable/aliasthis.d(477): Deprecation: alias this for classes/interfaces is deprecated
-runnable/aliasthis.d(1013): Deprecation: alias this for classes/interfaces is deprecated
false
-runnable/aliasthis.d(2100): Deprecation: alias this for classes/interfaces is deprecated
[] = int
[] = string
[0] = int
@@ -19,7 +10,6 @@ runnable/aliasthis.d(2100): Deprecation: alias this for classes/interfaces is de
[] = int
[1] = string
[0] = int
-runnable/aliasthis.d(741): Deprecation: alias this for classes/interfaces is deprecated
---
RUN_OUTPUT:
diff --git a/gcc/testsuite/gdc.test/runnable/complex.d b/gcc/testsuite/gdc.test/runnable/complex.d
index 50e793e..3a7291d 100644
--- a/gcc/testsuite/gdc.test/runnable/complex.d
+++ b/gcc/testsuite/gdc.test/runnable/complex.d
@@ -243,11 +243,11 @@ void test12()
{
real x = 3;
creal a = (2 + 4i) % 3;
- printf("%Lg %Lgi\n", a.re, a.im);
+ //printf("%Lg %Lgi\n", a.re, a.im);
assert(a == 2 + 1i);
creal b = (2 + 4i) % x;
- printf("%Lg %Lgi\n", b.re, b.im);
+ //printf("%Lg %Lgi\n", b.re, b.im);
assert(b == a);
}
@@ -257,7 +257,7 @@ void test13()
{
ireal a = 5i;
ireal b = a % 2;
- printf("%Lg %Lgi\n", b.re, b.im);
+ //printf("%Lg %Lgi\n", b.re, b.im);
assert(b == 1i);
}
@@ -530,9 +530,9 @@ void test22()
{
static creal[] params = [1+0i, 3+0i, 5+0i];
- printf("params[0] = %Lf + %Lfi\n", params[0].re, params[0].im);
- printf("params[1] = %Lf + %Lfi\n", params[1].re, params[1].im);
- printf("params[2] = %Lf + %Lfi\n", params[2].re, params[2].im);
+ //printf("params[0] = %Lf + %Lfi\n", params[0].re, params[0].im);
+ //printf("params[1] = %Lf + %Lfi\n", params[1].re, params[1].im);
+ //printf("params[2] = %Lf + %Lfi\n", params[2].re, params[2].im);
creal[] sums = new creal[3];
sums[] = 0+0i;
@@ -603,19 +603,19 @@ float func_24_4(float f, double d)
void test24()
{
ifloat f = func_24_1(10i, 8);
- printf("%fi\n", f);
+ //printf("%fi\n", f);
// assert(f == 1.25i);
f = func_24_2(10i, 8);
- printf("%fi\n", f);
+ //printf("%fi\n", f);
assert(f == 1.25i);
float g = func_24_3(10, 8);
- printf("%f\n", g);
+ //printf("%f\n", g);
// assert(g == 1.25);
g = func_24_4(10, 8);
- printf("%f\n", g);
+ //printf("%f\n", g);
assert(g == 1.25);
}
@@ -647,9 +647,9 @@ void test26()
foreach( cdouble z; A )
{
s = toString26(z);
- printf("%.*s ", cast(int)s.length, s.ptr);
+ //printf("%.*s ", cast(int)s.length, s.ptr);
}
- printf("\n");
+ //printf("\n");
for(int ii=0; ii<A.length; ii++ )
A[ii] += -1i*A[ii];
@@ -661,9 +661,9 @@ void test26()
foreach( cdouble z; A )
{
s = toString26(z);
- printf("%.*s ", cast(int)s.length, s.ptr);
+ //printf("%.*s ", cast(int)s.length, s.ptr);
}
- printf("\n");
+ //printf("\n");
}
/*************************************/
@@ -698,19 +698,19 @@ void test28()
void test29()
{
ireal a = 6.5i % 3i;
- printf("%Lfi %Lfi\n", a, a - .5i);
+ //printf("%Lfi %Lfi\n", a, a - .5i);
assert(a == .5i);
a = 6.5i % 3;
- printf("%Lfi %Lfi\n", a, a - .5i);
+ //printf("%Lfi %Lfi\n", a, a - .5i);
assert(a == .5i);
real b = 6.5 % 3i;
- printf("%Lf %Lf\n", b, b - .5);
+ //printf("%Lf %Lf\n", b, b - .5);
assert(b == .5);
b = 6.5 % 3;
- printf("%Lf %Lf\n", b, b - .5);
+ //printf("%Lf %Lf\n", b, b - .5);
assert(b == .5);
}
@@ -720,17 +720,17 @@ void test30()
{
cfloat f = 1+0i;
f %= 2fi;
- printf("%f + %fi\n", f.re, f.im);
+ //printf("%f + %fi\n", f.re, f.im);
assert(f == 1 + 0i);
cdouble d = 1+0i;
d %= 2i;
- printf("%f + %fi\n", d.re, d.im);
+ //printf("%f + %fi\n", d.re, d.im);
assert(d == 1 + 0i);
creal r = 1+0i;
r %= 2i;
- printf("%Lf + %Lfi\n", r.re, r.im);
+ //printf("%Lf + %Lfi\n", r.re, r.im);
assert(r == 1 + 0i);
}
@@ -740,17 +740,17 @@ void test31()
{
cfloat f = 1+0i;
f %= 2i;
- printf("%f + %fi\n", f.re, f.im);
+ //printf("%f + %fi\n", f.re, f.im);
assert(f == 1);
cdouble d = 1+0i;
d = d % 2i;
- printf("%f + %fi\n", d.re, d.im);
+ //printf("%f + %fi\n", d.re, d.im);
assert(d == 1);
creal r = 1+0i;
r = r % 2i;
- printf("%Lf + %Lfi\n", r.re, r.im);
+ //printf("%Lf + %Lfi\n", r.re, r.im);
assert(r == 1);
}
@@ -770,7 +770,7 @@ void assertEqual(real* a, real* b, string file = __FILE__, size_t line = __LINE_
{
if (x[i] != y[i])
{
- printf("%02zd: %02x %02x\n", i, x[i], y[i]);
+ //printf("%02zd: %02x %02x\n", i, x[i], y[i]);
import core.exception;
throw new AssertError(file, line);
}
@@ -856,7 +856,7 @@ void test35()
void test36()
{
ireal imag = 2.5i;
- printf ("test of imag*imag = %Lf\n",imag*imag);
+ //printf ("test of imag*imag = %Lf\n",imag*imag);
assert(imag * imag == -6.25);
}
@@ -885,7 +885,7 @@ void test39()
creal z = 1 + 2.5i;
real e = z.im;
- printf ("e = %Lf\n", e);
+ //printf ("e = %Lf\n", e);
assert(e == 2.5);
}
@@ -942,7 +942,7 @@ void test44()
{
ifloat f = 1.0fi;
// f *= 2.0fi; // illegal but compiles
- printf("%g\n", f);
+ //printf("%g\n", f);
// assert(f == 0i);
}
diff --git a/gcc/testsuite/gdc.test/runnable/interpret.d b/gcc/testsuite/gdc.test/runnable/interpret.d
index f9972f2..ee324d7 100644
--- a/gcc/testsuite/gdc.test/runnable/interpret.d
+++ b/gcc/testsuite/gdc.test/runnable/interpret.d
@@ -4,7 +4,6 @@ TEST_OUTPUT:
true
g
&Test109S(&Test109S(<recursion>))
-runnable/interpret.d(3742): Deprecation: alias this for classes/interfaces is deprecated
tfoo
tfoo
Crash!
@@ -2197,7 +2196,7 @@ struct Q
Q opOpAssign(string op)(int w) if (op == "-")
{
x -= w;
- version(D_Version2) { mixin("return this;"); } else { mixin("return *this;"); }
+ return this;
}
int boo() { return 4; }
int coo() { return x; }
@@ -2427,7 +2426,7 @@ static assert(bug1605() == 27);
int bug2564()
{
- version(D_Version2) { mixin("enum int Q = 0;"); }else {mixin("int Q = 0;"); }
+ enum int Q = 0;
string [2] s = ["a", "b"];
assert(s[Q].dup == "a");
return 0;
@@ -2646,8 +2645,6 @@ static assert(lazyTest2(17) == 18);
/************************************************/
-version(D_Version2)
-{
// https://issues.dlang.org/show_bug.cgi?id=4020
// https://issues.dlang.org/show_bug.cgi?id=4027
// D2 only
@@ -2677,7 +2674,6 @@ static if (is(typeof((){ static const s = bug4027("aaa")(); }()))) {
static assert(bug4027("aaa")() == "aaa");
static assert(bug4027("bbb")() == "bbb");
}
-}
// ---
diff --git a/gcc/testsuite/gdc.test/runnable/template9.d b/gcc/testsuite/gdc.test/runnable/template9.d
index dbad3f1..fa70b81 100644
--- a/gcc/testsuite/gdc.test/runnable/template9.d
+++ b/gcc/testsuite/gdc.test/runnable/template9.d
@@ -1991,7 +1991,7 @@ void test8976()
// https://issues.dlang.org/show_bug.cgi?id=8940
const int n8940; // or `immutable`
-static this() { n8940 = 3; }
+shared static this() { n8940 = 3; }
void f8940(T)(ref int val)
{
diff --git a/gcc/testsuite/gdc.test/runnable/test17684.d b/gcc/testsuite/gdc.test/runnable/test17684.d
index e102655..efdce08 100644
--- a/gcc/testsuite/gdc.test/runnable/test17684.d
+++ b/gcc/testsuite/gdc.test/runnable/test17684.d
@@ -1,13 +1,3 @@
-/*
-TEST_OUTPUT:
----
-runnable/test17684.d(37): Deprecation: alias this for classes/interfaces is deprecated
-runnable/test17684.d(54): Deprecation: alias this for classes/interfaces is deprecated
-runnable/test17684.d(54): Deprecation: alias this for classes/interfaces is deprecated
-runnable/test17684.d(37): Deprecation: alias this for classes/interfaces is deprecated
----
-*/
-
struct StructField(T)
{
static T Field;
diff --git a/gcc/testsuite/gdc.test/runnable/test19782.d b/gcc/testsuite/gdc.test/runnable/test19782.d
index 61a168b..a24d841 100644
--- a/gcc/testsuite/gdc.test/runnable/test19782.d
+++ b/gcc/testsuite/gdc.test/runnable/test19782.d
@@ -1,12 +1,4 @@
// https://issues.dlang.org/show_bug.cgi?id=19782
-
-/*
-TEST_OUTPUT:
----
-runnable/test19782.d(17): Deprecation: alias this for classes/interfaces is deprecated
----
-*/
-
class Inner
{
int a;
diff --git a/gcc/testsuite/gdc.test/runnable/test20.d b/gcc/testsuite/gdc.test/runnable/test20.d
index 5d47b06..5036ef2 100644
--- a/gcc/testsuite/gdc.test/runnable/test20.d
+++ b/gcc/testsuite/gdc.test/runnable/test20.d
@@ -1104,7 +1104,7 @@ class C60
{
}
- static this()
+ shared static this()
{
x = 5;
}
@@ -1117,7 +1117,7 @@ class C60
const int z60;
-static this()
+shared static this()
{
z60 = 3;
}
diff --git a/gcc/testsuite/gdc.test/runnable/test21039.d b/gcc/testsuite/gdc.test/runnable/test21039.d
index f32267a..c58600f 100644
--- a/gcc/testsuite/gdc.test/runnable/test21039.d
+++ b/gcc/testsuite/gdc.test/runnable/test21039.d
@@ -1,12 +1,5 @@
// https://issues.dlang.org/show_bug.cgi?id=21039
-/*
-TEST_OUTPUT:
----
-runnable/test21039.d(14): Deprecation: alias this for classes/interfaces is deprecated
----
-*/
-
class Inner {}
class Outer {
diff --git a/gcc/testsuite/gdc.test/runnable/test23234.d b/gcc/testsuite/gdc.test/runnable/test23234.d
index f974864..7872aa7 100644
--- a/gcc/testsuite/gdc.test/runnable/test23234.d
+++ b/gcc/testsuite/gdc.test/runnable/test23234.d
@@ -1,12 +1,5 @@
// https://issues.dlang.org/show_bug.cgi?id=23234
-/*
-TEST_OUTPUT:
----
-runnable/test23234.d(17): Deprecation: alias this for classes/interfaces is deprecated
----
-*/
-
class Bar
{
}
diff --git a/gcc/testsuite/gdc.test/runnable/test3449.d b/gcc/testsuite/gdc.test/runnable/test3449.d
index 8d38918..c06674a 100644
--- a/gcc/testsuite/gdc.test/runnable/test3449.d
+++ b/gcc/testsuite/gdc.test/runnable/test3449.d
@@ -12,11 +12,11 @@ immutable int ig1;
static this()
{
mg1 = 10;
- cg1 = 10;
}
shared static this()
{
+ cg1 = 10;
ig1 = 10;
}
static assert(!__traits(compiles, { static assert(mg1 == 0); }));
diff --git a/gcc/testsuite/gdc.test/runnable/test42.d b/gcc/testsuite/gdc.test/runnable/test42.d
index 436f707..d89c152 100644
--- a/gcc/testsuite/gdc.test/runnable/test42.d
+++ b/gcc/testsuite/gdc.test/runnable/test42.d
@@ -6167,7 +6167,7 @@ void test5332()
const int x11472 = void;
-static this() { x11472 = 10; }
+shared static this() { x11472 = 10; }
void test11472()
{
diff --git a/gcc/testsuite/gdc.test/runnable/testaliascast.d b/gcc/testsuite/gdc.test/runnable/testaliascast.d
index ed5091d..c55f820 100644
--- a/gcc/testsuite/gdc.test/runnable/testaliascast.d
+++ b/gcc/testsuite/gdc.test/runnable/testaliascast.d
@@ -1,13 +1,5 @@
// https://issues.dlang.org/show_bug.cgi?id=11294
-/*
-TEST_OUTPUT:
----
-runnable/testaliascast.d(29): Deprecation: alias this for classes/interfaces is deprecated
-runnable/testaliascast.d(58): Deprecation: alias this for classes/interfaces is deprecated
----
-*/
-
string result;
extern(C) void rt_finalize(void *ptr, bool det=true);
diff --git a/gcc/testsuite/gdc.test/runnable/testassign.d b/gcc/testsuite/gdc.test/runnable/testassign.d
index 79a4c57..c2b8a51 100644
--- a/gcc/testsuite/gdc.test/runnable/testassign.d
+++ b/gcc/testsuite/gdc.test/runnable/testassign.d
@@ -2,8 +2,6 @@
REQUIRED_ARGS: -preview=rvaluerefparam
TEST_OUTPUT:
---
-runnable/testassign.d(802): Deprecation: alias this for classes/interfaces is deprecated
-runnable/testassign.d(808): Deprecation: alias this for classes/interfaces is deprecated
\ S1 S2a S2b S3a S3b S4a S4b
- true true true true true true true
Xa true true true true true true true
@@ -363,7 +361,7 @@ struct CtorTest6174(Data)
const char gc6174;
const char[1] ga6174;
-static this()
+shared static this()
{
gc6174 = 'a'; // OK
ga6174[0] = 'a'; // line 5, Err
@@ -728,7 +726,7 @@ struct Foo8783
const Foo8783[1] foos8783;
-static this()
+shared static this()
{
foreach (i; 0 .. foos8783.length)
foos8783[i].bar[i] = 1; // OK
diff --git a/gcc/testsuite/gdc.test/runnable/testconst.d b/gcc/testsuite/gdc.test/runnable/testconst.d
index 17e3236..43f986d 100644
--- a/gcc/testsuite/gdc.test/runnable/testconst.d
+++ b/gcc/testsuite/gdc.test/runnable/testconst.d
@@ -551,7 +551,7 @@ void test38()
static const int x39;
const int y39;
-static this()
+shared static this()
{
x39 = 3;
y39 = 4;
@@ -613,7 +613,7 @@ class C42
static const int d;
static const int e = ctfe() + 2;
- static this()
+ shared static this()
{
d = 4;
}
@@ -1302,7 +1302,7 @@ void test78()
const bool[string] stopWords79;
-static this()
+shared static this()
{
stopWords79 = [ "a"[]:1 ];
}
diff --git a/gcc/testsuite/gdc.test/runnable/testswitch.d b/gcc/testsuite/gdc.test/runnable/testswitch.d
index c7b9378..4744697 100644
--- a/gcc/testsuite/gdc.test/runnable/testswitch.d
+++ b/gcc/testsuite/gdc.test/runnable/testswitch.d
@@ -353,15 +353,11 @@ int foo15(int i)
return y;
}
-static this()
-{
- X15 = 4;
- Z15 = 5;
-}
-
shared static this()
{
+ X15 = 4;
Y15 = 4;
+ Z15 = 5;
}
void test15()
diff --git a/gcc/testsuite/gdc.test/runnable/traits_getPointerBitmap.d b/gcc/testsuite/gdc.test/runnable/traits_getPointerBitmap.d
index ffa0b80..8996c9e 100644
--- a/gcc/testsuite/gdc.test/runnable/traits_getPointerBitmap.d
+++ b/gcc/testsuite/gdc.test/runnable/traits_getPointerBitmap.d
@@ -1,3 +1,4 @@
+
module traits_getPointerBitmap;
import core.stdc.stdio;
@@ -75,6 +76,19 @@ template pOff(T)
enum pOff = T.p.offsetof / bytesPerPtr;
}
+class C(T, aliasTo = void)
+{
+ static if(!is(aliasTo == void))
+ {
+ aliasTo a;
+ alias a this;
+ }
+
+ size_t x;
+ T t = void;
+ void* p;
+}
+
///////////////////////////////////////
void _testType(T)(size_t[] expected)
@@ -104,6 +118,21 @@ void testType(T)(size_t[] expected)
// prepend string
sexp[0] = (expected[0] << tOff!(S!(T, string))) | (1 << pOff!(S!(T, string))) | 2; // arr ptr
_testType!(S!(T, string))(sexp);
+
+ // generate bit pattern for C!T
+ C!T ct = null;
+ size_t mutexBit = (RTInfoMark__Monitor ? 2 : 0);
+ size_t ctpOff = ct.p.offsetof / bytesPerPtr;
+ size_t cttOff = ct.t.offsetof / bytesPerPtr;
+ sexp[0] = (expected[0] << cttOff) | (1 << ctpOff) | mutexBit;
+ _testType!(C!(T))(sexp);
+
+ C!(T, string) cts = null;
+ size_t ctspOff = cts.p.offsetof / bytesPerPtr;
+ size_t ctstOff = cts.t.offsetof / bytesPerPtr;
+ // generate bit pattern for C!T
+ sexp[0] = (expected[0] << ctstOff) | (1 << ctspOff) | mutexBit | 0b1000; // arr ptr
+ _testType!(C!(T, string))(sexp);
}
///////////////////////////////////////
diff --git a/gcc/testsuite/gdc.test/runnable/xtest46.d b/gcc/testsuite/gdc.test/runnable/xtest46.d
index 972de90..aeb2aab 100644
--- a/gcc/testsuite/gdc.test/runnable/xtest46.d
+++ b/gcc/testsuite/gdc.test/runnable/xtest46.d
@@ -2,14 +2,11 @@
//
/* TEST_OUTPUT:
---
-runnable/xtest46.d(165): Deprecation: alias this for classes/interfaces is deprecated
Boo!double
Boo!int
true
int
!! immutable(int)[]
-runnable/xtest46.d(2932): Deprecation: alias this for classes/interfaces is deprecated
-runnable/xtest46.d(2964): Deprecation: alias this for classes/interfaces is deprecated
int(int i, long j = 7L)
long
C10390(C10390(C10390(<recursion>)))
@@ -22,7 +19,6 @@ string[]
double[]
double[]
{}
-runnable/xtest46.d(4670): Deprecation: alias this for classes/interfaces is deprecated
AliasSeq!("m")
true
TFunction1: extern (C) void function()
diff --git a/gcc/testsuite/gdc.test/runnable/xtest46_gc.d b/gcc/testsuite/gdc.test/runnable/xtest46_gc.d
index aab6227..38c136d 100644
--- a/gcc/testsuite/gdc.test/runnable/xtest46_gc.d
+++ b/gcc/testsuite/gdc.test/runnable/xtest46_gc.d
@@ -3,14 +3,11 @@ REQUIRED_ARGS: -lowmem -Jrunnable -preview=rvaluerefparam
EXTRA_FILES: xtest46.d
TEST_OUTPUT:
---
-runnable/xtest46_gc.d-mixin-33(197): Deprecation: alias this for classes/interfaces is deprecated
Boo!double
Boo!int
true
int
!! immutable(int)[]
-runnable/xtest46_gc.d-mixin-33(2964): Deprecation: alias this for classes/interfaces is deprecated
-runnable/xtest46_gc.d-mixin-33(2996): Deprecation: alias this for classes/interfaces is deprecated
int(int i, long j = 7L)
long
C10390(C10390(<recursion>))
@@ -23,7 +20,6 @@ string[]
double[]
double[]
{}
-runnable/xtest46_gc.d-mixin-33(4702): Deprecation: alias this for classes/interfaces is deprecated
AliasSeq!("m")
true
TFunction1: extern (C) void function()