aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2023-04-07 21:43:06 +0200
committerThomas Schwinge <thomas_schwinge@mentor.com>2023-04-07 21:43:06 +0200
commitec914345e9ede274de0256cac45dc75804c2243e (patch)
treee2b551fed81feb7779cbae9806752c27e1e9cc8d /gcc
parente44f127cdb12a28536fe21983dfad20570bceda0 (diff)
parent10f085135bc98afa57309fcd679698a0122925bf (diff)
downloadgcc-ec914345e9ede274de0256cac45dc75804c2243e.zip
gcc-ec914345e9ede274de0256cac45dc75804c2243e.tar.gz
gcc-ec914345e9ede274de0256cac45dc75804c2243e.tar.bz2
Merge commit '7411eca498beb13729cc2acec77e68250940aa81~1' into HEAD
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog44
-rw-r--r--gcc/DATESTAMP2
-rw-r--r--gcc/analyzer/ChangeLog17
-rw-r--r--gcc/analyzer/analyzer.opt4
-rw-r--r--gcc/analyzer/engine.cc29
-rw-r--r--gcc/analyzer/pending-diagnostic.h4
-rw-r--r--gcc/analyzer/program-state.cc28
-rw-r--r--gcc/analyzer/region-model.cc2
-rw-r--r--gcc/analyzer/sm-malloc.cc4
-rw-r--r--gcc/config/xtensa/xtensa.cc2
-rw-r--r--gcc/config/xtensa/xtensa.md20
-rw-r--r--gcc/d/ChangeLog20
-rw-r--r--gcc/d/Make-lang.in1
-rw-r--r--gcc/d/d-codegen.cc29
-rw-r--r--gcc/d/d-gimplify.cc9
-rw-r--r--gcc/d/d-lang.cc5
-rw-r--r--gcc/d/decl.cc4
-rw-r--r--gcc/d/dmd/MERGE2
-rw-r--r--gcc/d/dmd/README.md1
-rw-r--r--gcc/d/dmd/VERSION2
-rw-r--r--gcc/d/dmd/access.d3
-rw-r--r--gcc/d/dmd/aggregate.d5
-rw-r--r--gcc/d/dmd/aggregate.h9
-rw-r--r--gcc/d/dmd/aliasthis.d5
-rw-r--r--gcc/d/dmd/aliasthis.h2
-rw-r--r--gcc/d/dmd/apply.d2
-rw-r--r--gcc/d/dmd/arrayop.d3
-rw-r--r--gcc/d/dmd/arraytypes.d2
-rw-r--r--gcc/d/dmd/arraytypes.h2
-rw-r--r--gcc/d/dmd/ast_node.d2
-rw-r--r--gcc/d/dmd/ast_node.h2
-rw-r--r--gcc/d/dmd/astenums.d2
-rw-r--r--gcc/d/dmd/attrib.d3
-rw-r--r--gcc/d/dmd/attrib.h2
-rw-r--r--gcc/d/dmd/blockexit.d3
-rw-r--r--gcc/d/dmd/builtin.d4
-rw-r--r--gcc/d/dmd/canthrow.d2
-rw-r--r--gcc/d/dmd/chkformat.d3
-rw-r--r--gcc/d/dmd/clone.d3
-rw-r--r--gcc/d/dmd/common/bitfields.d2
-rw-r--r--gcc/d/dmd/common/file.d2
-rw-r--r--gcc/d/dmd/common/outbuffer.d2
-rw-r--r--gcc/d/dmd/common/outbuffer.h2
-rw-r--r--gcc/d/dmd/common/string.d2
-rw-r--r--gcc/d/dmd/compiler.d2
-rw-r--r--gcc/d/dmd/compiler.h2
-rw-r--r--gcc/d/dmd/cond.d17
-rw-r--r--gcc/d/dmd/cond.h2
-rw-r--r--gcc/d/dmd/constfold.d12
-rw-r--r--gcc/d/dmd/cparse.d3
-rw-r--r--gcc/d/dmd/cppmangle.d3
-rw-r--r--gcc/d/dmd/ctfe.h2
-rw-r--r--gcc/d/dmd/ctfeexpr.d3
-rw-r--r--gcc/d/dmd/ctorflow.d4
-rw-r--r--gcc/d/dmd/dcast.d38
-rw-r--r--gcc/d/dmd/dclass.d5
-rw-r--r--gcc/d/dmd/declaration.d8
-rw-r--r--gcc/d/dmd/declaration.h2
-rw-r--r--gcc/d/dmd/delegatize.d3
-rw-r--r--gcc/d/dmd/denum.d3
-rw-r--r--gcc/d/dmd/dimport.d3
-rw-r--r--gcc/d/dmd/dinterpret.d62
-rw-r--r--gcc/d/dmd/dmacro.d2
-rw-r--r--gcc/d/dmd/dmangle.d2
-rw-r--r--gcc/d/dmd/dmodule.d97
-rw-r--r--gcc/d/dmd/doc.d6
-rw-r--r--gcc/d/dmd/doc.h2
-rw-r--r--gcc/d/dmd/dscope.d3
-rw-r--r--gcc/d/dmd/dstruct.d3
-rw-r--r--gcc/d/dmd/dsymbol.d3
-rw-r--r--gcc/d/dmd/dsymbol.h9
-rw-r--r--gcc/d/dmd/dsymbolsem.d49
-rw-r--r--gcc/d/dmd/dtemplate.d69
-rw-r--r--gcc/d/dmd/dtoh.d3
-rw-r--r--gcc/d/dmd/dversion.d3
-rw-r--r--gcc/d/dmd/entity.d2
-rw-r--r--gcc/d/dmd/enum.h2
-rw-r--r--gcc/d/dmd/errors.d3
-rw-r--r--gcc/d/dmd/errors.h2
-rw-r--r--gcc/d/dmd/escape.d5
-rw-r--r--gcc/d/dmd/expression.d9
-rw-r--r--gcc/d/dmd/expression.h2
-rw-r--r--gcc/d/dmd/expressionsem.d108
-rw-r--r--gcc/d/dmd/file_manager.d55
-rw-r--r--gcc/d/dmd/foreachvar.d2
-rw-r--r--gcc/d/dmd/func.d138
-rw-r--r--gcc/d/dmd/globals.d132
-rw-r--r--gcc/d/dmd/globals.h18
-rw-r--r--gcc/d/dmd/gluelayer.d2
-rw-r--r--gcc/d/dmd/hdrgen.d11
-rw-r--r--gcc/d/dmd/hdrgen.h2
-rw-r--r--gcc/d/dmd/iasm.d2
-rw-r--r--gcc/d/dmd/iasmgcc.d3
-rw-r--r--gcc/d/dmd/id.d2
-rw-r--r--gcc/d/dmd/id.h2
-rw-r--r--gcc/d/dmd/identifier.d4
-rw-r--r--gcc/d/dmd/identifier.h2
-rw-r--r--gcc/d/dmd/impcnvtab.d2
-rw-r--r--gcc/d/dmd/imphint.d2
-rw-r--r--gcc/d/dmd/import.h2
-rw-r--r--gcc/d/dmd/importc.d2
-rw-r--r--gcc/d/dmd/init.d3
-rw-r--r--gcc/d/dmd/init.h2
-rw-r--r--gcc/d/dmd/initsem.d3
-rw-r--r--gcc/d/dmd/inline.d2
-rw-r--r--gcc/d/dmd/intrange.d2
-rw-r--r--gcc/d/dmd/json.d3
-rw-r--r--gcc/d/dmd/json.h2
-rw-r--r--gcc/d/dmd/lambdacomp.d2
-rw-r--r--gcc/d/dmd/lexer.d69
-rw-r--r--gcc/d/dmd/location.d158
-rw-r--r--gcc/d/dmd/mangle.h2
-rw-r--r--gcc/d/dmd/module.h8
-rw-r--r--gcc/d/dmd/mtype.d51
-rw-r--r--gcc/d/dmd/mtype.h2
-rw-r--r--gcc/d/dmd/mustuse.d5
-rw-r--r--gcc/d/dmd/nogc.d2
-rw-r--r--gcc/d/dmd/nspace.d3
-rw-r--r--gcc/d/dmd/nspace.h2
-rw-r--r--gcc/d/dmd/ob.d3
-rw-r--r--gcc/d/dmd/objc.d3
-rw-r--r--gcc/d/dmd/objc.h2
-rw-r--r--gcc/d/dmd/opover.d9
-rw-r--r--gcc/d/dmd/optimize.d8
-rw-r--r--gcc/d/dmd/parse.d26
-rw-r--r--gcc/d/dmd/printast.d2
-rw-r--r--gcc/d/dmd/root/aav.d2
-rw-r--r--gcc/d/dmd/root/array.d2
-rw-r--r--gcc/d/dmd/root/array.h2
-rw-r--r--gcc/d/dmd/root/bitarray.d2
-rw-r--r--gcc/d/dmd/root/bitarray.h2
-rw-r--r--gcc/d/dmd/root/complex.d2
-rw-r--r--gcc/d/dmd/root/complex_t.h2
-rw-r--r--gcc/d/dmd/root/ctfloat.d2
-rw-r--r--gcc/d/dmd/root/ctfloat.h2
-rw-r--r--gcc/d/dmd/root/dcompat.h2
-rw-r--r--gcc/d/dmd/root/file.d2
-rw-r--r--gcc/d/dmd/root/filename.d2
-rw-r--r--gcc/d/dmd/root/filename.h2
-rw-r--r--gcc/d/dmd/root/hash.d2
-rw-r--r--gcc/d/dmd/root/object.h2
-rw-r--r--gcc/d/dmd/root/optional.d2
-rw-r--r--gcc/d/dmd/root/optional.h2
-rw-r--r--gcc/d/dmd/root/port.d2
-rw-r--r--gcc/d/dmd/root/port.h2
-rw-r--r--gcc/d/dmd/root/region.d2
-rw-r--r--gcc/d/dmd/root/rmem.d2
-rw-r--r--gcc/d/dmd/root/rmem.h2
-rw-r--r--gcc/d/dmd/root/rootobject.d2
-rw-r--r--gcc/d/dmd/root/speller.d2
-rw-r--r--gcc/d/dmd/root/string.d2
-rw-r--r--gcc/d/dmd/root/stringtable.d2
-rw-r--r--gcc/d/dmd/root/utf.d2
-rw-r--r--gcc/d/dmd/safe.d2
-rw-r--r--gcc/d/dmd/sapply.d2
-rw-r--r--gcc/d/dmd/scope.h2
-rw-r--r--gcc/d/dmd/semantic2.d41
-rw-r--r--gcc/d/dmd/semantic3.d3
-rw-r--r--gcc/d/dmd/sideeffect.d2
-rw-r--r--gcc/d/dmd/statement.d7
-rw-r--r--gcc/d/dmd/statement.h2
-rw-r--r--gcc/d/dmd/statement_rewrite_walker.d2
-rw-r--r--gcc/d/dmd/statementsem.d3
-rw-r--r--gcc/d/dmd/staticassert.d18
-rw-r--r--gcc/d/dmd/staticassert.h4
-rw-r--r--gcc/d/dmd/staticcond.d2
-rw-r--r--gcc/d/dmd/stmtstate.d2
-rw-r--r--gcc/d/dmd/target.d4
-rw-r--r--gcc/d/dmd/target.h2
-rw-r--r--gcc/d/dmd/template.h3
-rw-r--r--gcc/d/dmd/templateparamsem.d3
-rw-r--r--gcc/d/dmd/tokens.d8
-rw-r--r--gcc/d/dmd/tokens.h2
-rw-r--r--gcc/d/dmd/traits.d201
-rw-r--r--gcc/d/dmd/transitivevisitor.d5
-rw-r--r--gcc/d/dmd/typesem.d25
-rw-r--r--gcc/d/dmd/typinf.d3
-rw-r--r--gcc/d/dmd/utils.d4
-rw-r--r--gcc/d/dmd/version.h2
-rw-r--r--gcc/d/dmd/visitor.d2
-rw-r--r--gcc/d/dmd/visitor.h2
-rw-r--r--gcc/doc/invoke.texi25
-rw-r--r--gcc/fortran/ChangeLog9
-rw-r--r--gcc/fortran/parse.cc25
-rw-r--r--gcc/fortran/resolve.cc4
-rw-r--r--gcc/rust/ChangeLog839
-rw-r--r--gcc/testsuite/ChangeLog168
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/attribute-nonnull.c23
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/call-summaries-2.c15
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/data-model-1.c19
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/data-model-5.c4
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/doom-s_sound-pr108867.c653
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/memset-CVE-2017-18549-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/null-deref-pr108830.c94
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pipe-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pipe-void-return.c2
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pipe2-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr101547.c10
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr101875.c14
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr104224-split.c136
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/pr104224.c2
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/realloc-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/realloc-3.c2
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/realloc-5.c2
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/stdarg-1-ms_abi.c1
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/stdarg-1-sysv_abi.c1
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/stdarg-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/symbolic-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/symbolic-7.c14
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/uninit-4.c18
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/uninit-8.c73
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/uninit-pr94713.c10
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/zlib-6a.c2
-rw-r--r--gcc/testsuite/gcc.dg/pr108691.c9
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr108793.c10
-rw-r--r--gcc/testsuite/gdc.dg/ctfeintrinsics.d53
-rw-r--r--gcc/testsuite/gdc.dg/simd2a.d12
-rw-r--r--gcc/testsuite/gdc.dg/simd2b.d12
-rw-r--r--gcc/testsuite/gdc.dg/simd2c.d12
-rw-r--r--gcc/testsuite/gdc.dg/simd2d.d12
-rw-r--r--gcc/testsuite/gdc.dg/simd2e.d12
-rw-r--r--gcc/testsuite/gdc.dg/simd2f.d12
-rw-r--r--gcc/testsuite/gdc.dg/simd2g.d12
-rw-r--r--gcc/testsuite/gdc.dg/simd2h.d12
-rw-r--r--gcc/testsuite/gdc.dg/simd2i.d12
-rw-r--r--gcc/testsuite/gdc.dg/simd2j.d12
-rw-r--r--gcc/testsuite/gdc.test/compilable/extra-files/build23499.d7
-rw-r--r--gcc/testsuite/gdc.test/compilable/imports/file23499.d19
-rw-r--r--gcc/testsuite/gdc.test/compilable/imports/test23490frop.d7
-rw-r--r--gcc/testsuite/gdc.test/compilable/imports/test23490pop.d7
-rw-r--r--gcc/testsuite/gdc.test/compilable/imports/test23490zoo.d17
-rw-r--r--gcc/testsuite/gdc.test/compilable/isexpalias.d9
-rw-r--r--gcc/testsuite/gdc.test/compilable/issue20618.d10
-rw-r--r--gcc/testsuite/gdc.test/compilable/issue22646.d67
-rw-r--r--gcc/testsuite/gdc.test/compilable/issue22854.d20
-rw-r--r--gcc/testsuite/gdc.test/compilable/issue22975.d12
-rw-r--r--gcc/testsuite/gdc.test/compilable/issue23391.d31
-rw-r--r--gcc/testsuite/gdc.test/compilable/issue23567.d9
-rw-r--r--gcc/testsuite/gdc.test/compilable/noreturn1.d11
-rw-r--r--gcc/testsuite/gdc.test/compilable/noreturn3.d10
-rw-r--r--gcc/testsuite/gdc.test/compilable/test18646.d14
-rw-r--r--gcc/testsuite/gdc.test/compilable/test19585.d10
-rw-r--r--gcc/testsuite/gdc.test/compilable/test22638.d15
-rw-r--r--gcc/testsuite/gdc.test/compilable/test22813.d9
-rw-r--r--gcc/testsuite/gdc.test/compilable/test23481.d28
-rw-r--r--gcc/testsuite/gdc.test/compilable/test23490.d3
-rw-r--r--gcc/testsuite/gdc.test/compilable/test23497.d19
-rw-r--r--gcc/testsuite/gdc.test/compilable/test23499.d6
-rw-r--r--gcc/testsuite/gdc.test/compilable/test23529.d6
-rw-r--r--gcc/testsuite/gdc.test/compilable/test23532.d67
-rw-r--r--gcc/testsuite/gdc.test/compilable/test23533.d10
-rw-r--r--gcc/testsuite/gdc.test/compilable/test23586.d34
-rw-r--r--gcc/testsuite/gdc.test/compilable/test23587.d18
-rw-r--r--gcc/testsuite/gdc.test/compilable/test23589.d30
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail109.d16
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail20618.d16
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail23151.d41
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail23574.d41
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/fail23591.d16
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/failattr.d17
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/ice23564.d25
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/ice23569.d19
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/staticassertargs.d9
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/staticassertargsfail.d10
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test12228.d5
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test21008.d1
-rw-r--r--gcc/testsuite/gdc.test/fail_compilation/test23552.d24
-rw-r--r--gcc/testsuite/gdc.test/runnable/issue22854.d27
-rw-r--r--gcc/testsuite/gdc.test/runnable/test16098.d14
-rw-r--r--gcc/testsuite/gdc.test/runnable/test20811.d34
-rw-r--r--gcc/testsuite/gdc.test/runnable/test23307.d93
-rw-r--r--gcc/testsuite/gdc.test/runnable/test34.d2
-rw-r--r--gcc/testsuite/gdc.test/runnable/xtest46.d2
-rw-r--r--gcc/testsuite/gdc.test/runnable/xtest46_gc.d2
-rw-r--r--gcc/testsuite/gfortran.dg/pr96025.f9011
-rw-r--r--gcc/tree-ssa-dce.cc8
-rw-r--r--gcc/tree-ssa-loop-niter.cc11
277 files changed, 4402 insertions, 941 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3ab2938..4363149 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,47 @@
+2023-02-21 David Malcolm <dmalcolm@redhat.com>
+
+ PR analyzer/108830
+ * doc/invoke.texi: Document -fno-analyzer-suppress-followups.
+
+2023-02-21 Max Filippov <jcmvbkbc@gmail.com>
+
+ PR target/108876
+ * config/xtensa/xtensa.cc (xtensa_expand_epilogue): Drop emit_use
+ for A0_REG.
+ * config/xtensa/xtensa.md (sibcall, sibcall_internal)
+ (sibcall_value, sibcall_value_internal): Add 'use' expression
+ for A0_REG.
+
+2023-02-21 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/108691
+ * tree-ssa-dce.cc (eliminate_unnecessary_stmts): Remove
+ assert about calls_setjmp not becoming true when it was false.
+
+2023-02-21 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/108793
+ * tree-ssa-loop-niter.cc (number_of_iterations_until_wrap):
+ Use convert operands to niter_type when computing num.
+
+2023-02-21 Richard Biener <rguenther@suse.de>
+
+ Revert:
+ 2023-02-13 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/108691
+ * tree-cfg.cc (notice_special_calls): When the CFG is built
+ honor gimple_call_ctrl_altering_p.
+ * cfgexpand.cc (expand_call_stmt): Clear cfun->calls_setjmp
+ temporarily if the call is not control-altering.
+ * calls.cc (emit_call_1): Do not add REG_SETJMP if
+ cfun->calls_setjmp is not set. Do not alter cfun->calls_setjmp.
+
+2023-02-21 Takayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp>
+
+ * config/xtensa/xtensa.cc (xtensa_call_save_reg): Change to return
+ true if register A0 (return address register) when -Og is specified.
+
2023-02-20 Uroš Bizjak <ubizjak@gmail.com>
* config/i386/predicates.md
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 6d7db27..e7a8650 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230221
+20230222
diff --git a/gcc/analyzer/ChangeLog b/gcc/analyzer/ChangeLog
index 15a3de7..000360c 100644
--- a/gcc/analyzer/ChangeLog
+++ b/gcc/analyzer/ChangeLog
@@ -1,3 +1,20 @@
+2023-02-21 David Malcolm <dmalcolm@redhat.com>
+
+ PR analyzer/108830
+ * analyzer.opt (fanalyzer-suppress-followups): New option.
+ * engine.cc (impl_region_model_context::warn): Terminate the path
+ if the diagnostic's terminate_path_p vfunc returns true and
+ -fanalyzer-suppress-followups is true (the default).
+ (impl_sm_context::warn): Likewise, for both overloads.
+ * pending-diagnostic.h (pending_diagnostic::terminate_path_p): New
+ vfunc.
+ * program-state.cc (program_state::on_edge): Terminate the path if
+ the ctxt requests it during updating the edge.
+ * region-model.cc (poisoned_value_diagnostic::terminate_path_p):
+ New vfunc.
+ * sm-malloc.cc (null_deref::terminate_path_p): New vfunc.
+ (null_arg::terminate_path_p): New vfunc.
+
2023-02-16 David Malcolm <dmalcolm@redhat.com>
PR analyzer/108806
diff --git a/gcc/analyzer/analyzer.opt b/gcc/analyzer/analyzer.opt
index b4dcdb8..9d1a937 100644
--- a/gcc/analyzer/analyzer.opt
+++ b/gcc/analyzer/analyzer.opt
@@ -262,6 +262,10 @@ fanalyzer-state-merge
Common Var(flag_analyzer_state_merge) Init(1)
Merge similar-enough states during analysis.
+fanalyzer-suppress-followups
+Common Var(flag_analyzer_suppress_followups) Init(1)
+Stop exploring an execution path after certain diagnostics.
+
fanalyzer-transitivity
Common Var(flag_analyzer_transitivity) Init(0)
Enable transitivity of constraints during analysis.
diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc
index 24ded26..a5965c2 100644
--- a/gcc/analyzer/engine.cc
+++ b/gcc/analyzer/engine.cc
@@ -125,11 +125,20 @@ impl_region_model_context::warn (std::unique_ptr<pending_diagnostic> d)
return false;
}
if (m_eg)
- return m_eg->get_diagnostic_manager ().add_diagnostic
- (m_enode_for_diag, m_enode_for_diag->get_supernode (),
- m_stmt, m_stmt_finder, std::move (d));
- else
- return false;
+ {
+ bool terminate_path = d->terminate_path_p ();
+ if (m_eg->get_diagnostic_manager ().add_diagnostic
+ (m_enode_for_diag, m_enode_for_diag->get_supernode (),
+ m_stmt, m_stmt_finder, std::move (d)))
+ {
+ if (m_path_ctxt
+ && terminate_path
+ && flag_analyzer_suppress_followups)
+ m_path_ctxt->terminate_path ();
+ return true;
+ }
+ }
+ return false;
}
void
@@ -378,9 +387,14 @@ public:
= (var
? m_old_smap->get_state (var_old_sval, m_eg.get_ext_state ())
: m_old_smap->get_global_state ());
+ bool terminate_path = d->terminate_path_p ();
m_eg.get_diagnostic_manager ().add_diagnostic
(&m_sm, m_enode_for_diag, snode, stmt, m_stmt_finder,
var, var_old_sval, current, std::move (d));
+ if (m_path_ctxt
+ && terminate_path
+ && flag_analyzer_suppress_followups)
+ m_path_ctxt->terminate_path ();
}
void warn (const supernode *snode, const gimple *stmt,
@@ -393,9 +407,14 @@ public:
= (sval
? m_old_smap->get_state (sval, m_eg.get_ext_state ())
: m_old_smap->get_global_state ());
+ bool terminate_path = d->terminate_path_p ();
m_eg.get_diagnostic_manager ().add_diagnostic
(&m_sm, m_enode_for_diag, snode, stmt, m_stmt_finder,
NULL_TREE, sval, current, std::move (d));
+ if (m_path_ctxt
+ && terminate_path
+ && flag_analyzer_suppress_followups)
+ m_path_ctxt->terminate_path ();
}
/* Hook for picking more readable trees for SSA names of temporaries,
diff --git a/gcc/analyzer/pending-diagnostic.h b/gcc/analyzer/pending-diagnostic.h
index d9e9e7f..6423c8b 100644
--- a/gcc/analyzer/pending-diagnostic.h
+++ b/gcc/analyzer/pending-diagnostic.h
@@ -173,6 +173,10 @@ class pending_diagnostic
having to generate feasible execution paths for them). */
virtual int get_controlling_option () const = 0;
+ /* Vfunc to give the diagnostic the chance to terminate the execution
+ path being explored. By default, don't terminate the path. */
+ virtual bool terminate_path_p () const { return false; }
+
/* Vfunc for emitting the diagnostic. The rich_location will have been
populated with a diagnostic_path.
Return true if a diagnostic is actually emitted. */
diff --git a/gcc/analyzer/program-state.cc b/gcc/analyzer/program-state.cc
index 9a1a8cd..8dade4b 100644
--- a/gcc/analyzer/program-state.cc
+++ b/gcc/analyzer/program-state.cc
@@ -1105,6 +1105,27 @@ program_state::on_edge (exploded_graph &eg,
const superedge *succ,
uncertainty_t *uncertainty)
{
+ class my_path_context : public path_context
+ {
+ public:
+ my_path_context (bool &terminated) : m_terminated (terminated) {}
+ void bifurcate (std::unique_ptr<custom_edge_info>) final override
+ {
+ gcc_unreachable ();
+ }
+
+ void terminate_path () final override
+ {
+ m_terminated = true;
+ }
+
+ bool terminate_path_p () const final override
+ {
+ return m_terminated;
+ }
+ bool &m_terminated;
+ };
+
/* Update state. */
const program_point &point = enode->get_point ();
const gimple *last_stmt = point.get_supernode ()->get_last_stmt ();
@@ -1117,11 +1138,12 @@ program_state::on_edge (exploded_graph &eg,
Adding the relevant conditions for the edge could also trigger
sm-state transitions (e.g. transitions due to ptrs becoming known
to be NULL or non-NULL) */
-
+ bool terminated = false;
+ my_path_context path_ctxt (terminated);
impl_region_model_context ctxt (eg, enode,
&enode->get_state (),
this,
- uncertainty, NULL,
+ uncertainty, &path_ctxt,
last_stmt);
if (!m_region_model->maybe_update_for_edge (*succ,
last_stmt,
@@ -1134,6 +1156,8 @@ program_state::on_edge (exploded_graph &eg,
succ->m_dest->m_index);
return false;
}
+ if (terminated)
+ return false;
program_state::detect_leaks (enode->get_state (), *this,
NULL, eg.get_ext_state (),
diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index e3de74b..f844b51 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -505,6 +505,8 @@ public:
}
}
+ bool terminate_path_p () const final override { return true; }
+
bool emit (rich_location *rich_loc) final override
{
switch (m_pkind)
diff --git a/gcc/analyzer/sm-malloc.cc b/gcc/analyzer/sm-malloc.cc
index c24fe73..1ea9b30 100644
--- a/gcc/analyzer/sm-malloc.cc
+++ b/gcc/analyzer/sm-malloc.cc
@@ -1150,6 +1150,8 @@ public:
return OPT_Wanalyzer_null_dereference;
}
+ bool terminate_path_p () const final override { return true; }
+
bool emit (rich_location *rich_loc) final override
{
/* CWE-476: NULL Pointer Dereference. */
@@ -1203,6 +1205,8 @@ public:
return OPT_Wanalyzer_null_argument;
}
+ bool terminate_path_p () const final override { return true; }
+
bool emit (rich_location *rich_loc) final override
{
/* CWE-476: NULL Pointer Dereference. */
diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc
index d0320ef..5c1c713 100644
--- a/gcc/config/xtensa/xtensa.cc
+++ b/gcc/config/xtensa/xtensa.cc
@@ -3548,8 +3548,6 @@ xtensa_expand_epilogue (bool sibcall_p)
gen_frame_mem (SImode, x));
}
}
- if (sibcall_p)
- emit_use (gen_rtx_REG (SImode, A0_REG));
if (cfun->machine->current_frame_size > 0)
{
diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md
index d3996b2..b8a8aaf 100644
--- a/gcc/config/xtensa/xtensa.md
+++ b/gcc/config/xtensa/xtensa.md
@@ -2369,8 +2369,10 @@
(set_attr "length" "3")])
(define_expand "sibcall"
- [(call (match_operand 0 "memory_operand" "")
- (match_operand 1 "" ""))]
+ [(parallel [
+ (call (match_operand 0 "memory_operand" "")
+ (match_operand 1 "" ""))
+ (use (reg:SI A0_REG))])]
"!TARGET_WINDOWED_ABI"
{
xtensa_prepare_expand_call (0, operands);
@@ -2378,7 +2380,8 @@
(define_insn "sibcall_internal"
[(call (mem:SI (match_operand:SI 0 "call_insn_operand" "nic"))
- (match_operand 1 "" "i"))]
+ (match_operand 1 "" "i"))
+ (use (reg:SI A0_REG))]
"!TARGET_WINDOWED_ABI && SIBLING_CALL_P (insn)"
{
return xtensa_emit_sibcall (0, operands);
@@ -2388,9 +2391,11 @@
(set_attr "length" "3")])
(define_expand "sibcall_value"
- [(set (match_operand 0 "register_operand" "")
- (call (match_operand 1 "memory_operand" "")
- (match_operand 2 "" "")))]
+ [(parallel [
+ (set (match_operand 0 "register_operand" "")
+ (call (match_operand 1 "memory_operand" "")
+ (match_operand 2 "" "")))
+ (use (reg:SI A0_REG))])]
"!TARGET_WINDOWED_ABI"
{
xtensa_prepare_expand_call (1, operands);
@@ -2399,7 +2404,8 @@
(define_insn "sibcall_value_internal"
[(set (match_operand 0 "register_operand" "=a")
(call (mem:SI (match_operand:SI 1 "call_insn_operand" "nic"))
- (match_operand 2 "" "i")))]
+ (match_operand 2 "" "i")))
+ (use (reg:SI A0_REG))]
"!TARGET_WINDOWED_ABI && SIBLING_CALL_P (insn)"
{
return xtensa_emit_sibcall (1, operands);
diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog
index 3a06f45..bac1366 100644
--- a/gcc/d/ChangeLog
+++ b/gcc/d/ChangeLog
@@ -1,3 +1,23 @@
+2023-02-21 Iain Buclaw <ibuclaw@gdcproject.org>
+
+ * Make-lang.in (D_FRONTEND_OBJS): Add d/location.o.
+ * d-lang.cc (d_init_options): Update for new front-end interface.
+ (d_post_options): Call Loc::set after handling options.
+ * dmd/MERGE: Merge upstream dmd 09faa4eacd.
+ * dmd/VERSION: Bump version to v2.102.0-beta.1.
+
+2023-02-21 Iain Buclaw <ibuclaw@gdcproject.org>
+
+ * d-codegen.cc (d_build_call): Remove front-end expansion of
+ side-effects in a call expression.
+ * d-gimplify.cc (d_gimplify_call_expr): Gimplify the callee before its
+ arguments.
+
+2023-02-21 Iain Buclaw <ibuclaw@gdcproject.org>
+
+ * decl.cc (DeclVisitor::visit (FuncDeclaration *)): Set
+ doing_semantic_analysis_p before calling functionSemantic3.
+
2023-01-02 Jakub Jelinek <jakub@redhat.com>
* gdc.texi: Bump @copyrights-d year.
diff --git a/gcc/d/Make-lang.in b/gcc/d/Make-lang.in
index bf295a9..4feebac 100644
--- a/gcc/d/Make-lang.in
+++ b/gcc/d/Make-lang.in
@@ -147,6 +147,7 @@ D_FRONTEND_OBJS = \
d/json.o \
d/lambdacomp.o \
d/lexer.o \
+ d/location.o \
d/mtype.o \
d/mustuse.o \
d/nogc.o \
diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc
index 920b45d..0e8e073 100644
--- a/gcc/d/d-codegen.cc
+++ b/gcc/d/d-codegen.cc
@@ -2172,7 +2172,6 @@ d_build_call (TypeFunction *tf, tree callable, tree object,
/* Build the argument list for the call. */
vec <tree, va_gc> *args = NULL;
- tree saved_args = NULL_TREE;
bool noreturn_call = false;
/* If this is a delegate call or a nested function being called as
@@ -2182,23 +2181,6 @@ d_build_call (TypeFunction *tf, tree callable, tree object,
if (arguments)
{
- /* First pass, evaluated expanded tuples in function arguments. */
- for (size_t i = 0; i < arguments->length; ++i)
- {
- Lagain:
- Expression *arg = (*arguments)[i];
- gcc_assert (arg->op != EXP::tuple);
-
- if (arg->op == EXP::comma)
- {
- CommaExp *ce = arg->isCommaExp ();
- tree tce = build_expr (ce->e1);
- saved_args = compound_expr (saved_args, tce);
- (*arguments)[i] = ce->e2;
- goto Lagain;
- }
- }
-
const size_t nparams = tf->parameterList.length ();
/* if _arguments[] is the first argument. */
const size_t varargs = tf->isDstyleVariadic ();
@@ -2257,17 +2239,12 @@ d_build_call (TypeFunction *tf, tree callable, tree object,
}
}
- /* Evaluate the callee before calling it. */
- if (TREE_SIDE_EFFECTS (callee))
- {
- callee = d_save_expr (callee);
- saved_args = compound_expr (callee, saved_args);
- }
-
/* If we saw a `noreturn` parameter, any unreachable argument evaluations
after it are discarded, as well as the function call itself. */
if (noreturn_call)
{
+ tree saved_args = NULL_TREE;
+
if (TREE_SIDE_EFFECTS (callee))
saved_args = compound_expr (callee, saved_args);
@@ -2297,7 +2274,7 @@ d_build_call (TypeFunction *tf, tree callable, tree object,
result = force_target_expr (result);
}
- return compound_expr (saved_args, result);
+ return result;
}
/* Build and return the correct call to fmod depending on TYPE.
diff --git a/gcc/d/d-gimplify.cc b/gcc/d/d-gimplify.cc
index 4072a3d..04cb631 100644
--- a/gcc/d/d-gimplify.cc
+++ b/gcc/d/d-gimplify.cc
@@ -162,6 +162,15 @@ d_gimplify_call_expr (tree *expr_p, gimple_seq *pre_p)
if (!has_side_effects)
return GS_UNHANDLED;
+ /* Evaluate the callee before calling it. */
+ tree new_call_fn = CALL_EXPR_FN (*expr_p);
+
+ if (gimplify_expr (&new_call_fn, pre_p, NULL,
+ is_gimple_call_addr, fb_rvalue) == GS_ERROR)
+ return GS_ERROR;
+
+ CALL_EXPR_FN (*expr_p) = new_call_fn;
+
/* Leave the last argument for gimplify_call_expr. */
for (int i = 0; i < nargs - 1; i++)
{
diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc
index d9b4946..449c692 100644
--- a/gcc/d/d-lang.cc
+++ b/gcc/d/d-lang.cc
@@ -303,7 +303,7 @@ d_init_options (unsigned int, cl_decoded_option *decoded_options)
/* Warnings and deprecations are disabled by default. */
global.params.useDeprecated = DIAGNOSTICinform;
global.params.warnings = DIAGNOSTICoff;
- global.params.messageStyle = MESSAGESTYLEgnu;
+ global.params.messageStyle = MessageStyle::gnu;
global.params.imppath = d_gc_malloc<Strings> ();
global.params.fileImppath = d_gc_malloc<Strings> ();
@@ -940,6 +940,9 @@ d_post_options (const char ** fn)
global.params.showColumns = flag_show_column;
global.params.printErrorContext = flag_diagnostics_show_caret;
+ /* Keep the front-end location type in sync with params. */
+ Loc::set (global.params.showColumns, global.params.messageStyle);
+
if (global.params.useInline)
global.params.dihdr.fullOutput = true;
diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 2bece96..990ac40 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -829,8 +829,12 @@ public:
/* Ensure all semantic passes have run. */
if (d->semanticRun < PASS::semantic3)
{
+ gcc_assert (!doing_semantic_analysis_p);
+
+ doing_semantic_analysis_p = true;
d->functionSemantic3 ();
Module::runDeferredSemantic3 ();
+ doing_semantic_analysis_p = false;
}
if (global.errors)
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 5ee6f62..ac3dd12 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-c8ae4adb2eda515b09b326948e3a4aa9f489af45
+09faa4eacd4fb147107e94eeebf56b3a73fdcc05
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 1c7e1dd..43eb187 100644
--- a/gcc/d/dmd/README.md
+++ b/gcc/d/dmd/README.md
@@ -47,6 +47,7 @@ Note that these groups have no strict meaning, the category assignments are a bi
| File | Purpose |
|-----------------------------------------------------------------------|----------------------------------------------------------------------|
| [lexer.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/lexer.d) | Convert source code into tokens for the D and ImportC parsers |
+| [location.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/location.d)| Encapsulate file/line/column info for error messages, etc. |
| [entity.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/entity.d) | Define "\\&Entity;" escape sequence for strings / character literals |
| [tokens.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/tokens.d) | Define lexical tokens. |
| [parse.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/parse.d) | D parser, converting tokens into an Abstract Syntax Tree (AST) |
diff --git a/gcc/d/dmd/VERSION b/gcc/d/dmd/VERSION
index 50adf9c..177c41d 100644
--- a/gcc/d/dmd/VERSION
+++ b/gcc/d/dmd/VERSION
@@ -1 +1 @@
-v2.101.0-beta.1
+v2.102.0-beta.1
diff --git a/gcc/d/dmd/access.d b/gcc/d/dmd/access.d
index 59c77adf..f2d68d5 100644
--- a/gcc/d/dmd/access.d
+++ b/gcc/d/dmd/access.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/attribute.html#visibility_attributes, Visibility Attributes)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/access.d, _access.d)
@@ -25,6 +25,7 @@ import dmd.errors;
import dmd.expression;
import dmd.func;
import dmd.globals;
+import dmd.location;
import dmd.mtype;
import dmd.tokens;
diff --git a/gcc/d/dmd/aggregate.d b/gcc/d/dmd/aggregate.d
index 50fdc3b..1306a10 100644
--- a/gcc/d/dmd/aggregate.d
+++ b/gcc/d/dmd/aggregate.d
@@ -4,7 +4,7 @@
* Specification: $(LINK2 https://dlang.org/spec/struct.html, Structs, Unions),
* $(LINK2 https://dlang.org/spec/class.html, Class).
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/aggregate.d, _aggregate.d)
@@ -34,6 +34,7 @@ import dmd.func;
import dmd.globals;
import dmd.id;
import dmd.identifier;
+import dmd.location;
import dmd.mtype;
import dmd.tokens;
import dmd.typesem : defaultInit;
@@ -206,7 +207,7 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
//printf("AggregateDeclaration::determineSize() %s, sizeok = %d\n", toChars(), sizeok);
// The previous instance size finalizing had:
- if (type.ty == Terror)
+ if (type.ty == Terror || errors)
return false; // failed already
if (sizeok == Sizeok.done)
return true; // succeeded
diff --git a/gcc/d/dmd/aggregate.h b/gcc/d/dmd/aggregate.h
index d4432b5..9f9098f 100644
--- a/gcc/d/dmd/aggregate.h
+++ b/gcc/d/dmd/aggregate.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
@@ -41,13 +41,6 @@ enum class Baseok : uint8_t
semanticdone // all base classes semantic done
};
-enum class ThreeState : uint8_t
-{
- none, // value not yet computed
- no, // value is false
- yes, // value is true
-};
-
FuncDeclaration *search_toString(StructDeclaration *sd);
enum class ClassKind : uint8_t
diff --git a/gcc/d/dmd/aliasthis.d b/gcc/d/dmd/aliasthis.d
index 2771071b..ef839fa 100644
--- a/gcc/d/dmd/aliasthis.d
+++ b/gcc/d/dmd/aliasthis.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/class.html#alias-this, Alias This)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/aliasthis.d, _aliasthis.d)
@@ -21,6 +21,7 @@ import dmd.expression;
import dmd.expressionsem;
import dmd.globals;
import dmd.identifier;
+import dmd.location;
import dmd.mtype;
import dmd.opover;
import dmd.tokens;
@@ -94,7 +95,7 @@ Expression resolveAliasThis(Scope* sc, Expression e, bool gag = false, bool find
Type tthis = (e.op == EXP.type ? e.type : null);
const flags = DotExpFlag.noAliasThis | (gag ? DotExpFlag.gag : 0);
uint olderrors = gag ? global.startGagging() : 0;
- e = dotExp(e.type, sc, e, ad.aliasthis.ident, flags);
+ e = dotExp(ad.type, sc, e, ad.aliasthis.ident, flags);
if (!e || findOnly)
return gag && global.endGagging(olderrors) ? null : e;
diff --git a/gcc/d/dmd/aliasthis.h b/gcc/d/dmd/aliasthis.h
index c63d717..389cff4 100644
--- a/gcc/d/dmd/aliasthis.h
+++ b/gcc/d/dmd/aliasthis.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 2009-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 2009-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/apply.d b/gcc/d/dmd/apply.d
index 3b73771..f5855c4 100644
--- a/gcc/d/dmd/apply.d
+++ b/gcc/d/dmd/apply.d
@@ -1,7 +1,7 @@
/**
* A depth-first visitor for expressions.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/apply.d, _apply.d)
diff --git a/gcc/d/dmd/arrayop.d b/gcc/d/dmd/arrayop.d
index f07a6f4..da2f800 100644
--- a/gcc/d/dmd/arrayop.d
+++ b/gcc/d/dmd/arrayop.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/arrays.html#array-operations, Array Operations)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/arrayop.d, _arrayop.d)
@@ -26,6 +26,7 @@ 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;
diff --git a/gcc/d/dmd/arraytypes.d b/gcc/d/dmd/arraytypes.d
index 29b3a3d..34ffa6e 100644
--- a/gcc/d/dmd/arraytypes.d
+++ b/gcc/d/dmd/arraytypes.d
@@ -1,7 +1,7 @@
/**
* Provide aliases for arrays of certain declarations or statements.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/arraytypes.d, _arraytypes.d)
diff --git a/gcc/d/dmd/arraytypes.h b/gcc/d/dmd/arraytypes.h
index ca2051c..05126a5 100644
--- a/gcc/d/dmd/arraytypes.h
+++ b/gcc/d/dmd/arraytypes.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 2006-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 2006-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/ast_node.d b/gcc/d/dmd/ast_node.d
index 843cc02..c0dd186 100644
--- a/gcc/d/dmd/ast_node.d
+++ b/gcc/d/dmd/ast_node.d
@@ -1,7 +1,7 @@
/**
* Defines the base class for all nodes which are part of the AST.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/ast_node.d, _ast_node.d)
diff --git a/gcc/d/dmd/ast_node.h b/gcc/d/dmd/ast_node.h
index 0e04e38..6154c6d 100644
--- a/gcc/d/dmd/ast_node.h
+++ b/gcc/d/dmd/ast_node.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/astenums.d b/gcc/d/dmd/astenums.d
index 091e96a..6e88208 100644
--- a/gcc/d/dmd/astenums.d
+++ b/gcc/d/dmd/astenums.d
@@ -1,7 +1,7 @@
/**
* Defines enums common to dmd and dmd as parse library.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/astenums.d, _astenums.d)
* Documentation: https://dlang.org/phobos/dmd_astenums.html
diff --git a/gcc/d/dmd/attrib.d b/gcc/d/dmd/attrib.d
index 55d69b5..712099e 100644
--- a/gcc/d/dmd/attrib.d
+++ b/gcc/d/dmd/attrib.d
@@ -14,7 +14,7 @@
* - Protection (`private`, `public`)
* - Deprecated declarations (`@deprecated`)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/attrib.d, _attrib.d)
@@ -40,6 +40,7 @@ import dmd.globals;
import dmd.hdrgen : visibilityToBuffer;
import dmd.id;
import dmd.identifier;
+import dmd.location;
import dmd.mtype;
import dmd.objc; // for objc.addSymbols
import dmd.common.outbuffer;
diff --git a/gcc/d/dmd/attrib.h b/gcc/d/dmd/attrib.h
index b153229..96c46e8 100644
--- a/gcc/d/dmd/attrib.h
+++ b/gcc/d/dmd/attrib.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/blockexit.d b/gcc/d/dmd/blockexit.d
index 6456876..6369b5a 100644
--- a/gcc/d/dmd/blockexit.d
+++ b/gcc/d/dmd/blockexit.d
@@ -1,7 +1,7 @@
/**
* Find out in what ways control flow can exit a statement block.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/blockexit.d, _blockexit.d)
@@ -23,6 +23,7 @@ import dmd.func;
import dmd.globals;
import dmd.id;
import dmd.identifier;
+import dmd.location;
import dmd.mtype;
import dmd.statement;
import dmd.tokens;
diff --git a/gcc/d/dmd/builtin.d b/gcc/d/dmd/builtin.d
index 06db97b..27ba1e0 100644
--- a/gcc/d/dmd/builtin.d
+++ b/gcc/d/dmd/builtin.d
@@ -3,7 +3,7 @@
*
* Currently includes functions from `std.math`, `core.math` and `core.bitop`.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/builtin.d, _builtin.d)
@@ -16,7 +16,7 @@ module dmd.builtin;
import dmd.arraytypes;
import dmd.expression;
import dmd.func;
-import dmd.globals;
+import dmd.location;
/**********************************
* Determine if function is a builtin one that we can
diff --git a/gcc/d/dmd/canthrow.d b/gcc/d/dmd/canthrow.d
index cb9289f..7c18040 100644
--- a/gcc/d/dmd/canthrow.d
+++ b/gcc/d/dmd/canthrow.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/function.html#nothrow-functions, Nothrow Functions)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/canthrow.d, _canthrow.d)
diff --git a/gcc/d/dmd/chkformat.d b/gcc/d/dmd/chkformat.d
index 8204961..21a1b5e 100644
--- a/gcc/d/dmd/chkformat.d
+++ b/gcc/d/dmd/chkformat.d
@@ -1,7 +1,7 @@
/**
* Check the arguments to `printf` and `scanf` against the `format` string.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/chkformat.d, _chkformat.d)
@@ -19,6 +19,7 @@ import dmd.errors;
import dmd.expression;
import dmd.globals;
import dmd.identifier;
+import dmd.location;
import dmd.mtype;
import dmd.target;
diff --git a/gcc/d/dmd/clone.d b/gcc/d/dmd/clone.d
index c030d35..ef5464d 100644
--- a/gcc/d/dmd/clone.d
+++ b/gcc/d/dmd/clone.d
@@ -2,7 +2,7 @@
* Builds struct member functions if needed and not defined by the user.
* Includes `opEquals`, `opAssign`, post blit, copy constructor and destructor.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/clone.d, _clone.d)
@@ -31,6 +31,7 @@ import dmd.globals;
import dmd.id;
import dmd.identifier;
import dmd.init;
+import dmd.location;
import dmd.mtype;
import dmd.opover;
import dmd.semantic2;
diff --git a/gcc/d/dmd/common/bitfields.d b/gcc/d/dmd/common/bitfields.d
index bba61ad..b9fcb09 100644
--- a/gcc/d/dmd/common/bitfields.d
+++ b/gcc/d/dmd/common/bitfields.d
@@ -1,7 +1,7 @@
/**
* A library bitfields utility
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: Dennis Korpel
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/common/bitfields.d, common/bitfields.d)
diff --git a/gcc/d/dmd/common/file.d b/gcc/d/dmd/common/file.d
index 89e7027..ae13c41 100644
--- a/gcc/d/dmd/common/file.d
+++ b/gcc/d/dmd/common/file.d
@@ -4,7 +4,7 @@
* Functions and objects dedicated to file I/O and management. TODO: Move here artifacts
* from places such as root/ so both the frontend and the backend have access to them.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: Walter Bright, https://www.digitalmars.com
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/common/file.d, common/_file.d)
diff --git a/gcc/d/dmd/common/outbuffer.d b/gcc/d/dmd/common/outbuffer.d
index 9d544a4..276928a 100644
--- a/gcc/d/dmd/common/outbuffer.d
+++ b/gcc/d/dmd/common/outbuffer.d
@@ -1,7 +1,7 @@
/**
* An expandable buffer in which you can write text or binary data.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: Walter Bright, https://www.digitalmars.com
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/outbuffer.d, root/_outbuffer.d)
diff --git a/gcc/d/dmd/common/outbuffer.h b/gcc/d/dmd/common/outbuffer.h
index fed25c0..b672842 100644
--- a/gcc/d/dmd/common/outbuffer.h
+++ b/gcc/d/dmd/common/outbuffer.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+/* Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/common/string.d b/gcc/d/dmd/common/string.d
index 48bf9bb..1111cec 100644
--- a/gcc/d/dmd/common/string.d
+++ b/gcc/d/dmd/common/string.d
@@ -1,7 +1,7 @@
/**
* Common string functions including filename manipulation.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: Walter Bright, https://www.digitalmars.com
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/common/string.d, common/_string.d)
diff --git a/gcc/d/dmd/compiler.d b/gcc/d/dmd/compiler.d
index dd26d40..68ec1d3 100644
--- a/gcc/d/dmd/compiler.d
+++ b/gcc/d/dmd/compiler.d
@@ -1,7 +1,7 @@
/**
* Describes a back-end compiler and implements compiler-specific actions.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/compiler.d, _compiler.d)
diff --git a/gcc/d/dmd/compiler.h b/gcc/d/dmd/compiler.h
index e8b7704..c7cbce3 100644
--- a/gcc/d/dmd/compiler.h
+++ b/gcc/d/dmd/compiler.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/cond.d b/gcc/d/dmd/cond.d
index c1e1e4d..c0c4cf1 100644
--- a/gcc/d/dmd/cond.d
+++ b/gcc/d/dmd/cond.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/version.html, Conditional Compilation)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/cond.d, _cond.d)
@@ -26,6 +26,7 @@ import dmd.expression;
import dmd.expressionsem;
import dmd.globals;
import dmd.identifier;
+import dmd.location;
import dmd.mtype;
import dmd.typesem;
import dmd.common.outbuffer;
@@ -80,6 +81,11 @@ extern (C++) abstract class Condition : ASTNode
return null;
}
+ inout(StaticIfCondition) isStaticIfCondition() inout
+ {
+ return null;
+ }
+
override void accept(Visitor v)
{
v.visit(this);
@@ -218,12 +224,12 @@ extern (C++) final class StaticForeach : RootObject
{
if (aggrfe)
{
- return new ForeachStatement(loc, aggrfe.op, parameters, aggrfe.aggr.syntaxCopy(), s, loc);
+ return new ForeachStatement(loc, aggrfe.op, parameters, aggrfe.aggr, s, loc);
}
else
{
assert(rangefe && parameters.length == 1);
- return new ForeachRangeStatement(loc, rangefe.op, (*parameters)[0], rangefe.lwr.syntaxCopy(), rangefe.upr.syntaxCopy(), s, loc);
+ return new ForeachRangeStatement(loc, rangefe.op, (*parameters)[0], rangefe.lwr, rangefe.upr, s, loc);
}
}
@@ -953,6 +959,11 @@ extern (C++) final class StaticIfCondition : Condition
v.visit(this);
}
+ override inout(StaticIfCondition) isStaticIfCondition() inout
+ {
+ return this;
+ }
+
override const(char)* toChars() const
{
return exp ? exp.toChars() : "static if".ptr;
diff --git a/gcc/d/dmd/cond.h b/gcc/d/dmd/cond.h
index b33f288..422a715 100644
--- a/gcc/d/dmd/cond.h
+++ b/gcc/d/dmd/cond.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/constfold.d b/gcc/d/dmd/constfold.d
index ef684ba..79bbd5d 100644
--- a/gcc/d/dmd/constfold.d
+++ b/gcc/d/dmd/constfold.d
@@ -5,7 +5,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/float.html#fp_const_folding, Floating Point Constant Folding)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/constfold.d, _constfold.d)
@@ -25,6 +25,7 @@ import dmd.dstruct;
import dmd.errors;
import dmd.expression;
import dmd.globals;
+import dmd.location;
import dmd.mtype;
import dmd.root.complex;
import dmd.root.ctfloat;
@@ -1249,7 +1250,14 @@ UnionExp Slice(Type type, Expression e1, Expression lwr, Expression upr)
}
}
- if (e1.op == EXP.string_ && lwr.op == EXP.int64 && upr.op == EXP.int64)
+ if (!lwr)
+ {
+ if (e1.op == EXP.string_)
+ emplaceExp(&ue, e1);
+ else
+ cantExp(ue);
+ }
+ else if (e1.op == EXP.string_ && lwr.op == EXP.int64 && upr.op == EXP.int64)
{
StringExp es1 = e1.isStringExp();
const uinteger_t ilwr = lwr.toInteger();
diff --git a/gcc/d/dmd/cparse.d b/gcc/d/dmd/cparse.d
index d4416ab..a6bc42b 100644
--- a/gcc/d/dmd/cparse.d
+++ b/gcc/d/dmd/cparse.d
@@ -3,7 +3,7 @@
*
* Specification: C11
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/cparse.d, _cparse.d)
@@ -20,6 +20,7 @@ import dmd.globals;
import dmd.id;
import dmd.identifier;
import dmd.lexer;
+import dmd.location;
import dmd.parse;
import dmd.errors;
import dmd.root.array;
diff --git a/gcc/d/dmd/cppmangle.d b/gcc/d/dmd/cppmangle.d
index fbe9f01..d3effa99 100644
--- a/gcc/d/dmd/cppmangle.d
+++ b/gcc/d/dmd/cppmangle.d
@@ -4,7 +4,7 @@
* This is the POSIX side of the implementation.
* It exports two functions to C++, `toCppMangleItanium` and `cppTypeInfoMangleItanium`.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: Walter Bright, https://www.digitalmars.com
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/cppmangle.d, _cppmangle.d)
@@ -38,6 +38,7 @@ import dmd.func;
import dmd.globals;
import dmd.id;
import dmd.identifier;
+import dmd.location;
import dmd.mtype;
import dmd.nspace;
import dmd.root.array;
diff --git a/gcc/d/dmd/ctfe.h b/gcc/d/dmd/ctfe.h
index ab022ff..1071edf 100644
--- a/gcc/d/dmd/ctfe.h
+++ b/gcc/d/dmd/ctfe.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/ctfeexpr.d b/gcc/d/dmd/ctfeexpr.d
index 1dc1f7d..c902149 100644
--- a/gcc/d/dmd/ctfeexpr.d
+++ b/gcc/d/dmd/ctfeexpr.d
@@ -1,7 +1,7 @@
/**
* CTFE for expressions involving pointers, slices, array concatenation etc.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/ctfeexpr.d, _ctfeexpr.d)
@@ -27,6 +27,7 @@ import dmd.errors;
import dmd.expression;
import dmd.func;
import dmd.globals;
+import dmd.location;
import dmd.mtype;
import dmd.root.complex;
import dmd.root.ctfloat;
diff --git a/gcc/d/dmd/ctorflow.d b/gcc/d/dmd/ctorflow.d
index c04793d..a3953af 100644
--- a/gcc/d/dmd/ctorflow.d
+++ b/gcc/d/dmd/ctorflow.d
@@ -1,7 +1,7 @@
/**
* Manage flow analysis for constructors.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/ctorflow.d, _ctorflow.d)
@@ -14,7 +14,7 @@ module dmd.ctorflow;
import core.stdc.stdio;
import dmd.root.rmem;
-import dmd.globals : Loc;
+import dmd.location;
enum CSX : ushort
{
diff --git a/gcc/d/dmd/dcast.d b/gcc/d/dmd/dcast.d
index 02bf6cf..b305360 100644
--- a/gcc/d/dmd/dcast.d
+++ b/gcc/d/dmd/dcast.d
@@ -1,7 +1,7 @@
/**
* Semantic analysis for cast-expressions.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/dcast.d, _dcast.d)
@@ -30,6 +30,7 @@ import dmd.expressionsem;
import dmd.func;
import dmd.globals;
import dmd.hdrgen;
+import dmd.location;
import dmd.impcnvtab;
import dmd.id;
import dmd.importc;
@@ -66,10 +67,14 @@ Expression implicitCastTo(Expression e, Scope* sc, Type t)
{
Expression visit(Expression e)
{
- //printf("Expression.implicitCastTo(%s of type %s) => %s\n", e.toChars(), e.type.toChars(), t.toChars());
+ // printf("Expression.implicitCastTo(%s of type %s) => %s\n", e.toChars(), e.type.toChars(), t.toChars());
if (const match = (sc && sc.flags & SCOPE.Cfile) ? e.cimplicitConvTo(t) : e.implicitConvTo(t))
{
+ if (match == MATCH.convert && e.type.isTypeNoreturn())
+ {
+ return specialNoreturnCast(e, t);
+ }
if (match == MATCH.constant && (e.type.constConv(t) || !e.isLvalue() && e.type.equivalent(t)))
{
/* Do not emit CastExp for const conversions and
@@ -1526,6 +1531,10 @@ Expression castTo(Expression e, Scope* sc, Type t, Type att = null)
{
return e;
}
+ if (e.type.isTypeNoreturn())
+ {
+ return specialNoreturnCast(e, t);
+ }
if (auto ve = e.isVarExp())
{
VarDeclaration v = ve.var.isVarDeclaration();
@@ -2539,7 +2548,12 @@ Expression castTo(Expression e, Scope* sc, Type t, Type att = null)
// Handle the cast from Tarray to Tsarray with CT-known slicing
- TypeSArray tsa = toStaticArrayType(e).isTypeSArray();
+ TypeSArray tsa;
+ {
+ Type t = toStaticArrayType(e);
+ tsa = t ? t.isTypeSArray() : null;
+ }
+
if (tsa && tsa.size(e.loc) == tb.size(e.loc))
{
/* Match if the sarray sizes are equal:
@@ -3858,3 +3872,21 @@ IntRange getIntRange(Expression e)
case EXP.negate : return visitNeg(e.isNegExp());
}
}
+/**
+ * A helper function to "cast" from expressions of type noreturn to
+ * any other type - noreturn is implicitly convertible to any other type.
+ * However, the dmd backend does not like a naive cast from a noreturn expression
+ * (particularly an `assert(0)`) so this function generates:
+ *
+ * `(assert(0), value)` instead of `cast(to)(assert(0))`.
+ *
+ * `value` is currently `to.init` however it cannot be read so could be made simpler.
+ * Params:
+ * toBeCasted = Expression of type noreturn to cast
+ * to = Type to cast the expression to.
+ * Returns: A CommaExp, upon any failure ErrorExp will be returned.
+ */
+Expression specialNoreturnCast(Expression toBeCasted, Type to)
+{
+ return Expression.combine(toBeCasted, to.defaultInitLiteral(toBeCasted.loc));
+}
diff --git a/gcc/d/dmd/dclass.d b/gcc/d/dmd/dclass.d
index fc49b21..1fdd073 100644
--- a/gcc/d/dmd/dclass.d
+++ b/gcc/d/dmd/dclass.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/class.html, Classes)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/dclass.d, _dclass.d)
@@ -30,6 +30,7 @@ import dmd.func;
import dmd.globals;
import dmd.id;
import dmd.identifier;
+import dmd.location;
import dmd.mtype;
import dmd.objc;
import dmd.root.rmem;
@@ -468,7 +469,7 @@ extern (C++) class ClassDeclaration : AggregateDeclaration
{
//printf("%s.ClassDeclaration.search('%s', flags=x%x)\n", toChars(), ident.toChars(), flags);
//if (_scope) printf("%s baseok = %d\n", toChars(), baseok);
- if (_scope && baseok < Baseok.done)
+ if (_scope && baseok < Baseok.semanticdone)
{
if (!inuse)
{
diff --git a/gcc/d/dmd/declaration.d b/gcc/d/dmd/declaration.d
index 3d0752c..51737ce 100644
--- a/gcc/d/dmd/declaration.d
+++ b/gcc/d/dmd/declaration.d
@@ -2,7 +2,7 @@
* Miscellaneous declarations, including typedef, alias, variable declarations including the
* implicit this declaration, type tuples, ClassInfo, ModuleInfo and various TypeInfos.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/declaration.d, _declaration.d)
@@ -35,6 +35,7 @@ import dmd.identifier;
import dmd.init;
import dmd.initsem;
import dmd.intrange;
+import dmd.location;
import dmd.mtype;
import dmd.common.outbuffer;
import dmd.root.rootobject;
@@ -81,6 +82,9 @@ bool checkFrameAccess(Loc loc, Scope* sc, AggregateDeclaration ad, size_t iStart
/***********************************************
* Mark variable v as modified if it is inside a constructor that var
* is a field in.
+ * Also used to allow immutable globals to be initialized inside a static constructor.
+ * Returns:
+ * true if it's an initialization of v
*/
bool modifyFieldVar(Loc loc, Scope* sc, VarDeclaration var, Expression e1)
{
@@ -93,7 +97,7 @@ bool modifyFieldVar(Loc loc, Scope* sc, VarDeclaration var, Expression e1)
fd = s.isFuncDeclaration();
if (fd &&
((fd.isCtorDeclaration() && var.isField()) ||
- (fd.isStaticCtorDeclaration() && !var.isField())) &&
+ ((fd.isStaticCtorDeclaration() || fd.isCrtCtor) && !var.isField())) &&
fd.toParentDecl() == var.toParent2() &&
(!e1 || e1.op == EXP.this_))
{
diff --git a/gcc/d/dmd/declaration.h b/gcc/d/dmd/declaration.h
index 2668b6e..5d5c423 100644
--- a/gcc/d/dmd/declaration.h
+++ b/gcc/d/dmd/declaration.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/delegatize.d b/gcc/d/dmd/delegatize.d
index 461f441..3f982b3 100644
--- a/gcc/d/dmd/delegatize.d
+++ b/gcc/d/dmd/delegatize.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/function.html#lazy-params, Lazy Parameters)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/delegatize.d, _delegatize.d)
@@ -25,6 +25,7 @@ import dmd.func;
import dmd.globals;
import dmd.init;
import dmd.initsem;
+import dmd.location;
import dmd.mtype;
import dmd.statement;
import dmd.tokens;
diff --git a/gcc/d/dmd/denum.d b/gcc/d/dmd/denum.d
index 926186b..221250b 100644
--- a/gcc/d/dmd/denum.d
+++ b/gcc/d/dmd/denum.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/enum.html, Enums)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/denum.d, _denum.d)
@@ -28,6 +28,7 @@ import dmd.globals;
import dmd.id;
import dmd.identifier;
import dmd.init;
+import dmd.location;
import dmd.mtype;
import dmd.tokens;
import dmd.typesem;
diff --git a/gcc/d/dmd/dimport.d b/gcc/d/dmd/dimport.d
index 1104005..b653d9b 100644
--- a/gcc/d/dmd/dimport.d
+++ b/gcc/d/dmd/dimport.d
@@ -1,7 +1,7 @@
/**
* A `Dsymbol` representing a renamed import.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/dimport.d, _dimport.d)
@@ -22,6 +22,7 @@ import dmd.errors;
import dmd.expression;
import dmd.globals;
import dmd.identifier;
+import dmd.location;
import dmd.mtype;
import dmd.visitor;
diff --git a/gcc/d/dmd/dinterpret.d b/gcc/d/dmd/dinterpret.d
index e504cb4..7920df7 100644
--- a/gcc/d/dmd/dinterpret.d
+++ b/gcc/d/dmd/dinterpret.d
@@ -3,7 +3,7 @@
*
* Specification: ($LINK2 https://dlang.org/spec/function.html#interpretation, Compile Time Function Execution (CTFE))
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/dinterpret.d, _dinterpret.d)
@@ -39,6 +39,7 @@ import dmd.id;
import dmd.identifier;
import dmd.init;
import dmd.initsem;
+import dmd.location;
import dmd.mtype;
import dmd.printast;
import dmd.root.rmem;
@@ -165,7 +166,7 @@ public Expression ctfeInterpretForPragmaMsg(Expression e)
return e;
}
-public extern (C++) Expression getValue(VarDeclaration vd)
+public Expression getValue(VarDeclaration vd)
{
return ctfeGlobals.stack.getValue(vd);
}
@@ -280,25 +281,25 @@ private:
Expression localThis; // value of 'this', or NULL if none
public:
- extern (C++) size_t stackPointer()
+ size_t stackPointer()
{
return values.length;
}
// The current value of 'this', or NULL if none
- extern (C++) Expression getThis()
+ Expression getThis()
{
return localThis;
}
// Largest number of stack positions we've used
- extern (C++) size_t maxStackUsage()
+ size_t maxStackUsage()
{
return maxStackPointer;
}
// Start a new stack frame, using the provided 'this'.
- extern (C++) void startFrame(Expression thisexp)
+ void startFrame(Expression thisexp)
{
frames.push(cast(void*)cast(size_t)framepointer);
savedThis.push(localThis);
@@ -306,7 +307,7 @@ public:
localThis = thisexp;
}
- extern (C++) void endFrame()
+ void endFrame()
{
size_t oldframe = cast(size_t)frames[frames.length - 1];
localThis = savedThis[savedThis.length - 1];
@@ -316,14 +317,14 @@ public:
savedThis.setDim(savedThis.length - 1);
}
- extern (C++) bool isInCurrentFrame(VarDeclaration v)
+ bool isInCurrentFrame(VarDeclaration v)
{
if (v.isDataseg() && !v.isCTFE())
return false; // It's a global
return v.ctfeAdrOnStack >= framepointer;
}
- extern (C++) Expression getValue(VarDeclaration v)
+ Expression getValue(VarDeclaration v)
{
//printf("getValue() %s\n", v.toChars());
if ((v.isDataseg() || v.storage_class & STC.manifest) && !v.isCTFE())
@@ -335,7 +336,7 @@ public:
return values[v.ctfeAdrOnStack];
}
- extern (C++) void setValue(VarDeclaration v, Expression e)
+ void setValue(VarDeclaration v, Expression e)
{
//printf("setValue() %s : %s\n", v.toChars(), e.toChars());
assert(!v.isDataseg() || v.isCTFE());
@@ -343,7 +344,7 @@ public:
values[v.ctfeAdrOnStack] = e;
}
- extern (C++) void push(VarDeclaration v)
+ void push(VarDeclaration v)
{
//printf("push() %s\n", v.toChars());
assert(!v.isDataseg() || v.isCTFE());
@@ -359,7 +360,7 @@ public:
values.push(null);
}
- extern (C++) void pop(VarDeclaration v)
+ void pop(VarDeclaration v)
{
assert(!v.isDataseg() || v.isCTFE());
assert(!v.isReference());
@@ -373,7 +374,7 @@ public:
}
}
- extern (C++) void popAll(size_t stackpointer)
+ void popAll(size_t stackpointer)
{
if (stackPointer() > maxStackPointer)
maxStackPointer = stackPointer();
@@ -388,7 +389,7 @@ public:
savedId.setDim(stackpointer);
}
- extern (C++) void saveGlobalConstant(VarDeclaration v, Expression e)
+ void saveGlobalConstant(VarDeclaration v, Expression e)
{
assert(v._init && (v.isConst() || v.isImmutable() || v.storage_class & STC.manifest) && !v.isCTFE());
v.ctfeAdrOnStack = cast(uint)globalValues.length;
@@ -1529,7 +1530,7 @@ public:
}
// Little sanity check to make sure it's really a Throwable
ClassReferenceExp boss = oldest.thrown;
- const next = 4; // index of Throwable.next
+ const next = 5; // index of Throwable.next
assert((*boss.value.elements)[next].type.ty == Tclass); // Throwable.next
ClassReferenceExp collateral = newest.thrown;
if (collateral.originalClass().isErrorException() && !boss.originalClass().isErrorException())
@@ -1849,10 +1850,27 @@ public:
{
printf("%s StringExp::interpret() %s\n", e.loc.toChars(), e.toChars());
}
- /* Attempts to modify string literals are prevented
- * in BinExp::interpretAssignCommon.
- */
- result = e;
+ if (e.ownedByCtfe >= OwnedBy.ctfe) // We've already interpreted the string
+ {
+ result = e;
+ return;
+ }
+
+ if (e.type.ty != Tsarray ||
+ (cast(TypeNext)e.type).next.mod & (MODFlags.const_ | MODFlags.immutable_))
+ {
+ // If it's immutable, we don't need to dup it. Attempts to modify
+ // string literals are prevented in BinExp::interpretAssignCommon.
+ result = e;
+ }
+ else
+ {
+ // https://issues.dlang.org/show_bug.cgi?id=20811
+ // Create a copy of mutable string literals, so that any change in
+ // value via an index or slice will not survive CTFE.
+ *pue = copyLiteral(e);
+ result = pue.exp();
+ }
}
override void visit(FuncExp e)
@@ -4287,12 +4305,12 @@ public:
bool needsPostblit;
bool needsDtor;
- extern (C++) Expression assignTo(ArrayLiteralExp ae)
+ Expression assignTo(ArrayLiteralExp ae)
{
return assignTo(ae, 0, ae.elements.length);
}
- extern (C++) Expression assignTo(ArrayLiteralExp ae, size_t lwr, size_t upr)
+ Expression assignTo(ArrayLiteralExp ae, size_t lwr, size_t upr)
{
Expressions* w = ae.elements;
assert(ae.type.ty == Tsarray || ae.type.ty == Tarray);
@@ -6178,7 +6196,7 @@ public:
{
debug (LOG)
{
- printf("%s ThrowExpression::interpret()\n", e.loc.toChars());
+ printf("%s ThrowExpression::interpret()\n", te.loc.toChars());
}
interpretThrow(te.e1, te.loc);
}
diff --git a/gcc/d/dmd/dmacro.d b/gcc/d/dmd/dmacro.d
index 358712b..6fc23e9 100644
--- a/gcc/d/dmd/dmacro.d
+++ b/gcc/d/dmd/dmacro.d
@@ -1,7 +1,7 @@
/**
* Text macro processor for Ddoc.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/dmacro.d, _dmacro.d)
diff --git a/gcc/d/dmd/dmangle.d b/gcc/d/dmd/dmangle.d
index 6ecaa52..867d3ca 100644
--- a/gcc/d/dmd/dmangle.d
+++ b/gcc/d/dmd/dmangle.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/abi.html#name_mangling, Name Mangling)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: Walter Bright, https://www.digitalmars.com
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/dmangle.d, _dmangle.d)
diff --git a/gcc/d/dmd/dmodule.d b/gcc/d/dmd/dmodule.d
index 6160805..e1234e5 100644
--- a/gcc/d/dmd/dmodule.d
+++ b/gcc/d/dmd/dmodule.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/module.html, Modules)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/dmodule.d, _dmodule.d)
@@ -35,6 +35,7 @@ import dmd.file_manager;
import dmd.globals;
import dmd.id;
import dmd.identifier;
+import dmd.location;
import dmd.parse;
import dmd.cparse;
import dmd.root.array;
@@ -359,7 +360,8 @@ extern (C++) final class Module : Package
Package pkg; // if isPackageFile is true, the Package that contains this package.d
Strings contentImportedFiles; // array of files whose content was imported
int needmoduleinfo;
- int selfimports; // 0: don't know, 1: does not, 2: does
+ private ThreeState selfimports;
+ private ThreeState rootimports;
Dsymbol[void*] tagSymTab; /// ImportC: tag symbols that conflict with other symbols used as the index
private OutBuffer defines; // collect all the #define lines here
@@ -371,48 +373,46 @@ extern (C++) final class Module : Package
bool selfImports()
{
//printf("Module::selfImports() %s\n", toChars());
- if (selfimports == 0)
+ if (selfimports == ThreeState.none)
{
foreach (Module m; amodules)
- m.insearch = 0;
- selfimports = imports(this) + 1;
+ m.insearch = false;
+ selfimports = imports(this) ? ThreeState.yes : ThreeState.no;
foreach (Module m; amodules)
- m.insearch = 0;
+ m.insearch = false;
}
- return selfimports == 2;
+ return selfimports == ThreeState.yes;
}
- int rootimports; // 0: don't know, 1: does not, 2: does
-
/*************************************
* Return true if module imports root module.
*/
bool rootImports()
{
//printf("Module::rootImports() %s\n", toChars());
- if (rootimports == 0)
+ if (rootimports == ThreeState.none)
{
foreach (Module m; amodules)
- m.insearch = 0;
- rootimports = 1;
+ m.insearch = false;
+ rootimports = ThreeState.no;
foreach (Module m; amodules)
{
if (m.isRoot() && imports(m))
{
- rootimports = 2;
+ rootimports = ThreeState.yes;
break;
}
}
foreach (Module m; amodules)
- m.insearch = 0;
+ m.insearch = false;
}
- return rootimports == 2;
+ return rootimports == ThreeState.yes;
}
- int insearch;
- Identifier searchCacheIdent;
- Dsymbol searchCacheSymbol; // cached value of search
- int searchCacheFlags; // cached flags
+ private Identifier searchCacheIdent;
+ private Dsymbol searchCacheSymbol; // cached value of search
+ private int searchCacheFlags; // cached flags
+ private bool insearch;
/**
* A root module is one that will be compiled all the way to
@@ -1041,9 +1041,9 @@ extern (C++) final class Module : Package
uint errors = global.errors;
- insearch = 1;
+ insearch = true;
Dsymbol s = ScopeDsymbol.search(loc, ident, flags);
- insearch = 0;
+ insearch = false;
if (errors == global.errors)
{
@@ -1214,7 +1214,7 @@ extern (C++) final class Module : Package
return true;
if (!mi.insearch)
{
- mi.insearch = 1;
+ mi.insearch = true;
int r = mi.imports(m);
if (r)
return r;
@@ -1284,6 +1284,59 @@ extern (C++) final class Module : Package
_escapetable = new Escape();
return _escapetable;
}
+
+ /****************************
+ * A Singleton that loads core.atomic
+ * Returns:
+ * Module of core.atomic, null if couldn't find it
+ */
+ extern (D) static Module loadCoreAtomic()
+ {
+ __gshared Module core_atomic;
+ return loadModuleFromLibrary(core_atomic, Id.core, Id.atomic);
+ }
+
+ /****************************
+ * A Singleton that loads std.math
+ * Returns:
+ * Module of std.math, null if couldn't find it
+ */
+ extern (D) static Module loadStdMath()
+ {
+ __gshared Module std_math;
+ return loadModuleFromLibrary(std_math, Id.std, Id.math);
+ }
+
+ /**********************************
+ * Load a Module from the library.
+ * Params:
+ * mod = cached return value of this call
+ * pkgid = package id
+ * modid = module id
+ * Returns:
+ * Module loaded, null if cannot load it
+ */
+ private static Module loadModuleFromLibrary(ref Module mod, Identifier pkgid, Identifier modid)
+ {
+ if (mod)
+ return mod;
+
+ auto ids = new Identifier[1];
+ ids[0] = pkgid;
+ auto imp = new Import(Loc.initial, ids[], modid, null, true);
+ // Module.load will call fatal() if there's no module available.
+ // Gag the error here, pushing the error handling to the caller.
+ const errors = global.startGagging();
+ imp.load(null);
+ if (imp.mod)
+ {
+ imp.mod.importAll(null);
+ imp.mod.dsymbolSemantic(null);
+ }
+ global.endGagging(errors);
+ mod = imp.mod;
+ return mod;
+ }
}
/***********************************************************
diff --git a/gcc/d/dmd/doc.d b/gcc/d/dmd/doc.d
index c04409c4..732a737 100644
--- a/gcc/d/dmd/doc.d
+++ b/gcc/d/dmd/doc.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/ddoc.html, Documentation Generator)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/doc.d, _doc.d)
@@ -41,6 +41,7 @@ import dmd.hdrgen;
import dmd.id;
import dmd.identifier;
import dmd.lexer;
+import dmd.location;
import dmd.mtype;
import dmd.root.array;
import dmd.root.file;
@@ -5181,7 +5182,8 @@ private void highlightCode2(Scope* sc, Dsymbols* a, ref OutBuffer buf, size_t of
{
uint errorsave = global.startGagging();
- scope Lexer lex = new Lexer(null, cast(char*)buf[].ptr, 0, buf.length - 1, 0, 1);
+ scope Lexer lex = new Lexer(null, cast(char*)buf[].ptr, 0, buf.length - 1, 0, 1,
+ global.vendor, global.versionNumber());
OutBuffer res;
const(char)* lastp = cast(char*)buf[].ptr;
//printf("highlightCode2('%.*s')\n", cast(int)(buf.length - 1), buf[].ptr);
diff --git a/gcc/d/dmd/doc.h b/gcc/d/dmd/doc.h
index 8dc2d9f..d16806b 100644
--- a/gcc/d/dmd/doc.h
+++ b/gcc/d/dmd/doc.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/dscope.d b/gcc/d/dmd/dscope.d
index 362e7f2..8f19626 100644
--- a/gcc/d/dmd/dscope.d
+++ b/gcc/d/dmd/dscope.d
@@ -3,7 +3,7 @@
*
* Not to be confused with the `scope` storage class.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/dscope.d, _dscope.d)
@@ -33,6 +33,7 @@ import dmd.func;
import dmd.globals;
import dmd.id;
import dmd.identifier;
+import dmd.location;
import dmd.common.outbuffer;
import dmd.root.rmem;
import dmd.root.speller;
diff --git a/gcc/d/dmd/dstruct.d b/gcc/d/dmd/dstruct.d
index 2115fda..6ab93d4 100644
--- a/gcc/d/dmd/dstruct.d
+++ b/gcc/d/dmd/dstruct.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/struct.html, Structs, Unions)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/dstruct.d, _dstruct.d)
@@ -29,6 +29,7 @@ import dmd.func;
import dmd.globals;
import dmd.id;
import dmd.identifier;
+import dmd.location;
import dmd.mtype;
import dmd.opover;
import dmd.target;
diff --git a/gcc/d/dmd/dsymbol.d b/gcc/d/dmd/dsymbol.d
index 2cf5500..3611e09 100644
--- a/gcc/d/dmd/dsymbol.d
+++ b/gcc/d/dmd/dsymbol.d
@@ -1,7 +1,7 @@
/**
* The base class for a D symbol, which can be a module, variable, function, enum, etc.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/dsymbol.d, _dsymbol.d)
@@ -42,6 +42,7 @@ import dmd.id;
import dmd.identifier;
import dmd.init;
import dmd.lexer;
+import dmd.location;
import dmd.mtype;
import dmd.nspace;
import dmd.opover;
diff --git a/gcc/d/dmd/dsymbol.h b/gcc/d/dmd/dsymbol.h
index 3e9b634..88110e1 100644
--- a/gcc/d/dmd/dsymbol.h
+++ b/gcc/d/dmd/dsymbol.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
@@ -87,6 +87,13 @@ struct Ungag
~Ungag() { global.gag = oldgag; }
};
+enum class ThreeState : uint8_t
+{
+ none, // value not yet computed
+ no, // value is false
+ yes, // value is true
+};
+
void dsymbolSemantic(Dsymbol *dsym, Scope *sc);
void semantic2(Dsymbol *dsym, Scope *sc);
void semantic3(Dsymbol *dsym, Scope* sc);
diff --git a/gcc/d/dmd/dsymbolsem.d b/gcc/d/dmd/dsymbolsem.d
index b842dc8..49e1c59 100644
--- a/gcc/d/dmd/dsymbolsem.d
+++ b/gcc/d/dmd/dsymbolsem.d
@@ -2,7 +2,7 @@
* Does the semantic 1 pass on the AST, which looks at symbol declarations but not initializers
* or function bodies.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/dsymbolsem.d, _dsymbolsem.d)
@@ -51,6 +51,7 @@ import dmd.init;
import dmd.initsem;
import dmd.intrange;
import dmd.hdrgen;
+import dmd.location;
import dmd.mtype;
import dmd.mustuse;
import dmd.nogc;
@@ -1594,6 +1595,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
if (pd.ident == Id.printf || pd.ident == Id.scanf)
{
s.setPragmaPrintf(pd.ident == Id.printf);
+ s.dsymbolSemantic(sc2);
continue;
}
@@ -2310,6 +2312,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
auto inneruda = em.userAttribDecl.userAttribDecl;
em.userAttribDecl.setScope(sc);
em.userAttribDecl.userAttribDecl = inneruda;
+ em.userAttribDecl.dsymbolSemantic(sc);
}
// The first enum member is special
@@ -2464,8 +2467,11 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
e = e.ctfeInterpret();
if (e.toInteger())
{
+ auto mt = em.ed.memtype;
+ if (!mt)
+ mt = eprev.type;
em.error("initialization with `%s.%s+1` causes overflow for type `%s`",
- emprev.ed.toChars(), emprev.toChars(), em.ed.memtype.toChars());
+ emprev.ed.toChars(), emprev.toChars(), mt.toChars());
return errorReturn();
}
@@ -5165,6 +5171,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
}
// Copy vtbl[] from base class
+ assert(cldec.vtbl.length == 0);
cldec.vtbl.setDim(cldec.baseClass.vtbl.length);
memcpy(cldec.vtbl.tdata(), cldec.baseClass.vtbl.tdata(), (void*).sizeof * cldec.vtbl.length);
@@ -5205,7 +5212,6 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
cldec.baseClass.toChars(),
cldec.baseClass.toParentLocal().toChars());
}
- cldec.enclosing = null;
}
if (cldec.vthis2)
{
@@ -5378,10 +5384,11 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
cldec.error("already exists at %s. Perhaps in another function with the same name?", cd.loc.toChars());
}
- if (global.errors != errors)
+ if (global.errors != errors || (cldec.baseClass && cldec.baseClass.errors))
{
- // The type is no good.
- cldec.type = Type.terror;
+ // The type is no good, but we should keep the
+ // the type so that we have more accurate error messages
+ // See: https://issues.dlang.org/show_bug.cgi?id=23552
cldec.errors = true;
if (cldec.deferred)
cldec.deferred.errors = true;
@@ -7073,33 +7080,13 @@ bool determineFields(AggregateDeclaration ad)
/// Do an atomic operation (currently tailored to [shared] static ctors|dtors) needs
private CallExp doAtomicOp (string op, Identifier var, Expression arg)
{
- __gshared Import imp = null;
- __gshared Identifier[1] id;
-
assert(op == "-=" || op == "+=");
- const loc = Loc.initial;
+ Module mod = Module.loadCoreAtomic();
+ if (!mod)
+ return null; // core.atomic couldn't be loaded
- // Below code is similar to `loadStdMath` (used for `^^` operator)
- if (!imp)
- {
- id[0] = Id.core;
- auto s = new Import(Loc.initial, id[], Id.atomic, null, true);
- // Module.load will call fatal() if there's no std.math available.
- // Gag the error here, pushing the error handling to the caller.
- uint errors = global.startGagging();
- s.load(null);
- if (s.mod)
- {
- s.mod.importAll(null);
- s.mod.dsymbolSemantic(null);
- }
- global.endGagging(errors);
- imp = s;
- }
- // Module couldn't be loaded
- if (imp.mod is null)
- return null;
+ const loc = Loc.initial;
Objects* tiargs = new Objects(1);
(*tiargs)[0] = new StringExp(loc, op);
@@ -7108,7 +7095,7 @@ private CallExp doAtomicOp (string op, Identifier var, Expression arg)
(*args)[0] = new IdentifierExp(loc, var);
(*args)[1] = arg;
- auto sc = new ScopeExp(loc, imp.mod);
+ auto sc = new ScopeExp(loc, mod);
auto dti = new DotTemplateInstanceExp(
loc, sc, Id.atomicOp, tiargs);
diff --git a/gcc/d/dmd/dtemplate.d b/gcc/d/dmd/dtemplate.d
index 6095dcc..32799aa 100644
--- a/gcc/d/dmd/dtemplate.d
+++ b/gcc/d/dmd/dtemplate.d
@@ -28,7 +28,7 @@
* arguments, and uses it if found.
* - Otherwise, the rest of semantic is run on the `TemplateInstance`.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/dtemplate.d, _dtemplate.d)
@@ -64,6 +64,7 @@ import dmd.identifier;
import dmd.impcnvtab;
import dmd.init;
import dmd.initsem;
+import dmd.location;
import dmd.mtype;
import dmd.opover;
import dmd.root.array;
@@ -567,7 +568,6 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol
bool isTrivialAlias; /// matches pattern `template Alias(T) { alias Alias = qualifiers(T); }`
bool deprecated_; /// this template declaration is deprecated
Visibility visibility;
- int inuse; /// for recursive expansion detection
// threaded list of previous instantiation attempts on stack
TemplatePrevious* previous;
@@ -1117,9 +1117,7 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol
printf("\tparameter[%d] is %s : %s\n", i, tp.ident.toChars(), ttp.specType ? ttp.specType.toChars() : "");
}
- inuse++;
m2 = tp.matchArg(ti.loc, paramscope, ti.tiargs, i, parameters, dedtypes, &sparam);
- inuse--;
//printf("\tm2 = %d\n", m2);
if (m2 == MATCH.nomatch)
{
@@ -1783,9 +1781,7 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol
}
else
{
- inuse++;
oded = tparam.defaultArg(instLoc, paramscope);
- inuse--;
if (oded)
(*dedargs)[i] = declareParameter(paramscope, tparam, oded);
}
@@ -2166,9 +2162,7 @@ extern (C++) final class TemplateDeclaration : ScopeDsymbol
}
else
{
- inuse++;
oded = tparam.defaultArg(instLoc, paramscope);
- inuse--;
if (!oded)
{
// if tuple parameter and
@@ -2813,11 +2807,6 @@ void functionResolve(ref MatchAccumulator m, Dsymbol dstart, Loc loc, Scope* sc,
int applyTemplate(TemplateDeclaration td)
{
//printf("applyTemplate()\n");
- if (td.inuse)
- {
- td.error(loc, "recursive template expansion");
- return 1;
- }
if (td == td_best) // skip duplicates
return 0;
@@ -3613,8 +3602,29 @@ MATCH deduceType(RootObject o, Scope* sc, Type tparam, TemplateParameters* param
}
// Found the corresponding parameter tp
+ /+
+ https://issues.dlang.org/show_bug.cgi?id=23578
+ To pattern match:
+ static if (is(S!int == S!av, alias av))
+
+ We eventually need to deduce `int` (Tint32 [0]) and `av` (Tident).
+ Previously this would not get pattern matched at all, but now we check if the
+ template parameter `av` came from.
+
+ This note has been left to serve as a hint for further explorers into
+ how IsExp matching works.
+ +/
+ if (auto ta = tp.isTemplateAliasParameter())
+ {
+ (*dedtypes)[i] = t;
+ goto Lexact;
+ }
+ // (23578) - ensure previous behaviour for non-alias template params
if (!tp.isTemplateTypeParameter())
+ {
goto Lnomatch;
+ }
+
Type at = cast(Type)(*dedtypes)[i];
Type tt;
if (ubyte wx = wm ? deduceWildHelper(t, &tt, tparam) : 0)
@@ -4100,6 +4110,7 @@ MATCH deduceType(RootObject o, Scope* sc, Type tparam, TemplateParameters* param
}
goto Lnomatch;
}
+
TemplateParameter tpx = (*parameters)[i];
if (!tpx.matchArg(sc, tempdecl, i, parameters, dedtypes, null))
goto Lnomatch;
@@ -4110,7 +4121,7 @@ MATCH deduceType(RootObject o, Scope* sc, Type tparam, TemplateParameters* param
L2:
for (size_t i = 0; 1; i++)
{
- //printf("\ttest: tempinst.tiargs[%d]\n", i);
+ //printf("\ttest: tempinst.tiargs[%zu]\n", i);
RootObject o1 = null;
if (i < t.tempinst.tiargs.length)
o1 = (*t.tempinst.tiargs)[i];
@@ -4121,7 +4132,7 @@ MATCH deduceType(RootObject o, Scope* sc, Type tparam, TemplateParameters* param
}
else if (i >= tp.tempinst.tiargs.length)
break;
-
+ //printf("\ttest: o1 = %s\n", o1.toChars());
if (i >= tp.tempinst.tiargs.length)
{
size_t dim = tempdecl.parameters.length - (tempdecl.isVariadic() ? 1 : 0);
@@ -4136,7 +4147,7 @@ MATCH deduceType(RootObject o, Scope* sc, Type tparam, TemplateParameters* param
RootObject o2 = (*tp.tempinst.tiargs)[i];
Type t2 = isType(o2);
-
+ //printf("\ttest: o2 = %s\n", o2.toChars());
size_t j = (t2 && t2.ty == Tident && i == tp.tempinst.tiargs.length - 1)
? templateParameterLookup(t2, parameters) : IDX_NOTFOUND;
if (j != IDX_NOTFOUND && j == parameters.length - 1 &&
@@ -5571,15 +5582,25 @@ extern (C++) final class TemplateValueParameter : TemplateParameter
if (e)
{
e = e.syntaxCopy();
- uint olderrs = global.errors;
if ((e = e.expressionSemantic(sc)) is null)
return null;
+ if (auto te = e.isTemplateExp())
+ {
+ assert(sc && sc.tinst);
+ if (te.td == sc.tinst.tempdecl)
+ {
+ // defaultValue is a reference to its template declaration
+ // i.e: `template T(int arg = T)`
+ // Raise error now before calling resolveProperties otherwise we'll
+ // start looping on the expansion of the template instance.
+ sc.tinst.tempdecl.error("recursive template expansion");
+ return ErrorExp.get();
+ }
+ }
if ((e = resolveProperties(sc, e)) is null)
return null;
e = e.resolveLoc(instLoc, sc); // use the instantiated loc
e = e.optimize(WANTvalue);
- if (global.errors != olderrs)
- e = ErrorExp.get();
}
return e;
}
@@ -6910,11 +6931,6 @@ extern (C++) class TemplateInstance : ScopeDsymbol
auto td = s.isTemplateDeclaration();
if (!td)
return 0;
- if (td.inuse)
- {
- td.error(loc, "recursive template expansion");
- return 1;
- }
if (td == td_best) // skip duplicates
return 0;
@@ -7133,11 +7149,6 @@ extern (C++) class TemplateInstance : ScopeDsymbol
auto td = s.isTemplateDeclaration();
if (!td)
return 0;
- if (td.inuse)
- {
- td.error(loc, "recursive template expansion");
- return 1;
- }
/* If any of the overloaded template declarations need inference,
* then return true
diff --git a/gcc/d/dmd/dtoh.d b/gcc/d/dmd/dtoh.d
index 432e88d..30ca3d1 100644
--- a/gcc/d/dmd/dtoh.d
+++ b/gcc/d/dmd/dtoh.d
@@ -2,7 +2,7 @@
* This module contains the implementation of the C++ header generation available through
* the command line switch -Hc.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/dtohd, _dtoh.d)
@@ -24,6 +24,7 @@ import dmd.errors;
import dmd.globals;
import dmd.hdrgen;
import dmd.identifier;
+import dmd.location;
import dmd.root.filename;
import dmd.visitor;
import dmd.tokens;
diff --git a/gcc/d/dmd/dversion.d b/gcc/d/dmd/dversion.d
index 94753bb..259f85c5 100644
--- a/gcc/d/dmd/dversion.d
+++ b/gcc/d/dmd/dversion.d
@@ -4,7 +4,7 @@
* Specification: $(LINK2 https://dlang.org/spec/version.html#version-specification, Version Specification),
* $(LINK2 https://dlang.org/spec/version.html#debug_specification, Debug Specification).
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/dversion.d, _dversion.d)
@@ -22,6 +22,7 @@ import dmd.dsymbol;
import dmd.dsymbolsem;
import dmd.globals;
import dmd.identifier;
+import dmd.location;
import dmd.common.outbuffer;
import dmd.visitor;
diff --git a/gcc/d/dmd/entity.d b/gcc/d/dmd/entity.d
index 2b499c1..c31883f 100644
--- a/gcc/d/dmd/entity.d
+++ b/gcc/d/dmd/entity.d
@@ -3,7 +3,7 @@
*
* Specification $(LINK2 https://dlang.org/spec/entity.html, Named Character Entities)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/entity.d, _entity.d)
diff --git a/gcc/d/dmd/enum.h b/gcc/d/dmd/enum.h
index 723cebc..be12c65 100644
--- a/gcc/d/dmd/enum.h
+++ b/gcc/d/dmd/enum.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/errors.d b/gcc/d/dmd/errors.d
index 62e86a1..03c78a5 100644
--- a/gcc/d/dmd/errors.d
+++ b/gcc/d/dmd/errors.d
@@ -1,7 +1,7 @@
/**
* Functions for raising errors.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/errors.d, _errors.d)
@@ -13,6 +13,7 @@ module dmd.errors;
import core.stdc.stdarg;
import dmd.globals;
+import dmd.location;
nothrow:
diff --git a/gcc/d/dmd/errors.h b/gcc/d/dmd/errors.h
index 000242c..cc72811 100644
--- a/gcc/d/dmd/errors.h
+++ b/gcc/d/dmd/errors.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/escape.d b/gcc/d/dmd/escape.d
index 24a428b..7bc018e 100644
--- a/gcc/d/dmd/escape.d
+++ b/gcc/d/dmd/escape.d
@@ -1,7 +1,7 @@
/**
* Most of the logic to implement scoped pointers and scoped references is here.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/escape.d, _escape.d)
@@ -29,6 +29,7 @@ import dmd.globals;
import dmd.id;
import dmd.identifier;
import dmd.init;
+import dmd.location;
import dmd.mtype;
import dmd.printast;
import dmd.root.rootobject;
@@ -1788,7 +1789,7 @@ void escapeByValue(Expression e, EscapeByResults* er, bool live = false, bool re
if (tf.isreturn)
stc |= STC.return_;
if (tf.isreturnscope)
- stc |= STC.returnScope;
+ stc |= STC.returnScope | STC.scope_;
auto ad = fd.isThis();
if (ad.isClassDeclaration() || tf.isScopeQual)
stc |= STC.scope_;
diff --git a/gcc/d/dmd/expression.d b/gcc/d/dmd/expression.d
index 4f14d66..e0f258c 100644
--- a/gcc/d/dmd/expression.d
+++ b/gcc/d/dmd/expression.d
@@ -3,7 +3,7 @@
*
* Specification: ($LINK2 https://dlang.org/spec/expression.html, Expressions)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/expression.d, _expression.d)
@@ -50,6 +50,7 @@ import dmd.id;
import dmd.identifier;
import dmd.init;
import dmd.inline;
+import dmd.location;
import dmd.mtype;
import dmd.nspace;
import dmd.objc;
@@ -1291,12 +1292,16 @@ extern (C++) abstract class Expression : ASTNode
return false; // ...or manifest constants
// accessing empty structs is pure
+ // https://issues.dlang.org/show_bug.cgi?id=18694
+ // https://issues.dlang.org/show_bug.cgi?id=21464
+ // https://issues.dlang.org/show_bug.cgi?id=23589
if (v.type.ty == Tstruct)
{
StructDeclaration sd = (cast(TypeStruct)v.type).sym;
if (sd.members) // not opaque
{
- sd.determineSize(v.loc);
+ if (sd.semanticRun >= PASS.semanticdone)
+ sd.determineSize(v.loc);
if (sd.hasNoFields)
return false;
}
diff --git a/gcc/d/dmd/expression.h b/gcc/d/dmd/expression.h
index 79bc528..7202960 100644
--- a/gcc/d/dmd/expression.h
+++ b/gcc/d/dmd/expression.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/expressionsem.d b/gcc/d/dmd/expressionsem.d
index 60b51cb..63236cd 100644
--- a/gcc/d/dmd/expressionsem.d
+++ b/gcc/d/dmd/expressionsem.d
@@ -3,7 +3,7 @@
*
* Specification: ($LINK2 https://dlang.org/spec/expression.html, Expressions)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/expressionsem.d, _expressionsem.d)
@@ -55,6 +55,7 @@ import dmd.init;
import dmd.initsem;
import dmd.inline;
import dmd.intrange;
+import dmd.location;
import dmd.mtype;
import dmd.mustuse;
import dmd.nspace;
@@ -512,7 +513,7 @@ private Expression resolveUFCS(Scope* sc, CallExp ce)
{
Identifier ident = die.ident;
- Expression ex = die.semanticX(sc);
+ Expression ex = die.dotIdSemanticPropX(sc);
if (ex != die)
{
ce.e1 = ex;
@@ -561,7 +562,7 @@ private Expression resolveUFCS(Scope* sc, CallExp ce)
}
else
{
- if (Expression ey = die.semanticY(sc, 1))
+ if (Expression ey = die.dotIdSemanticProp(sc, 1))
{
if (ey.op == EXP.error)
return ey;
@@ -632,7 +633,7 @@ private Expression resolveUFCS(Scope* sc, CallExp ce)
}
else if (auto dti = ce.e1.isDotTemplateInstanceExp())
{
- if (Expression ey = dti.semanticY(sc, 1))
+ if (Expression ey = dti.dotTemplateSemanticProp(sc, 1))
{
ce.e1 = ey;
return null;
@@ -2536,28 +2537,6 @@ Package resolveIsPackage(Dsymbol sym)
return pkg;
}
-private Module loadStdMath()
-{
- __gshared Import impStdMath = null;
- __gshared Identifier[1] stdID;
- if (!impStdMath)
- {
- stdID[0] = Id.std;
- auto s = new Import(Loc.initial, stdID[], Id.math, null, false);
- // Module.load will call fatal() if there's no std.math available.
- // Gag the error here, pushing the error handling to the caller.
- uint errors = global.startGagging();
- s.load(null);
- if (s.mod)
- {
- s.mod.importAll(null);
- s.mod.dsymbolSemantic(null);
- }
- global.endGagging(errors);
- impStdMath = s;
- }
- return impStdMath.mod;
-}
private extern (C++) final class ExpressionSemanticVisitor : Visitor
{
@@ -3585,6 +3564,8 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
if (auto tc = tb.isTypeClass())
{
auto cd = tc.sym;
+ if (cd.errors)
+ return setError();
cd.size(exp.loc);
if (cd.sizeok != Sizeok.done)
return setError();
@@ -3630,21 +3611,25 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
{
if (!cdthis)
{
- if (!sc.hasThis)
+ void noReferenceToOuterClass()
{
- string msg = "cannot construct " ~
- (cd.isAnonymous ? "anonymous nested class" : "nested class `%s`") ~
- " because no implicit `this` reference to outer class" ~
- (cdn.isAnonymous ? "" : " `%s`") ~ " is available\0";
-
- exp.error(msg.ptr, cd.toChars, cdn.toChars);
+ if (cd.isAnonymous)
+ exp.error("cannot construct anonymous nested class because no implicit `this` reference to outer class is available");
+ else
+ exp.error("cannot construct nested class `%s` because no implicit `this` reference to outer class `%s` is available",
+ cd.toChars(), cdn.toChars());
return setError();
}
+ if (!sc.hasThis)
+ return noReferenceToOuterClass();
+
// Supply an implicit 'this' and try again
exp.thisexp = new ThisExp(exp.loc);
for (Dsymbol sp = sc.parent; 1; sp = sp.toParentLocal())
{
+ if (!sp)
+ return noReferenceToOuterClass();
ClassDeclaration cdp = sp.isClassDeclaration();
if (!cdp)
continue;
@@ -4671,8 +4656,8 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
else if (exp.arguments.length == 1)
{
e = (*exp.arguments)[0];
- if (!e.type.isTypeNoreturn())
- e = e.implicitCastTo(sc, t1);
+ e = e.implicitCastTo(sc, t1);
+ e = new CastExp(exp.loc, e, t1);
}
else
{
@@ -5851,8 +5836,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
dedtypes.zero();
MATCH m = deduceType(e.targ, sc, e.tspec, e.parameters, &dedtypes, null, 0, e.tok == TOK.equal);
- //printf("targ: %s\n", targ.toChars());
- //printf("tspec: %s\n", tspec.toChars());
+
if (m == MATCH.nomatch || (m != MATCH.exact && e.tok == TOK.equal))
{
return no();
@@ -6557,7 +6541,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
}
}
- Expression e = exp.semanticY(sc, 1);
+ Expression e = exp.dotIdSemanticProp(sc, 1);
if (e && isDotOpDispatch(e))
{
@@ -6786,7 +6770,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
return;
}
// Indicate we need to resolve by UFCS.
- Expression e = exp.semanticY(sc, 1);
+ Expression e = exp.dotTemplateSemanticProp(sc, 1);
if (!e)
e = resolveUFCSProperties(sc, exp);
if (e is exp)
@@ -7528,11 +7512,6 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
return;
}
- if (exp.e1.type.isTypeNoreturn() && (!exp.to || !exp.to.isTypeNoreturn()))
- {
- result = exp.e1;
- return;
- }
if (exp.to && !exp.to.isTypeSArray() && !exp.to.isTypeFunction())
exp.e1 = exp.e1.arrayFuncConv(sc);
@@ -8069,22 +8048,12 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
Expression el = new ArrayLengthExp(exp.loc, exp.e1);
el = el.expressionSemantic(sc);
el = el.optimize(WANTvalue);
- if (el.op == EXP.int64 && t1b.ty == Tsarray)
+ if (el.op == EXP.int64)
{
// Array length is known at compile-time. Upper is in bounds if it fits length.
dinteger_t length = el.toInteger();
auto bounds = IntRange(SignExtendedNumber(0), SignExtendedNumber(length));
exp.upperIsInBounds = bounds.contains(uprRange);
- if (exp.lwr.op == EXP.int64 && exp.upr.op == EXP.int64 && exp.lwr.toInteger() > exp.upr.toInteger())
- {
- exp.error("in slice `%s[%llu .. %llu]`, lower bound is greater than upper bound", exp.e1.toChars, exp.lwr.toInteger(), exp.upr.toInteger());
- return setError();
- }
- if (exp.upr.op == EXP.int64 && exp.upr.toInteger() > length)
- {
- exp.error("in slice `%s[%llu .. %llu]`, upper bound is greater than array length `%llu`", exp.e1.toChars, exp.lwr.toInteger(), exp.upr.toInteger(), length);
- return setError();
- }
}
else if (exp.upr.op == EXP.int64 && exp.upr.toInteger() == 0)
{
@@ -8884,7 +8853,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
*/
if (auto dti = e1x.isDotTemplateInstanceExp())
{
- Expression e = dti.semanticY(sc, 1);
+ Expression e = dti.dotTemplateSemanticProp(sc, 1);
if (!e)
{
return setResult(resolveUFCSProperties(sc, e1x, exp.e2));
@@ -8899,7 +8868,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
}
else if (auto die = e1x.isDotIdExp())
{
- Expression e = die.semanticY(sc, 1);
+ Expression e = die.dotIdSemanticProp(sc, 1);
if (e && isDotOpDispatch(e))
{
/* https://issues.dlang.org/show_bug.cgi?id=19687
@@ -11275,7 +11244,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
return;
}
- Module mmath = loadStdMath();
+ Module mmath = Module.loadStdMath();
if (!mmath)
{
e.error("`%s` requires `std.math` for `^^` operators", e.toChars());
@@ -11823,8 +11792,8 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
return;
}
- if (t1.isTypeVector())
- exp.type = t1;
+ if (auto tv = t1.isTypeVector())
+ exp.type = tv.toBooleanVector();
result = exp;
return;
@@ -12105,8 +12074,8 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
return;
}
- if (t1.isTypeVector())
- exp.type = t1;
+ if (auto tv = t1.isTypeVector())
+ exp.type = tv.toBooleanVector();
result = exp;
}
@@ -12244,10 +12213,12 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
if (t1.ty == Tnoreturn)
{
exp.type = t2;
+ exp.e1 = specialNoreturnCast(exp.e1, exp.type);
}
else if (t2.ty == Tnoreturn)
{
exp.type = t1;
+ exp.e2 = specialNoreturnCast(exp.e2, exp.type);
}
// If either operand is void the result is void, we have to cast both
// the expression to void so that we explicitly discard the expression
@@ -12541,7 +12512,7 @@ extern (C++) Expression expressionSemantic(Expression e, Scope* sc)
return v.result;
}
-Expression semanticX(DotIdExp exp, Scope* sc)
+private Expression dotIdSemanticPropX(DotIdExp exp, Scope* sc)
{
//printf("DotIdExp::semanticX(this = %p, '%s')\n", this, toChars());
if (Expression ex = unaSemantic(exp, sc))
@@ -12649,7 +12620,7 @@ Expression semanticX(DotIdExp exp, Scope* sc)
* Returns:
* resolved expression, null if error
*/
-Expression semanticY(DotIdExp exp, Scope* sc, int flag)
+Expression dotIdSemanticProp(DotIdExp exp, Scope* sc, int flag)
{
//printf("DotIdExp::semanticY(this = %p, '%s')\n", exp, exp.toChars());
@@ -12681,7 +12652,7 @@ Expression semanticY(DotIdExp exp, Scope* sc, int flag)
}
{
- Expression e = semanticX(exp, sc);
+ Expression e = dotIdSemanticPropX(exp, sc);
if (e != exp)
return e;
}
@@ -12983,7 +12954,7 @@ Expression semanticY(DotIdExp exp, Scope* sc, int flag)
// Resolve e1.ident!tiargs without seeing UFCS.
// If flag == 1, stop "not a property" error and return NULL.
-Expression semanticY(DotTemplateInstanceExp exp, Scope* sc, int flag)
+Expression dotTemplateSemanticProp(DotTemplateInstanceExp exp, Scope* sc, int flag)
{
static if (LOGSEMANTIC)
{
@@ -13007,7 +12978,7 @@ Expression semanticY(DotTemplateInstanceExp exp, Scope* sc, int flag)
auto die = new DotIdExp(exp.loc, e1, exp.ti.name);
- Expression e = die.semanticX(sc);
+ Expression e = die.dotIdSemanticPropX(sc);
if (e == die)
{
exp.e1 = die.e1; // take back
@@ -13020,7 +12991,7 @@ Expression semanticY(DotTemplateInstanceExp exp, Scope* sc, int flag)
if (flag)
return null;
}
- e = die.semanticY(sc, flag);
+ e = die.dotIdSemanticProp(sc, flag);
if (flag)
{
if (!e ||
@@ -13169,6 +13140,7 @@ Lerr:
bool checkSharedAccess(Expression e, Scope* sc, bool returnRef = false)
{
if (global.params.noSharedAccess != FeatureState.enabled ||
+ !sc ||
sc.intypeof ||
sc.flags & SCOPE.ctfe)
{
diff --git a/gcc/d/dmd/file_manager.d b/gcc/d/dmd/file_manager.d
index a941115..a0e5d05 100644
--- a/gcc/d/dmd/file_manager.d
+++ b/gcc/d/dmd/file_manager.d
@@ -1,7 +1,7 @@
/**
* Read a file from disk and store it in memory.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/file_manager.d, _file_manager.d)
* Documentation: https://dlang.org/phobos/dmd_file_manager.html
@@ -16,6 +16,7 @@ import dmd.root.filename : FileName, isDirSeparator;
import dmd.root.string : toDString;
import dmd.globals;
import dmd.identifier;
+import dmd.location;
enum package_d = "package." ~ mars_ext;
enum package_di = "package." ~ hdr_ext;
@@ -123,7 +124,7 @@ nothrow:
const(char)[] lookForSourceFile(const char[] filename, const char*[] path)
{
//printf("lookForSourceFile(`%.*s`)\n", cast(int)filename.length, filename.ptr);
- /* Search along path[] for .di file, then .d file, then .i file, then .c file.
+ /* Search along path[] for .di file, then .d file.
*/
// see if we should check for the module locally.
bool checkLocal = packageExists(filename);
@@ -140,16 +141,6 @@ nothrow:
return sd;
scope(exit) FileName.free(sd.ptr);
- const si = FileName.forceExt(filename, i_ext);
- if (checkLocal && FileName.exists(si) == 1)
- return si;
- scope(exit) FileName.free(si.ptr);
-
- const sc = FileName.forceExt(filename, c_ext);
- if (checkLocal && FileName.exists(sc) == 1)
- return sc;
- scope(exit) FileName.free(sc.ptr);
-
if (checkLocal)
{
auto cached = packageStatus.lookup(filename);
@@ -198,18 +189,6 @@ nothrow:
}
FileName.free(n.ptr);
- n = FileName.combine(p, si);
- if (FileName.exists(n) == 1) {
- return n;
- }
- FileName.free(n.ptr);
-
- n = FileName.combine(p, sc);
- if (FileName.exists(n) == 1) {
- return n;
- }
- FileName.free(n.ptr);
-
const b = FileName.removeExt(filename);
n = FileName.combine(p, b);
FileName.free(b.ptr);
@@ -235,6 +214,34 @@ nothrow:
FileName.free(n2.ptr);
}
}
+
+ /* ImportC: No D modules found, now search along path[] for .i file, then .c file.
+ */
+ const si = FileName.forceExt(filename, i_ext);
+ if (FileName.exists(si) == 1)
+ return si;
+ scope(exit) FileName.free(si.ptr);
+
+ const sc = FileName.forceExt(filename, c_ext);
+ if (FileName.exists(sc) == 1)
+ return sc;
+ scope(exit) FileName.free(sc.ptr);
+ foreach (entry; path)
+ {
+ const p = entry.toDString();
+
+ const(char)[] n = FileName.combine(p, si);
+ if (FileName.exists(n) == 1) {
+ return n;
+ }
+ FileName.free(n.ptr);
+
+ n = FileName.combine(p, sc);
+ if (FileName.exists(n) == 1) {
+ return n;
+ }
+ FileName.free(n.ptr);
+ }
return null;
}
diff --git a/gcc/d/dmd/foreachvar.d b/gcc/d/dmd/foreachvar.d
index 63281b5..7c4df0d 100644
--- a/gcc/d/dmd/foreachvar.d
+++ b/gcc/d/dmd/foreachvar.d
@@ -1,7 +1,7 @@
/**
* Utility to visit every variable in an expression.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/foreachvar.d, _foreachvar.d)
diff --git a/gcc/d/dmd/func.d b/gcc/d/dmd/func.d
index 93e3634..3a85679 100644
--- a/gcc/d/dmd/func.d
+++ b/gcc/d/dmd/func.d
@@ -8,7 +8,7 @@
* - `invariant`
* - `unittest`
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/func.d, _func.d)
@@ -43,6 +43,7 @@ import dmd.hdrgen;
import dmd.id;
import dmd.identifier;
import dmd.init;
+import dmd.location;
import dmd.mtype;
import dmd.objc;
import dmd.root.aav;
@@ -2924,89 +2925,100 @@ Expression addInvariant(AggregateDeclaration ad, VarDeclaration vthis)
*/
extern (D) int overloadApply(Dsymbol fstart, scope int delegate(Dsymbol) dg, Scope* sc = null)
{
- Dsymbol next;
- for (auto d = fstart; d; d = next)
+ Dsymbols visited;
+
+ int overloadApplyRecurse(Dsymbol fstart, scope int delegate(Dsymbol) dg, Scope* sc)
{
- import dmd.access : checkSymbolAccess;
- if (auto od = d.isOverDeclaration())
+ // Detect cyclic calls.
+ if (visited.contains(fstart))
+ return 0;
+ visited.push(fstart);
+
+ Dsymbol next;
+ for (auto d = fstart; d; d = next)
{
- /* The scope is needed here to check whether a function in
- an overload set was added by means of a private alias (or a
- selective import). If the scope where the alias is created
- is imported somewhere, the overload set is visible, but the private
- alias is not.
- */
- if (sc)
+ import dmd.access : checkSymbolAccess;
+ if (auto od = d.isOverDeclaration())
{
- if (checkSymbolAccess(sc, od))
+ /* The scope is needed here to check whether a function in
+ an overload set was added by means of a private alias (or a
+ selective import). If the scope where the alias is created
+ is imported somewhere, the overload set is visible, but the private
+ alias is not.
+ */
+ if (sc)
{
- if (int r = overloadApply(od.aliassym, dg, sc))
+ if (checkSymbolAccess(sc, od))
+ {
+ if (int r = overloadApplyRecurse(od.aliassym, dg, sc))
+ return r;
+ }
+ }
+ else if (int r = overloadApplyRecurse(od.aliassym, dg, sc))
+ return r;
+ next = od.overnext;
+ }
+ else if (auto fa = d.isFuncAliasDeclaration())
+ {
+ if (fa.hasOverloads)
+ {
+ if (int r = overloadApplyRecurse(fa.funcalias, dg, sc))
return r;
}
+ else if (auto fd = fa.toAliasFunc())
+ {
+ if (int r = dg(fd))
+ return r;
+ }
+ else
+ {
+ d.error("is aliased to a function");
+ break;
+ }
+ next = fa.overnext;
}
- else if (int r = overloadApply(od.aliassym, dg, sc))
- return r;
- next = od.overnext;
- }
- else if (auto fa = d.isFuncAliasDeclaration())
- {
- if (fa.hasOverloads)
+ else if (auto ad = d.isAliasDeclaration())
{
- if (int r = overloadApply(fa.funcalias, dg, sc))
+ if (sc)
+ {
+ if (checkSymbolAccess(sc, ad))
+ next = ad.toAlias();
+ }
+ else
+ next = ad.toAlias();
+ if (next == ad)
+ break;
+ if (next == fstart)
+ break;
+ }
+ else if (auto td = d.isTemplateDeclaration())
+ {
+ if (int r = dg(td))
return r;
+ next = td.overnext;
}
- else if (auto fd = fa.toAliasFunc())
+ else if (auto fd = d.isFuncDeclaration())
{
if (int r = dg(fd))
return r;
+ next = fd.overnext;
+ }
+ else if (auto os = d.isOverloadSet())
+ {
+ foreach (ds; os.a)
+ if (int r = dg(ds))
+ return r;
}
else
{
d.error("is aliased to a function");
break;
+ // BUG: should print error message?
}
- next = fa.overnext;
- }
- else if (auto ad = d.isAliasDeclaration())
- {
- if (sc)
- {
- if (checkSymbolAccess(sc, ad))
- next = ad.toAlias();
- }
- else
- next = ad.toAlias();
- if (next == ad)
- break;
- if (next == fstart)
- break;
- }
- else if (auto td = d.isTemplateDeclaration())
- {
- if (int r = dg(td))
- return r;
- next = td.overnext;
- }
- else if (auto fd = d.isFuncDeclaration())
- {
- if (int r = dg(fd))
- return r;
- next = fd.overnext;
- }
- else if (auto os = d.isOverloadSet())
- {
- foreach (ds; os.a)
- if (int r = dg(ds))
- return r;
- }
- else
- {
- d.error("is aliased to a function");
- break;
- // BUG: should print error message?
}
+ return 0;
}
- return 0;
+ return overloadApplyRecurse(fstart, dg, sc);
}
/**
diff --git a/gcc/d/dmd/globals.d b/gcc/d/dmd/globals.d
index 2770f5a..80c183e 100644
--- a/gcc/d/dmd/globals.d
+++ b/gcc/d/dmd/globals.d
@@ -1,7 +1,7 @@
/**
* Stores command line options and contains other miscellaneous declarations.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/globals.d, _globals.d)
@@ -17,6 +17,7 @@ import dmd.root.filename;
import dmd.common.outbuffer;
import dmd.file_manager;
import dmd.identifier;
+import dmd.location;
/// Defines a setting for how compiler warnings and deprecations are handled
enum DiagnosticReporting : ubyte
@@ -26,13 +27,6 @@ enum DiagnosticReporting : ubyte
off, /// disable diagnostic
}
-/// How code locations are formatted for diagnostic reporting
-enum MessageStyle : ubyte
-{
- digitalmars, /// filename.d(line): message
- gnu, /// filename.d:line: message, see https://www.gnu.org/prep/standards/html_node/Errors.html
-}
-
/// In which context checks for assertions, contracts, bounds checks etc. are enabled
enum CHECKENABLE : ubyte
{
@@ -266,7 +260,7 @@ extern (C++) struct Global
{
const(char)[] inifilename; /// filename of configuration file as given by `-conf=`, or default value
- string copyright = "Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved";
+ string copyright = "Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved";
string written = "written by Walter Bright";
Array!(const(char)*)* path; /// Array of char*'s which form the import lookup path
@@ -446,125 +440,5 @@ alias dinteger_t = ulong;
alias sinteger_t = long;
alias uinteger_t = ulong;
-version (DMDLIB)
-{
- version = LocOffset;
-}
-
-/**
-A source code location
-
-Used for error messages, `__FILE__` and `__LINE__` tokens, `__traits(getLocation, XXX)`,
-debug info etc.
-*/
-struct Loc
-{
- /// zero-terminated filename string, either absolute or relative to cwd
- const(char)* filename;
- uint linnum; /// line number, starting from 1
- uint charnum; /// utf8 code unit index relative to start of line, starting from 1
- version (LocOffset)
- uint fileOffset; /// utf8 code unit index relative to start of file, starting from 0
-
- static immutable Loc initial; /// use for default initialization of const ref Loc's
-
-nothrow:
- extern (D) this(const(char)* filename, uint linnum, uint charnum) pure
- {
- this.linnum = linnum;
- this.charnum = charnum;
- this.filename = filename;
- }
-
- extern (C++) const(char)* toChars(
- bool showColumns = global.params.showColumns,
- ubyte messageStyle = global.params.messageStyle) const pure nothrow
- {
- OutBuffer buf;
- if (filename)
- {
- buf.writestring(filename);
- }
- if (linnum)
- {
- final switch (messageStyle)
- {
- case MessageStyle.digitalmars:
- buf.writeByte('(');
- buf.print(linnum);
- if (showColumns && charnum)
- {
- buf.writeByte(',');
- buf.print(charnum);
- }
- buf.writeByte(')');
- break;
- case MessageStyle.gnu: // https://www.gnu.org/prep/standards/html_node/Errors.html
- buf.writeByte(':');
- buf.print(linnum);
- if (showColumns && charnum)
- {
- buf.writeByte(':');
- buf.print(charnum);
- }
- break;
- }
- }
- return buf.extractChars();
- }
-
- /**
- * Checks for equivalence by comparing the filename contents (not the pointer) and character location.
- *
- * Note:
- * - Uses case-insensitive comparison on Windows
- * - Ignores `charnum` if `global.params.showColumns` is false.
- */
- extern (C++) bool equals(ref const(Loc) loc) const
- {
- return (!global.params.showColumns || charnum == loc.charnum) &&
- linnum == loc.linnum &&
- FileName.equals(filename, loc.filename);
- }
-
- /**
- * `opEquals()` / `toHash()` for AA key usage
- *
- * Compare filename contents (case-sensitively on Windows too), not
- * the pointer - a static foreach loop repeatedly mixing in a mixin
- * may lead to multiple equivalent filenames (`foo.d-mixin-<line>`),
- * e.g., for test/runnable/test18880.d.
- */
- extern (D) bool opEquals(ref const(Loc) loc) const @trusted pure nothrow @nogc
- {
- import core.stdc.string : strcmp;
-
- return charnum == loc.charnum &&
- linnum == loc.linnum &&
- (filename == loc.filename ||
- (filename && loc.filename && strcmp(filename, loc.filename) == 0));
- }
-
- /// ditto
- extern (D) size_t toHash() const @trusted pure nothrow
- {
- import dmd.root.string : toDString;
-
- auto hash = hashOf(linnum);
- hash = hashOf(charnum, hash);
- hash = hashOf(filename.toDString, hash);
- return hash;
- }
-
- /******************
- * Returns:
- * true if Loc has been set to other than the default initialization
- */
- bool isValid() const pure
- {
- return filename !is null;
- }
-}
-
/// Collection of global state
extern (C++) __gshared Global global;
diff --git a/gcc/d/dmd/globals.h b/gcc/d/dmd/globals.h
index d9cb76c..45c5624 100644
--- a/gcc/d/dmd/globals.h
+++ b/gcc/d/dmd/globals.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
@@ -30,11 +30,10 @@ enum
DIAGNOSTICoff // disable diagnostic
};
-typedef unsigned char MessageStyle;
-enum
+enum class MessageStyle : unsigned char
{
- MESSAGESTYLEdigitalmars, // file(line,column): message
- MESSAGESTYLEgnu // file:line:column: message
+ digitalmars, // file(line,column): message
+ gnu // file:line:column: message
};
// The state of array bounds checking
@@ -342,6 +341,11 @@ struct Loc
unsigned linnum;
unsigned charnum;
+ static void set(bool showColumns, MessageStyle messageStyle);
+
+ static bool showColumns;
+ static MessageStyle messageStyle;
+
Loc()
{
linnum = 0;
@@ -357,8 +361,8 @@ struct Loc
}
const char *toChars(
- bool showColumns = global.params.showColumns,
- MessageStyle messageStyle = global.params.messageStyle) const;
+ bool showColumns = Loc::showColumns,
+ MessageStyle messageStyle = Loc::messageStyle) const;
bool equals(const Loc& loc) const;
};
diff --git a/gcc/d/dmd/gluelayer.d b/gcc/d/dmd/gluelayer.d
index 73a1f00..7b52eff 100644
--- a/gcc/d/dmd/gluelayer.d
+++ b/gcc/d/dmd/gluelayer.d
@@ -3,7 +3,7 @@
*
* This 'glues' either the DMC or GCC back-end to the front-end.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/gluelayer.d, _gluelayer.d)
diff --git a/gcc/d/dmd/hdrgen.d b/gcc/d/dmd/hdrgen.d
index 6b51a81..68670d9 100644
--- a/gcc/d/dmd/hdrgen.d
+++ b/gcc/d/dmd/hdrgen.d
@@ -3,7 +3,7 @@
*
* Also used to convert AST nodes to D code in general, e.g. for error messages or `printf` debugging.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/hdrgen.d, _hdrgen.d)
@@ -823,10 +823,13 @@ public:
buf.writestring(s.kind());
buf.writeByte('(');
s.exp.expressionToBuffer(buf, hgs);
- if (s.msg)
+ if (s.msgs)
{
- buf.writestring(", ");
- s.msg.expressionToBuffer(buf, hgs);
+ foreach (m; (*s.msgs)[])
+ {
+ buf.writestring(", ");
+ m.expressionToBuffer(buf, hgs);
+ }
}
buf.writestring(");");
buf.writenl();
diff --git a/gcc/d/dmd/hdrgen.h b/gcc/d/dmd/hdrgen.h
index 0488c51..43fea34 100644
--- a/gcc/d/dmd/hdrgen.h
+++ b/gcc/d/dmd/hdrgen.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Dave Fladebo
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/iasm.d b/gcc/d/dmd/iasm.d
index 29aca3e..4d780b3 100644
--- a/gcc/d/dmd/iasm.d
+++ b/gcc/d/dmd/iasm.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/iasm.html, Inline Assembler)
*
- * Copyright (C) 2018-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 2018-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/iasm.d, _iasm.d)
diff --git a/gcc/d/dmd/iasmgcc.d b/gcc/d/dmd/iasmgcc.d
index f85e1ab..baf6b14 100644
--- a/gcc/d/dmd/iasmgcc.d
+++ b/gcc/d/dmd/iasmgcc.d
@@ -1,7 +1,7 @@
/**
* Inline assembler for the GCC D compiler.
*
- * Copyright (C) 2018-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 2018-2023 by The D Language Foundation, All Rights Reserved
* Authors: Iain Buclaw
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/iasmgcc.d, _iasmgcc.d)
@@ -21,6 +21,7 @@ import dmd.expression;
import dmd.expressionsem;
import dmd.identifier;
import dmd.globals;
+import dmd.location;
import dmd.parse;
import dmd.tokens;
import dmd.statement;
diff --git a/gcc/d/dmd/id.d b/gcc/d/dmd/id.d
index 48ca766..40a5c6e 100644
--- a/gcc/d/dmd/id.d
+++ b/gcc/d/dmd/id.d
@@ -1,7 +1,7 @@
/**
* Contains the `Id` struct with a list of predefined symbols the compiler knows about.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/id.d, _id.d)
diff --git a/gcc/d/dmd/id.h b/gcc/d/dmd/id.h
index 984c203..f6cf6e5 100644
--- a/gcc/d/dmd/id.h
+++ b/gcc/d/dmd/id.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 2017-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 2017-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/identifier.d b/gcc/d/dmd/identifier.d
index 7f92298..2233d77 100644
--- a/gcc/d/dmd/identifier.d
+++ b/gcc/d/dmd/identifier.d
@@ -1,7 +1,7 @@
/**
* Defines an identifier, which is the name of a `Dsymbol`.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/identifier.d, _identifier.d)
@@ -14,8 +14,8 @@ module dmd.identifier;
import core.stdc.ctype;
import core.stdc.stdio;
import core.stdc.string;
-import dmd.globals;
import dmd.id;
+import dmd.location;
import dmd.common.outbuffer;
import dmd.root.rootobject;
import dmd.root.string;
diff --git a/gcc/d/dmd/identifier.h b/gcc/d/dmd/identifier.h
index fa7a25a..c12c355 100644
--- a/gcc/d/dmd/identifier.h
+++ b/gcc/d/dmd/identifier.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/impcnvtab.d b/gcc/d/dmd/impcnvtab.d
index 832c331..b45880a 100644
--- a/gcc/d/dmd/impcnvtab.d
+++ b/gcc/d/dmd/impcnvtab.d
@@ -6,7 +6,7 @@
* Specification: $(LINK2 https://dlang.org/spec/type.html#integer-promotions, Integer Promotions),
* $(LINK2 https://dlang.org/spec/type.html#usual-arithmetic-conversions, Usual Arithmetic Conversions).
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/impcnvtab.d, _impcnvtab.d)
diff --git a/gcc/d/dmd/imphint.d b/gcc/d/dmd/imphint.d
index f03113d..913de9f 100644
--- a/gcc/d/dmd/imphint.d
+++ b/gcc/d/dmd/imphint.d
@@ -3,7 +3,7 @@
*
* For example, prompt to `import std.stdio` when using `writeln`.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/imphint.d, _imphint.d)
diff --git a/gcc/d/dmd/import.h b/gcc/d/dmd/import.h
index f749ef5..ff25ba2 100644
--- a/gcc/d/dmd/import.h
+++ b/gcc/d/dmd/import.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/importc.d b/gcc/d/dmd/importc.d
index afec5ef..97710b8 100644
--- a/gcc/d/dmd/importc.d
+++ b/gcc/d/dmd/importc.d
@@ -3,7 +3,7 @@
*
* Specification: C11
*
- * Copyright: Copyright (C) 2021-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 2021-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/importc.d, _importc.d)
diff --git a/gcc/d/dmd/init.d b/gcc/d/dmd/init.d
index f57b4e6..f646d03 100644
--- a/gcc/d/dmd/init.d
+++ b/gcc/d/dmd/init.d
@@ -1,7 +1,7 @@
/**
* Defines initializers of variables, e.g. the array literal in `int[3] x = [0, 1, 2]`.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/init.d, _init.d)
@@ -22,6 +22,7 @@ import dmd.expression;
import dmd.globals;
import dmd.hdrgen;
import dmd.identifier;
+import dmd.location;
import dmd.mtype;
import dmd.common.outbuffer;
import dmd.root.rootobject;
diff --git a/gcc/d/dmd/init.h b/gcc/d/dmd/init.h
index 977157f..66b874c 100644
--- a/gcc/d/dmd/init.h
+++ b/gcc/d/dmd/init.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/initsem.d b/gcc/d/dmd/initsem.d
index ecaa5e8..572753b 100644
--- a/gcc/d/dmd/initsem.d
+++ b/gcc/d/dmd/initsem.d
@@ -1,7 +1,7 @@
/**
* Semantic analysis of initializers.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/initsem.d, _initsem.d)
@@ -33,6 +33,7 @@ import dmd.id;
import dmd.identifier;
import dmd.importc;
import dmd.init;
+import dmd.location;
import dmd.mtype;
import dmd.opover;
import dmd.statement;
diff --git a/gcc/d/dmd/inline.d b/gcc/d/dmd/inline.d
index 25982a6..8e63122 100644
--- a/gcc/d/dmd/inline.d
+++ b/gcc/d/dmd/inline.d
@@ -4,7 +4,7 @@
* The AST is traversed, and every function call is considered for inlining using `inlinecost.d`.
* The function call is then inlined if this cost is below a threshold.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/inline.d, _inline.d)
diff --git a/gcc/d/dmd/intrange.d b/gcc/d/dmd/intrange.d
index d0206b6..d67e0f5 100644
--- a/gcc/d/dmd/intrange.d
+++ b/gcc/d/dmd/intrange.d
@@ -1,7 +1,7 @@
/**
* Implement $(LINK2 https://digitalmars.com/articles/b62.html, Value Range Propagation).
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/intrange.d, _intrange.d)
diff --git a/gcc/d/dmd/json.d b/gcc/d/dmd/json.d
index b7719d8..38e03e7 100644
--- a/gcc/d/dmd/json.d
+++ b/gcc/d/dmd/json.d
@@ -1,7 +1,7 @@
/**
* Code for generating .json descriptions of the module when passing the `-X` flag to dmd.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/json.d, _json.d)
@@ -32,6 +32,7 @@ import dmd.globals;
import dmd.hdrgen;
import dmd.id;
import dmd.identifier;
+import dmd.location;
import dmd.mtype;
import dmd.common.outbuffer;
import dmd.root.rootobject;
diff --git a/gcc/d/dmd/json.h b/gcc/d/dmd/json.h
index 979440c..7a23897 100644
--- a/gcc/d/dmd/json.h
+++ b/gcc/d/dmd/json.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/lambdacomp.d b/gcc/d/dmd/lambdacomp.d
index e1ed717..c800273 100644
--- a/gcc/d/dmd/lambdacomp.d
+++ b/gcc/d/dmd/lambdacomp.d
@@ -5,7 +5,7 @@
* The serialization is a string which contains the type of the parameters and the string
* represantation of the lambda expression.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/lamdbacomp.d, _lambdacomp.d)
diff --git a/gcc/d/dmd/lexer.d b/gcc/d/dmd/lexer.d
index 200d74f..bd53433 100644
--- a/gcc/d/dmd/lexer.d
+++ b/gcc/d/dmd/lexer.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/lex.html, Lexical)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/lexer.d, _lexer.d)
@@ -26,6 +26,7 @@ import dmd.errors;
import dmd.globals;
import dmd.id;
import dmd.identifier;
+import dmd.location;
import dmd.root.array;
import dmd.root.ctfloat;
import dmd.common.outbuffer;
@@ -79,15 +80,14 @@ class Lexer
bool commentToken; // comments are TOK.comment's
bool tokenizeNewlines; // newlines are turned into TOK.endOfLine's
- version (DMDLIB)
- {
- bool whitespaceToken; // tokenize whitespaces
- }
+ bool whitespaceToken; // tokenize whitespaces (only for DMDLIB)
int inTokenStringConstant; // can be larger than 1 when in nested q{} strings
int lastDocLine; // last line of previous doc comment
Token* tokenFreelist;
+ uint versionNumber;
+ const(char)[] vendor;
}
nothrow:
@@ -103,9 +103,12 @@ class Lexer
* endoffset = the last offset to read into base[]
* doDocComment = handle documentation comments
* commentToken = comments become TOK.comment's
+ * vendor = name of the vendor
+ * versionNumber = version of the caller
*/
this(const(char)* filename, const(char)* base, size_t begoffset,
- size_t endoffset, bool doDocComment, bool commentToken) pure
+ size_t endoffset, bool doDocComment, bool commentToken,
+ const(char)[] vendor = "DLF", uint versionNumber = 1) pure
{
scanloc = Loc(filename, 1, 1);
// debug printf("Lexer::Lexer(%p)\n", base);
@@ -120,6 +123,8 @@ class Lexer
this.tokenizeNewlines = false;
this.inTokenStringConstant = 0;
this.lastDocLine = 0;
+ this.versionNumber = versionNumber;
+ this.vendor = vendor;
//initKeywords();
/* If first line starts with '#!', ignore the line
*/
@@ -154,6 +159,16 @@ class Lexer
}
}
+ /***********************
+ * Alternative entry point for DMDLIB, adds `whitespaceToken`
+ */
+ this(const(char)* filename, const(char)* base, size_t begoffset, size_t endoffset,
+ bool doDocComment, bool commentToken, bool whitespaceToken)
+ {
+ this(filename, base, begoffset, endoffset, doDocComment, commentToken);
+ this.whitespaceToken = whitespaceToken;
+ }
+
/******************
* Used for unittests for a mock Lexer
*/
@@ -184,29 +199,23 @@ class Lexer
tokenizeNewlines = true;
}
- version (DMDLIB)
- {
- this(const(char)* filename, const(char)* base, size_t begoffset, size_t endoffset,
- bool doDocComment, bool commentToken, bool whitespaceToken)
- {
- this(filename, base, begoffset, endoffset, doDocComment, commentToken);
- this.whitespaceToken = whitespaceToken;
- }
+ /***************
+ * Range interface
+ */
- bool empty() const pure @property @nogc @safe
- {
- return front() == TOK.endOfFile;
- }
+ final bool empty() const pure @property @nogc @safe
+ {
+ return front() == TOK.endOfFile;
+ }
- TOK front() const pure @property @nogc @safe
- {
- return token.value;
- }
+ final TOK front() const pure @property @nogc @safe
+ {
+ return token.value;
+ }
- void popFront()
- {
- nextToken();
- }
+ final void popFront()
+ {
+ nextToken();
}
/// Returns: a newly allocated `Token`.
@@ -570,7 +579,7 @@ class Lexer
}
else if (id == Id.VENDOR)
{
- t.ustring = global.vendor.xarraydup.ptr;
+ t.ustring = vendor.xarraydup.ptr;
goto Lstr;
}
else if (id == Id.TIMESTAMP)
@@ -584,7 +593,7 @@ class Lexer
else if (id == Id.VERSIONX)
{
t.value = TOK.int64Literal;
- t.unsvalue = global.versionNumber();
+ t.unsvalue = versionNumber;
}
else if (id == Id.EOFX)
{
@@ -1965,7 +1974,7 @@ class Lexer
{
int base = 10;
const start = p;
- uinteger_t n = 0; // unsigned >=64 bit integer type
+ ulong n = 0; // unsigned >=64 bit integer type
int d;
bool err = false;
bool overflow = false;
@@ -2274,7 +2283,7 @@ class Lexer
* Returns:
* token value
*/
- private TOK cnumber(int base, uinteger_t n)
+ private TOK cnumber(int base, ulong n)
{
/* C11 6.4.4.1
* Parse trailing suffixes:
diff --git a/gcc/d/dmd/location.d b/gcc/d/dmd/location.d
new file mode 100644
index 0000000..020d297
--- /dev/null
+++ b/gcc/d/dmd/location.d
@@ -0,0 +1,158 @@
+/**
+ * Encapsulates file/line/column locations.
+ *
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
+ * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
+ * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/location.d, _location.d)
+ * Documentation: https://dlang.org/phobos/dmd_location.html
+ * Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/location.d
+ */
+
+module dmd.location;
+
+import dmd.common.outbuffer;
+import dmd.root.filename;
+
+version (DMDLIB)
+{
+ version = LocOffset;
+}
+
+/// How code locations are formatted for diagnostic reporting
+enum MessageStyle : ubyte
+{
+ digitalmars, /// filename.d(line): message
+ gnu, /// filename.d:line: message, see https://www.gnu.org/prep/standards/html_node/Errors.html
+}
+
+/**
+A source code location
+
+Used for error messages, `__FILE__` and `__LINE__` tokens, `__traits(getLocation, XXX)`,
+debug info etc.
+*/
+struct Loc
+{
+ /// zero-terminated filename string, either absolute or relative to cwd
+ const(char)* filename;
+ uint linnum; /// line number, starting from 1
+ uint charnum; /// utf8 code unit index relative to start of line, starting from 1
+ version (LocOffset)
+ uint fileOffset; /// utf8 code unit index relative to start of file, starting from 0
+
+ static immutable Loc initial; /// use for default initialization of const ref Loc's
+
+ extern (C++) __gshared bool showColumns;
+ extern (C++) __gshared MessageStyle messageStyle;
+
+nothrow:
+
+ /*******************************
+ * Configure how display is done
+ * Params:
+ * showColumns = when to display columns
+ * messageStyle = digitalmars or gnu style messages
+ */
+ extern (C++) static void set(bool showColumns, MessageStyle messageStyle)
+ {
+ this.showColumns = showColumns;
+ this.messageStyle = messageStyle;
+ }
+
+ extern (D) this(const(char)* filename, uint linnum, uint charnum) pure
+ {
+ this.linnum = linnum;
+ this.charnum = charnum;
+ this.filename = filename;
+ }
+
+ extern (C++) const(char)* toChars(
+ bool showColumns = Loc.showColumns,
+ MessageStyle messageStyle = Loc.messageStyle) const pure nothrow
+ {
+ OutBuffer buf;
+ if (filename)
+ {
+ buf.writestring(filename);
+ }
+ if (linnum)
+ {
+ final switch (messageStyle)
+ {
+ case MessageStyle.digitalmars:
+ buf.writeByte('(');
+ buf.print(linnum);
+ if (showColumns && charnum)
+ {
+ buf.writeByte(',');
+ buf.print(charnum);
+ }
+ buf.writeByte(')');
+ break;
+ case MessageStyle.gnu: // https://www.gnu.org/prep/standards/html_node/Errors.html
+ buf.writeByte(':');
+ buf.print(linnum);
+ if (showColumns && charnum)
+ {
+ buf.writeByte(':');
+ buf.print(charnum);
+ }
+ break;
+ }
+ }
+ return buf.extractChars();
+ }
+
+ /**
+ * Checks for equivalence by comparing the filename contents (not the pointer) and character location.
+ *
+ * Note:
+ * - Uses case-insensitive comparison on Windows
+ * - Ignores `charnum` if `Columns` is false.
+ */
+ extern (C++) bool equals(ref const(Loc) loc) const
+ {
+ return (!showColumns || charnum == loc.charnum) &&
+ linnum == loc.linnum &&
+ FileName.equals(filename, loc.filename);
+ }
+
+ /**
+ * `opEquals()` / `toHash()` for AA key usage
+ *
+ * Compare filename contents (case-sensitively on Windows too), not
+ * the pointer - a static foreach loop repeatedly mixing in a mixin
+ * may lead to multiple equivalent filenames (`foo.d-mixin-<line>`),
+ * e.g., for test/runnable/test18880.d.
+ */
+ extern (D) bool opEquals(ref const(Loc) loc) const @trusted pure nothrow @nogc
+ {
+ import core.stdc.string : strcmp;
+
+ return charnum == loc.charnum &&
+ linnum == loc.linnum &&
+ (filename == loc.filename ||
+ (filename && loc.filename && strcmp(filename, loc.filename) == 0));
+ }
+
+ /// ditto
+ extern (D) size_t toHash() const @trusted pure nothrow
+ {
+ import dmd.root.string : toDString;
+
+ auto hash = hashOf(linnum);
+ hash = hashOf(charnum, hash);
+ hash = hashOf(filename.toDString, hash);
+ return hash;
+ }
+
+ /******************
+ * Returns:
+ * true if Loc has been set to other than the default initialization
+ */
+ bool isValid() const pure
+ {
+ return filename !is null;
+ }
+}
diff --git a/gcc/d/dmd/mangle.h b/gcc/d/dmd/mangle.h
index 512184a..37953c2 100644
--- a/gcc/d/dmd/mangle.h
+++ b/gcc/d/dmd/mangle.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/module.h b/gcc/d/dmd/module.h
index 48046de..bc89ac4 100644
--- a/gcc/d/dmd/module.h
+++ b/gcc/d/dmd/module.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
@@ -79,18 +79,18 @@ public:
Package *pkg; // if isPackageFile is true, the Package that contains this package.d
Strings contentImportedFiles; // array of files whose content was imported
int needmoduleinfo;
- int selfimports; // 0: don't know, 1: does not, 2: does
+ ThreeState selfimports;
+ ThreeState rootimports;
void* tagSymTab; // ImportC: tag symbols that conflict with other symbols used as the index
OutBuffer defines; // collect all the #define lines here
bool selfImports(); // returns true if module imports itself
- int rootimports; // 0: don't know, 1: does not, 2: does
bool rootImports(); // returns true if module imports root module
- int insearch;
Identifier *searchCacheIdent;
Dsymbol *searchCacheSymbol; // cached value of search
int searchCacheFlags; // cached flags
+ bool insearch;
// module from command line we're imported from,
// i.e. a module that will be taken all the
diff --git a/gcc/d/dmd/mtype.d b/gcc/d/dmd/mtype.d
index 2c0a571..232042d 100644
--- a/gcc/d/dmd/mtype.d
+++ b/gcc/d/dmd/mtype.d
@@ -1,7 +1,7 @@
/**
* Defines a D type.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/mtype.d, _mtype.d)
@@ -41,6 +41,7 @@ import dmd.hdrgen;
import dmd.id;
import dmd.identifier;
import dmd.init;
+import dmd.location;
import dmd.opover;
import dmd.root.ctfloat;
import dmd.common.outbuffer;
@@ -7384,3 +7385,51 @@ private extern(D) MATCH matchTypeSafeVarArgs(TypeFunction tf, Parameter p,
return MATCH.nomatch;
}
}
+
+/**
+ * Creates an appropriate vector type for `tv` that will hold one boolean
+ * result for each element of the vector type. The result of vector comparisons
+ * is a single or doubleword mask of all 1s (comparison true) or all 0s
+ * (comparison false). This SIMD mask type does not have an equivalent D type,
+ * however its closest equivalent would be an integer vector of the same unit
+ * size and length.
+ *
+ * Params:
+ * tv = The `TypeVector` to build a vector from.
+ * Returns:
+ * A vector type suitable for the result of a vector comparison operation.
+ */
+TypeVector toBooleanVector(TypeVector tv)
+{
+ Type telem = tv.elementType();
+ switch (telem.ty)
+ {
+ case Tvoid:
+ case Tint8:
+ case Tuns8:
+ case Tint16:
+ case Tuns16:
+ case Tint32:
+ case Tuns32:
+ case Tint64:
+ case Tuns64:
+ // No need to build an equivalent mask type.
+ return tv;
+
+ case Tfloat32:
+ telem = Type.tuns32;
+ break;
+
+ case Tfloat64:
+ telem = Type.tuns64;
+ break;
+
+ default:
+ assert(0);
+ }
+
+ TypeSArray tsa = tv.basetype.isTypeSArray();
+ assert(tsa !is null);
+
+ return new TypeVector(new TypeSArray(telem, tsa.dim));
+}
diff --git a/gcc/d/dmd/mtype.h b/gcc/d/dmd/mtype.h
index c81c25a..d0775f2 100644
--- a/gcc/d/dmd/mtype.h
+++ b/gcc/d/dmd/mtype.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/mustuse.d b/gcc/d/dmd/mustuse.d
index 369d60e..11cc3b8d 100644
--- a/gcc/d/dmd/mustuse.d
+++ b/gcc/d/dmd/mustuse.d
@@ -1,7 +1,7 @@
/**
* Compile-time checks associated with the @mustuse attribute.
*
- * Copyright: Copyright (C) 2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 2022-2023 by The D Language Foundation, All Rights Reserved
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/mustuse.d, _mustuse.d)
* Documentation: https://dlang.org/phobos/dmd_mustuse.html
@@ -15,6 +15,7 @@ import dmd.dsymbol;
import dmd.expression;
import dmd.globals;
import dmd.identifier;
+import dmd.location;
// Used in isIncrementOrDecrement
private static const StringExp plusPlus, minusMinus;
@@ -147,7 +148,7 @@ private bool isAssignmentOpId(Identifier id)
private bool isIncrementOrDecrement(Expression e)
{
import dmd.dtemplate : isExpression;
- import dmd.globals : Loc;
+ import dmd.location;
import dmd.id : Id;
import dmd.tokens : EXP;
diff --git a/gcc/d/dmd/nogc.d b/gcc/d/dmd/nogc.d
index 3329c14..370e3b8 100644
--- a/gcc/d/dmd/nogc.d
+++ b/gcc/d/dmd/nogc.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/function.html#nogc-functions, No-GC Functions)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/nogc.d, _nogc.d)
diff --git a/gcc/d/dmd/nspace.d b/gcc/d/dmd/nspace.d
index 40f2676..551db5b 100644
--- a/gcc/d/dmd/nspace.d
+++ b/gcc/d/dmd/nspace.d
@@ -36,7 +36,7 @@
* are valid D identifier.
*
* See_Also: https://github.com/dlang/dmd/pull/10031
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/nspace.d, _nspace.d)
@@ -55,6 +55,7 @@ import dmd.dsymbolsem;
import dmd.expression;
import dmd.globals;
import dmd.identifier;
+import dmd.location;
import dmd.visitor;
import core.stdc.stdio;
diff --git a/gcc/d/dmd/nspace.h b/gcc/d/dmd/nspace.h
index 9dbbdf2..e9fb7bd 100644
--- a/gcc/d/dmd/nspace.h
+++ b/gcc/d/dmd/nspace.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/ob.d b/gcc/d/dmd/ob.d
index 59f34e1..31e93a7 100644
--- a/gcc/d/dmd/ob.d
+++ b/gcc/d/dmd/ob.d
@@ -1,7 +1,7 @@
/**
* Flow analysis for Ownership/Borrowing
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/ob.d, _ob.d)
@@ -35,6 +35,7 @@ import dmd.func;
import dmd.globals;
import dmd.identifier;
import dmd.init;
+import dmd.location;
import dmd.mtype;
import dmd.printast;
import dmd.statement;
diff --git a/gcc/d/dmd/objc.d b/gcc/d/dmd/objc.d
index 2bb5eab..c493323 100644
--- a/gcc/d/dmd/objc.d
+++ b/gcc/d/dmd/objc.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/objc_interface.html, Interfacing to Objective-C)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/objc.d, _objc.d)
@@ -36,6 +36,7 @@ import dmd.gluelayer;
import dmd.hdrgen;
import dmd.id;
import dmd.identifier;
+import dmd.location;
import dmd.mtype;
import dmd.root.array;
import dmd.common.outbuffer;
diff --git a/gcc/d/dmd/objc.h b/gcc/d/dmd/objc.h
index a030154..305ce81 100644
--- a/gcc/d/dmd/objc.h
+++ b/gcc/d/dmd/objc.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 2015-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 2015-2023 by The D Language Foundation, All Rights Reserved
* written by Michel Fortin
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/opover.d b/gcc/d/dmd/opover.d
index de41727..4d7fe9f 100644
--- a/gcc/d/dmd/opover.d
+++ b/gcc/d/dmd/opover.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/operatoroverloading.html, Operator Overloading)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/opover.d, _opover.d)
@@ -32,6 +32,7 @@ import dmd.globals;
import dmd.hdrgen;
import dmd.id;
import dmd.identifier;
+import dmd.location;
import dmd.mtype;
import dmd.statement;
import dmd.tokens;
@@ -931,6 +932,12 @@ Expression op_overload(Expression e, Scope* sc, EXP* pop = null)
/* Rewrite as:
* .object.opEquals(e1, e2)
*/
+ if (!ClassDeclaration.object)
+ {
+ e.error("cannot compare classes for equality because `object.Object` was not declared");
+ return null;
+ }
+
Expression e1x = e.e1;
Expression e2x = e.e2;
diff --git a/gcc/d/dmd/optimize.d b/gcc/d/dmd/optimize.d
index a9c5425..b5d32b2 100644
--- a/gcc/d/dmd/optimize.d
+++ b/gcc/d/dmd/optimize.d
@@ -1,7 +1,7 @@
/**
* Perform constant folding.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/optimize.d, _optimize.d)
@@ -25,6 +25,7 @@ import dmd.expression;
import dmd.expressionsem;
import dmd.globals;
import dmd.init;
+import dmd.location;
import dmd.mtype;
import dmd.printast;
import dmd.root.ctfloat;
@@ -586,7 +587,7 @@ Expression Expression_optimize(Expression e, int result, bool keepLvalue)
Expression ex = new AddrExp(ae1.loc, ae1); // &a[i]
ex.type = ae1.type.pointerTo();
- Expression add = new AddExp(ae.loc, ex, new IntegerExp(ae.loc, offset, e.type));
+ Expression add = new AddExp(ae.loc, ex, new IntegerExp(ae.e2.loc, offset, ae.e2.type));
add.type = e.type;
ret = Expression_optimize(add, result, keepLvalue);
return;
@@ -862,7 +863,8 @@ Expression Expression_optimize(Expression e, int result, bool keepLvalue)
return returnE_e1(); // can always convert a class to Object
// Need to determine correct offset before optimizing away the cast.
// https://issues.dlang.org/show_bug.cgi?id=16980
- cdfrom.size(e.loc);
+ if (cdfrom.size(e.loc) == SIZE_INVALID)
+ return error();
assert(cdfrom.sizeok == Sizeok.done);
assert(cdto.sizeok == Sizeok.done || !cdto.isBaseOf(cdfrom, null));
int offset;
diff --git a/gcc/d/dmd/parse.d b/gcc/d/dmd/parse.d
index 93c7ea0..6eb3021 100644
--- a/gcc/d/dmd/parse.d
+++ b/gcc/d/dmd/parse.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/grammar.html, D Grammar)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/parse.d, _parse.d)
@@ -20,6 +20,7 @@ import dmd.globals;
import dmd.id;
import dmd.identifier;
import dmd.lexer;
+import dmd.location;
import dmd.errors;
import dmd.root.filename;
import dmd.common.outbuffer;
@@ -52,7 +53,8 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
*/
extern (D) this(const ref Loc loc, AST.Module _module, const(char)[] input, bool doDocComment)
{
- super(_module ? _module.srcfile.toChars() : null, input.ptr, 0, input.length, doDocComment, false);
+ super(_module ? _module.srcfile.toChars() : null, input.ptr, 0, input.length, doDocComment, false,
+ global.vendor, global.versionNumber());
//printf("Parser::Parser()\n");
scanloc = loc;
@@ -74,7 +76,8 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
extern (D) this(AST.Module _module, const(char)[] input, bool doDocComment)
{
- super(_module ? _module.srcfile.toChars() : null, input.ptr, 0, input.length, doDocComment, false);
+ super(_module ? _module.srcfile.toChars() : null, input.ptr, 0, input.length, doDocComment, false,
+ global.vendor, global.versionNumber());
//printf("Parser::Parser()\n");
mod = _module;
@@ -1982,7 +1985,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
{
const loc = token.loc;
AST.Expression exp;
- AST.Expression msg = null;
+ AST.Expressions* msg = null;
//printf("parseStaticAssert()\n");
nextToken();
@@ -1991,15 +1994,16 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
exp = parseAssignExp();
if (token.value == TOK.comma)
{
- nextToken();
- if (token.value != TOK.rightParenthesis)
+ if (peekNext() == TOK.rightParenthesis)
{
- msg = parseAssignExp();
- if (token.value == TOK.comma)
- nextToken();
+ nextToken(); // consume `,`
+ nextToken(); // consume `)`
}
+ else
+ msg = parseArguments();
}
- check(TOK.rightParenthesis);
+ else
+ check(TOK.rightParenthesis);
check(TOK.semicolon, "static assert");
return new AST.StaticAssert(loc, exp, msg);
}
@@ -5719,6 +5723,8 @@ LagainStc:
s = null;
else if (token.value == TOK.leftCurly)
s = parseStatement(ParseStatementFlags.curly | ParseStatementFlags.scope_);
+ else if (flags & ParseStatementFlags.curlyScope)
+ s = parseStatement(ParseStatementFlags.semiOk | ParseStatementFlags.curlyScope);
else
s = parseStatement(ParseStatementFlags.semiOk);
s = new AST.LabelStatement(loc, ident, s);
diff --git a/gcc/d/dmd/printast.d b/gcc/d/dmd/printast.d
index 8c71a1a..9975c9c 100644
--- a/gcc/d/dmd/printast.d
+++ b/gcc/d/dmd/printast.d
@@ -1,7 +1,7 @@
/**
* Provides an AST printer for debugging.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/printast.d, _printast.d)
diff --git a/gcc/d/dmd/root/aav.d b/gcc/d/dmd/root/aav.d
index beceb0f0..42d1399 100644
--- a/gcc/d/dmd/root/aav.d
+++ b/gcc/d/dmd/root/aav.d
@@ -1,7 +1,7 @@
/**
* Associative array implementation.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: Walter Bright, https://www.digitalmars.com
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/aav.d, root/_aav.d)
diff --git a/gcc/d/dmd/root/array.d b/gcc/d/dmd/root/array.d
index 5c01940..e352c61 100644
--- a/gcc/d/dmd/root/array.d
+++ b/gcc/d/dmd/root/array.d
@@ -2,7 +2,7 @@
/**
* Dynamic array implementation.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/array.d, root/_array.d)
diff --git a/gcc/d/dmd/root/array.h b/gcc/d/dmd/root/array.h
index 52bed5e..ebe2c47 100644
--- a/gcc/d/dmd/root/array.h
+++ b/gcc/d/dmd/root/array.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011-2022 by The D Language Foundation, All Rights Reserved
+/* Copyright (C) 2011-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/root/bitarray.d b/gcc/d/dmd/root/bitarray.d
index 90cbaed..66adab6 100644
--- a/gcc/d/dmd/root/bitarray.d
+++ b/gcc/d/dmd/root/bitarray.d
@@ -1,7 +1,7 @@
/**
* Implementation of a bit array.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/bitarray.d, root/_bitarray.d)
diff --git a/gcc/d/dmd/root/bitarray.h b/gcc/d/dmd/root/bitarray.h
index c5c5d3a..617cc9e 100644
--- a/gcc/d/dmd/root/bitarray.h
+++ b/gcc/d/dmd/root/bitarray.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011-2022 by The D Language Foundation, All Rights Reserved
+/* Copyright (C) 2011-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/root/complex.d b/gcc/d/dmd/root/complex.d
index a7a7438..fc93bd7 100644
--- a/gcc/d/dmd/root/complex.d
+++ b/gcc/d/dmd/root/complex.d
@@ -1,7 +1,7 @@
/**
* Implements a complex number type.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/complex.d, _complex.d)
diff --git a/gcc/d/dmd/root/complex_t.h b/gcc/d/dmd/root/complex_t.h
index c384848..de2040b 100644
--- a/gcc/d/dmd/root/complex_t.h
+++ b/gcc/d/dmd/root/complex_t.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/root/ctfloat.d b/gcc/d/dmd/root/ctfloat.d
index 8c2fe46..cd336e6 100644
--- a/gcc/d/dmd/root/ctfloat.d
+++ b/gcc/d/dmd/root/ctfloat.d
@@ -1,7 +1,7 @@
/**
* Collects functions for compile-time floating-point calculations.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/ctfloat.d, root/_ctfloat.d)
diff --git a/gcc/d/dmd/root/ctfloat.h b/gcc/d/dmd/root/ctfloat.h
index 5a6cf25..44bd959e 100644
--- a/gcc/d/dmd/root/ctfloat.h
+++ b/gcc/d/dmd/root/ctfloat.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+/* Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/root/dcompat.h b/gcc/d/dmd/root/dcompat.h
index 5823e7c..0bc23b7 100644
--- a/gcc/d/dmd/root/dcompat.h
+++ b/gcc/d/dmd/root/dcompat.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+/* Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/root/file.d b/gcc/d/dmd/root/file.d
index b40413c..1fb1056 100644
--- a/gcc/d/dmd/root/file.d
+++ b/gcc/d/dmd/root/file.d
@@ -1,7 +1,7 @@
/**
* Read a file from disk and store it in memory.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: Walter Bright, https://www.digitalmars.com
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/file.d, root/_file.d)
diff --git a/gcc/d/dmd/root/filename.d b/gcc/d/dmd/root/filename.d
index f6a4515..33f4a7a 100644
--- a/gcc/d/dmd/root/filename.d
+++ b/gcc/d/dmd/root/filename.d
@@ -1,7 +1,7 @@
/**
* Encapsulate path and file names.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: Walter Bright, https://www.digitalmars.com
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/filename.d, root/_filename.d)
diff --git a/gcc/d/dmd/root/filename.h b/gcc/d/dmd/root/filename.h
index 419a4c9..8977411 100644
--- a/gcc/d/dmd/root/filename.h
+++ b/gcc/d/dmd/root/filename.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+/* Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/root/hash.d b/gcc/d/dmd/root/hash.d
index fe97c42..2acee35 100644
--- a/gcc/d/dmd/root/hash.d
+++ b/gcc/d/dmd/root/hash.d
@@ -1,7 +1,7 @@
/**
* Hash functions for arbitrary binary data.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: Martin Nowak, Walter Bright, https://www.digitalmars.com
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/hash.d, root/_hash.d)
diff --git a/gcc/d/dmd/root/object.h b/gcc/d/dmd/root/object.h
index b735dd9..8e505f0 100644
--- a/gcc/d/dmd/root/object.h
+++ b/gcc/d/dmd/root/object.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+/* Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/root/optional.d b/gcc/d/dmd/root/optional.d
index 266846b..bc1016b 100644
--- a/gcc/d/dmd/root/optional.d
+++ b/gcc/d/dmd/root/optional.d
@@ -1,7 +1,7 @@
/**
* Implementation of an 'Optional' type
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/optional.d, root/_optional.d)
diff --git a/gcc/d/dmd/root/optional.h b/gcc/d/dmd/root/optional.h
index e4a41a0..cc2ee79 100644
--- a/gcc/d/dmd/root/optional.h
+++ b/gcc/d/dmd/root/optional.h
@@ -3,7 +3,7 @@
/**
* Optional implementation.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/optional.h, root/_optional.h)
diff --git a/gcc/d/dmd/root/port.d b/gcc/d/dmd/root/port.d
index 0c8088c..290280f 100644
--- a/gcc/d/dmd/root/port.d
+++ b/gcc/d/dmd/root/port.d
@@ -1,7 +1,7 @@
/**
* Portable routines for functions that have different implementations on different platforms.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: Walter Bright, https://www.digitalmars.com
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/port.d, root/_port.d)
diff --git a/gcc/d/dmd/root/port.h b/gcc/d/dmd/root/port.h
index 66a6760..6fa3c00 100644
--- a/gcc/d/dmd/root/port.h
+++ b/gcc/d/dmd/root/port.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+/* Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/root/region.d b/gcc/d/dmd/root/region.d
index 1e86f32..9fc57f1 100644
--- a/gcc/d/dmd/root/region.d
+++ b/gcc/d/dmd/root/region.d
@@ -1,7 +1,7 @@
/**
* Region storage allocator implementation.
*
- * Copyright: Copyright (C) 2019-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 2019-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/region.d, root/_region.d)
diff --git a/gcc/d/dmd/root/rmem.d b/gcc/d/dmd/root/rmem.d
index ffe5ee1..9b1d9fb 100644
--- a/gcc/d/dmd/root/rmem.d
+++ b/gcc/d/dmd/root/rmem.d
@@ -1,7 +1,7 @@
/**
* Allocate memory using `malloc` or the GC depending on the configuration.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: Walter Bright, https://www.digitalmars.com
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/rmem.d, root/_rmem.d)
diff --git a/gcc/d/dmd/root/rmem.h b/gcc/d/dmd/root/rmem.h
index 1338d7c..36aa264 100644
--- a/gcc/d/dmd/root/rmem.h
+++ b/gcc/d/dmd/root/rmem.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+/* Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/root/rootobject.d b/gcc/d/dmd/root/rootobject.d
index 7390d07..4437d16 100644
--- a/gcc/d/dmd/root/rootobject.d
+++ b/gcc/d/dmd/root/rootobject.d
@@ -1,7 +1,7 @@
/**
* Provide the root object that classes in dmd inherit from.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: Walter Bright, https://www.digitalmars.com
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/rootobject.d, root/_rootobject.d)
diff --git a/gcc/d/dmd/root/speller.d b/gcc/d/dmd/root/speller.d
index 9b9460d..b646bdd 100644
--- a/gcc/d/dmd/root/speller.d
+++ b/gcc/d/dmd/root/speller.d
@@ -3,7 +3,7 @@
*
* Does not have any dependencies on the rest of DMD.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: Walter Bright, https://www.digitalmars.com
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/speller.d, root/_speller.d)
diff --git a/gcc/d/dmd/root/string.d b/gcc/d/dmd/root/string.d
index 93c596f..8b204ab 100644
--- a/gcc/d/dmd/root/string.d
+++ b/gcc/d/dmd/root/string.d
@@ -1,7 +1,7 @@
/**
* Contains various string related functions.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: Walter Bright, https://www.digitalmars.com
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/string.d, root/_string.d)
diff --git a/gcc/d/dmd/root/stringtable.d b/gcc/d/dmd/root/stringtable.d
index 20316fa..de293eb 100644
--- a/gcc/d/dmd/root/stringtable.d
+++ b/gcc/d/dmd/root/stringtable.d
@@ -1,7 +1,7 @@
/**
* A specialized associative array with string keys stored in a variable length structure.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: Walter Bright, https://www.digitalmars.com
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/stringtable.d, root/_stringtable.d)
diff --git a/gcc/d/dmd/root/utf.d b/gcc/d/dmd/root/utf.d
index 0d230e7..c9781a4 100644
--- a/gcc/d/dmd/root/utf.d
+++ b/gcc/d/dmd/root/utf.d
@@ -1,7 +1,7 @@
/**
* Functions related to UTF encoding.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/utf.d, _utf.d)
diff --git a/gcc/d/dmd/safe.d b/gcc/d/dmd/safe.d
index 397fd2ef..c3fa90d 100644
--- a/gcc/d/dmd/safe.d
+++ b/gcc/d/dmd/safe.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/function.html#function-safety, Function Safety)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/safe.d, _safe.d)
diff --git a/gcc/d/dmd/sapply.d b/gcc/d/dmd/sapply.d
index adfae32..8486028 100644
--- a/gcc/d/dmd/sapply.d
+++ b/gcc/d/dmd/sapply.d
@@ -1,7 +1,7 @@
/**
* Provides a depth-first statement visitor.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/sparse.d, _sparse.d)
diff --git a/gcc/d/dmd/scope.h b/gcc/d/dmd/scope.h
index 8b9e59e..b25c26a 100644
--- a/gcc/d/dmd/scope.h
+++ b/gcc/d/dmd/scope.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/semantic2.d b/gcc/d/dmd/semantic2.d
index 4795bcf..c103f60 100644
--- a/gcc/d/dmd/semantic2.d
+++ b/gcc/d/dmd/semantic2.d
@@ -1,7 +1,7 @@
/**
* Performs the semantic2 stage, which deals with initializer expressions.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/semantic2.d, _semantic2.d)
@@ -110,21 +110,36 @@ private extern(C++) final class Semantic2Visitor : Visitor
else if (result)
return;
- if (sa.msg)
+ if (sa.msgs)
{
- sc = sc.startCTFE();
- sa.msg = sa.msg.expressionSemantic(sc);
- sa.msg = resolveProperties(sc, sa.msg);
- sc = sc.endCTFE();
- sa.msg = sa.msg.ctfeInterpret();
- if (StringExp se = sa.msg.toStringExp())
+ OutBuffer msgbuf;
+ for (size_t i = 0; i < sa.msgs.length; i++)
{
- // same with pragma(msg)
- const slice = se.toUTF8(sc).peekString();
- error(sa.loc, "static assert: \"%.*s\"", cast(int)slice.length, slice.ptr);
+ Expression e = (*sa.msgs)[i];
+ sc = sc.startCTFE();
+ e = e.expressionSemantic(sc);
+ e = resolveProperties(sc, e);
+ sc = sc.endCTFE();
+ e = ctfeInterpretForPragmaMsg(e);
+ if (e.op == EXP.error)
+ {
+ errorSupplemental(sa.loc, "while evaluating `static assert` argument `%s`", (*sa.msgs)[i].toChars());
+ return;
+ }
+ StringExp se = e.toStringExp();
+ if (se)
+ {
+ const slice = se.toUTF8(sc).peekString();
+ // Hack to keep old formatting to avoid changing error messages everywhere
+ if (sa.msgs.length == 1)
+ msgbuf.printf("\"%.*s\"", cast(int)slice.length, slice.ptr);
+ else
+ msgbuf.printf("%.*s", cast(int)slice.length, slice.ptr);
+ }
+ else
+ msgbuf.printf("%s", e.toChars());
}
- else
- error(sa.loc, "static assert: %s", sa.msg.toChars());
+ error(sa.loc, "static assert: %s", msgbuf.extractChars());
}
else
error(sa.loc, "static assert: `%s` is false", sa.exp.toChars());
diff --git a/gcc/d/dmd/semantic3.d b/gcc/d/dmd/semantic3.d
index cc75aa5..78da4a1 100644
--- a/gcc/d/dmd/semantic3.d
+++ b/gcc/d/dmd/semantic3.d
@@ -1,7 +1,7 @@
/**
* Performs the semantic3 stage, which deals with function bodies.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/semantic3.d, _semantic3.d)
@@ -47,6 +47,7 @@ import dmd.identifier;
import dmd.init;
import dmd.initsem;
import dmd.hdrgen;
+import dmd.location;
import dmd.mtype;
import dmd.nogc;
import dmd.nspace;
diff --git a/gcc/d/dmd/sideeffect.d b/gcc/d/dmd/sideeffect.d
index f7a3836..ed93876 100644
--- a/gcc/d/dmd/sideeffect.d
+++ b/gcc/d/dmd/sideeffect.d
@@ -1,7 +1,7 @@
/**
* Find side-effects of expressions.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/sideeffect.d, _sideeffect.d)
diff --git a/gcc/d/dmd/statement.d b/gcc/d/dmd/statement.d
index 91a802e..96c59ba 100644
--- a/gcc/d/dmd/statement.d
+++ b/gcc/d/dmd/statement.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/statement.html, Statements)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/statement.d, _statement.d)
@@ -36,6 +36,7 @@ import dmd.globals;
import dmd.hdrgen;
import dmd.id;
import dmd.identifier;
+import dmd.location;
import dmd.dinterpret;
import dmd.mtype;
import dmd.common.outbuffer;
@@ -323,6 +324,10 @@ extern (C++) abstract class Statement : ASTNode
override void visit(DefaultStatement s)
{
}
+
+ override void visit(LabelStatement s)
+ {
+ }
}
scope HasCode hc = new HasCode();
diff --git a/gcc/d/dmd/statement.h b/gcc/d/dmd/statement.h
index 681b481..76a3991 100644
--- a/gcc/d/dmd/statement.h
+++ b/gcc/d/dmd/statement.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/statement_rewrite_walker.d b/gcc/d/dmd/statement_rewrite_walker.d
index 7b3a13b..dcdd963 100644
--- a/gcc/d/dmd/statement_rewrite_walker.d
+++ b/gcc/d/dmd/statement_rewrite_walker.d
@@ -1,7 +1,7 @@
/**
* Provides a visitor for statements that allows rewriting the currently visited node.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/statement_rewrite_walker.d, _statement_rewrite_walker.d)
diff --git a/gcc/d/dmd/statementsem.d b/gcc/d/dmd/statementsem.d
index b372fc2..5764efd 100644
--- a/gcc/d/dmd/statementsem.d
+++ b/gcc/d/dmd/statementsem.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/statement.html, Statements)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/statementsem.d, _statementsem.d)
@@ -50,6 +50,7 @@ import dmd.identifier;
import dmd.importc;
import dmd.init;
import dmd.intrange;
+import dmd.location;
import dmd.mtype;
import dmd.mustuse;
import dmd.nogc;
diff --git a/gcc/d/dmd/staticassert.d b/gcc/d/dmd/staticassert.d
index c7d3148..15c46b3 100644
--- a/gcc/d/dmd/staticassert.d
+++ b/gcc/d/dmd/staticassert.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/version.html#static-assert, Static Assert)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/staticassert.d, _staticassert.d)
@@ -13,10 +13,12 @@
module dmd.staticassert;
+import dmd.arraytypes;
import dmd.dscope;
import dmd.dsymbol;
import dmd.expression;
import dmd.globals;
+import dmd.location;
import dmd.id;
import dmd.identifier;
import dmd.mtype;
@@ -27,19 +29,27 @@ import dmd.visitor;
extern (C++) final class StaticAssert : Dsymbol
{
Expression exp;
- Expression msg;
+ Expressions* msgs;
extern (D) this(const ref Loc loc, Expression exp, Expression msg)
{
super(loc, Id.empty);
this.exp = exp;
- this.msg = msg;
+ this.msgs = new Expressions(1);
+ (*this.msgs)[0] = msg;
+ }
+
+ extern (D) this(const ref Loc loc, Expression exp, Expressions* msgs)
+ {
+ super(loc, Id.empty);
+ this.exp = exp;
+ this.msgs = msgs;
}
override StaticAssert syntaxCopy(Dsymbol s)
{
assert(!s);
- return new StaticAssert(loc, exp.syntaxCopy(), msg ? msg.syntaxCopy() : null);
+ return new StaticAssert(loc, exp.syntaxCopy(), msgs ? Expression.arraySyntaxCopy(msgs) : null);
}
override void addMember(Scope* sc, ScopeDsymbol sds)
diff --git a/gcc/d/dmd/staticassert.h b/gcc/d/dmd/staticassert.h
index d938990..2b7d300 100644
--- a/gcc/d/dmd/staticassert.h
+++ b/gcc/d/dmd/staticassert.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
@@ -18,7 +18,7 @@ class StaticAssert : public Dsymbol
{
public:
Expression *exp;
- Expression *msg;
+ Expressions *msg;
StaticAssert *syntaxCopy(Dsymbol *s) override;
void addMember(Scope *sc, ScopeDsymbol *sds) override;
diff --git a/gcc/d/dmd/staticcond.d b/gcc/d/dmd/staticcond.d
index 0cbdd96..aa6f37c 100644
--- a/gcc/d/dmd/staticcond.d
+++ b/gcc/d/dmd/staticcond.d
@@ -1,7 +1,7 @@
/**
* Lazily evaluate static conditions for `static if`, `static assert` and template constraints.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/staticcond.d, _staticcond.d)
diff --git a/gcc/d/dmd/stmtstate.d b/gcc/d/dmd/stmtstate.d
index 3e26b8f..7b2ea97 100644
--- a/gcc/d/dmd/stmtstate.d
+++ b/gcc/d/dmd/stmtstate.d
@@ -1,7 +1,7 @@
/**
* Used to help transform statement AST into flow graph.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/stmtstate.d, _stmtstate.d)
diff --git a/gcc/d/dmd/target.d b/gcc/d/dmd/target.d
index eb85c67..fddfd54 100644
--- a/gcc/d/dmd/target.d
+++ b/gcc/d/dmd/target.d
@@ -15,7 +15,7 @@
* - $(LINK2 https://github.com/ldc-developers/ldc, LDC repository)
* - $(LINK2 https://github.com/D-Programming-GDC/gcc, GDC repository)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/target.d, _target.d)
@@ -61,7 +61,7 @@ extern (C++) struct Target
import dmd.dscope : Scope;
import dmd.expression : Expression;
import dmd.func : FuncDeclaration;
- import dmd.globals : Loc;
+ import dmd.location;
import dmd.astenums : LINK, TY;
import dmd.mtype : Type, TypeFunction, TypeTuple;
import dmd.root.ctfloat : real_t;
diff --git a/gcc/d/dmd/target.h b/gcc/d/dmd/target.h
index 096c16f..ef2c09d 100644
--- a/gcc/d/dmd/target.h
+++ b/gcc/d/dmd/target.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 2013-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 2013-2023 by The D Language Foundation, All Rights Reserved
* written by Iain Buclaw
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/template.h b/gcc/d/dmd/template.h
index 9ad027a..8e8ba16 100644
--- a/gcc/d/dmd/template.h
+++ b/gcc/d/dmd/template.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
@@ -70,7 +70,6 @@ public:
bool isTrivialAlias; // matches pattern `template Alias(T) { alias Alias = qualifiers(T); }`
bool deprecated_; // this template declaration is deprecated
Visibility visibility;
- int inuse; // for recursive expansion detection
TemplatePrevious *previous; // threaded list of previous instantiation attempts on stack
diff --git a/gcc/d/dmd/templateparamsem.d b/gcc/d/dmd/templateparamsem.d
index e79a9ec..432daee 100644
--- a/gcc/d/dmd/templateparamsem.d
+++ b/gcc/d/dmd/templateparamsem.d
@@ -1,7 +1,7 @@
/**
* Semantic analysis of template parameters.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/templateparamsem.d, _templateparamsem.d)
@@ -16,6 +16,7 @@ import dmd.dsymbol;
import dmd.dscope;
import dmd.dtemplate;
import dmd.globals;
+import dmd.location;
import dmd.expression;
import dmd.expressionsem;
import dmd.root.rootobject;
diff --git a/gcc/d/dmd/tokens.d b/gcc/d/dmd/tokens.d
index 86abedf..b3cd2d3 100644
--- a/gcc/d/dmd/tokens.d
+++ b/gcc/d/dmd/tokens.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/lex.html#tokens, Tokens)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/tokens.d, _tokens.d)
@@ -16,8 +16,8 @@ module dmd.tokens;
import core.stdc.ctype;
import core.stdc.stdio;
import core.stdc.string;
-import dmd.globals;
import dmd.identifier;
+import dmd.location;
import dmd.root.ctfloat;
import dmd.common.outbuffer;
import dmd.root.rmem;
@@ -636,8 +636,8 @@ extern (C++) struct Token
union
{
// Integers
- sinteger_t intvalue;
- uinteger_t unsvalue;
+ long intvalue;
+ ulong unsvalue;
// Floats
real_t floatvalue;
diff --git a/gcc/d/dmd/tokens.h b/gcc/d/dmd/tokens.h
index 35fd68b..32ae5f4 100644
--- a/gcc/d/dmd/tokens.h
+++ b/gcc/d/dmd/tokens.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/traits.d b/gcc/d/dmd/traits.d
index a6d2304..048c24f 100644
--- a/gcc/d/dmd/traits.d
+++ b/gcc/d/dmd/traits.d
@@ -3,7 +3,7 @@
*
* Specification: $(LINK2 https://dlang.org/spec/traits.html, Traits)
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/traits.d, _traits.d)
@@ -38,6 +38,7 @@ import dmd.globals;
import dmd.hdrgen;
import dmd.id;
import dmd.identifier;
+import dmd.location;
import dmd.mtype;
import dmd.nogc;
import dmd.parse;
@@ -88,82 +89,6 @@ private Dsymbol getDsymbolWithoutExpCtx(RootObject oarg)
return getDsymbol(oarg);
}
-private const StringTable!bool traitsStringTable;
-
-shared static this()
-{
- static immutable string[] names =
- [
- "isAbstractClass",
- "isArithmetic",
- "isAssociativeArray",
- "isDisabled",
- "isDeprecated",
- "isFuture",
- "isFinalClass",
- "isPOD",
- "isNested",
- "isFloating",
- "isIntegral",
- "isScalar",
- "isStaticArray",
- "isUnsigned",
- "isVirtualFunction",
- "isVirtualMethod",
- "isAbstractFunction",
- "isFinalFunction",
- "isOverrideFunction",
- "isStaticFunction",
- "isModule",
- "isPackage",
- "isRef",
- "isOut",
- "isLazy",
- "isReturnOnStack",
- "hasMember",
- "identifier",
- "getProtection",
- "getVisibility",
- "parent",
- "child",
- "getLinkage",
- "getMember",
- "getOverloads",
- "getVirtualFunctions",
- "getVirtualMethods",
- "classInstanceSize",
- "classInstanceAlignment",
- "allMembers",
- "derivedMembers",
- "isSame",
- "compiles",
- "getAliasThis",
- "getAttributes",
- "getFunctionAttributes",
- "getFunctionVariadicStyle",
- "getParameterStorageClasses",
- "getUnitTests",
- "getVirtualIndex",
- "getPointerBitmap",
- "isZeroInit",
- "getTargetInfo",
- "getLocation",
- "hasPostblit",
- "hasCopyConstructor",
- "isCopyable",
- "parameters"
- ];
-
- StringTable!(bool)* stringTable = cast(StringTable!(bool)*) &traitsStringTable;
- stringTable._init(names.length);
-
- foreach (s; names)
- {
- auto sv = stringTable.insert(s, true);
- assert(sv);
- }
-}
-
/**
* get an array of size_t values that indicate possible pointer words in memory
* if interpreted as the type given as argument
@@ -2122,20 +2047,11 @@ Expression semanticTraits(TraitsExp e, Scope* sc)
auto tup = new TupleExp(e.loc, exps);
return tup.expressionSemantic(sc);
}
- static const(char)[] trait_search_fp(const(char)[] seed, out int cost)
- {
- //printf("trait_search_fp('%s')\n", seed);
- if (!seed.length)
- return null;
- cost = 0; // all the same cost
- const sv = traitsStringTable.lookup(seed);
- return sv ? sv.toString() : null;
- }
- if (auto sub = speller!trait_search_fp(e.ident.toString()))
- e.error("unrecognized trait `%s`, did you mean `%.*s`?", e.ident.toChars(), cast(int) sub.length, sub.ptr);
- else
- e.error("unrecognized trait `%s`", e.ident.toChars());
+ /* Can't find the identifier. Try a spell check for a better error message
+ */
+ traitNotFound(e);
+
return ErrorExp.get();
}
@@ -2263,3 +2179,108 @@ Lnext:
}
return true;
}
+
+
+/***********************************
+ * A trait was not found. Give a decent error message
+ * by trying a spell check.
+ * Params:
+ * e = the offending trait
+ */
+private void traitNotFound(TraitsExp e)
+{
+ __gshared const StringTable!bool traitsStringTable;
+ __gshared bool initialized;
+
+ if (!initialized)
+ {
+ initialized = true; // lazy initialization
+
+ // All possible traits
+ __gshared Identifier*[58] idents =
+ [
+ &Id.isAbstractClass,
+ &Id.isArithmetic,
+ &Id.isAssociativeArray,
+ &Id.isDisabled,
+ &Id.isDeprecated,
+ &Id.isFuture,
+ &Id.isFinalClass,
+ &Id.isPOD,
+ &Id.isNested,
+ &Id.isFloating,
+ &Id.isIntegral,
+ &Id.isScalar,
+ &Id.isStaticArray,
+ &Id.isUnsigned,
+ &Id.isVirtualFunction,
+ &Id.isVirtualMethod,
+ &Id.isAbstractFunction,
+ &Id.isFinalFunction,
+ &Id.isOverrideFunction,
+ &Id.isStaticFunction,
+ &Id.isModule,
+ &Id.isPackage,
+ &Id.isRef,
+ &Id.isOut,
+ &Id.isLazy,
+ &Id.isReturnOnStack,
+ &Id.hasMember,
+ &Id.identifier,
+ &Id.getProtection,
+ &Id.getVisibility,
+ &Id.parent,
+ &Id.child,
+ &Id.getLinkage,
+ &Id.getMember,
+ &Id.getOverloads,
+ &Id.getVirtualFunctions,
+ &Id.getVirtualMethods,
+ &Id.classInstanceSize,
+ &Id.classInstanceAlignment,
+ &Id.allMembers,
+ &Id.derivedMembers,
+ &Id.isSame,
+ &Id.compiles,
+ &Id.getAliasThis,
+ &Id.getAttributes,
+ &Id.getFunctionAttributes,
+ &Id.getFunctionVariadicStyle,
+ &Id.getParameterStorageClasses,
+ &Id.getUnitTests,
+ &Id.getVirtualIndex,
+ &Id.getPointerBitmap,
+ &Id.isZeroInit,
+ &Id.getTargetInfo,
+ &Id.getLocation,
+ &Id.hasPostblit,
+ &Id.hasCopyConstructor,
+ &Id.isCopyable,
+ &Id.parameters,
+ ];
+
+ StringTable!(bool)* stringTable = cast(StringTable!(bool)*) &traitsStringTable;
+ stringTable._init(idents.length);
+
+ foreach (id; idents)
+ {
+ auto sv = stringTable.insert((*id).toString(), true);
+ assert(sv);
+ }
+ }
+
+ static const(char)[] trait_search_fp(const(char)[] seed, out int cost)
+ {
+ //printf("trait_search_fp('%s')\n", seed);
+ if (!seed.length)
+ return null;
+ cost = 0; // all the same cost
+ const sv = traitsStringTable.lookup(seed);
+ return sv ? sv.toString() : null;
+ }
+
+ if (auto sub = speller!trait_search_fp(e.ident.toString()))
+ e.error("unrecognized trait `%s`, did you mean `%.*s`?", e.ident.toChars(), cast(int) sub.length, sub.ptr);
+ else
+ e.error("unrecognized trait `%s`", e.ident.toChars());
+}
diff --git a/gcc/d/dmd/transitivevisitor.d b/gcc/d/dmd/transitivevisitor.d
index 7aaf0b8..5844911 100644
--- a/gcc/d/dmd/transitivevisitor.d
+++ b/gcc/d/dmd/transitivevisitor.d
@@ -490,8 +490,9 @@ package mixin template ParseVisitMethods(AST)
{
//printf("Visiting StaticAssert\n");
s.exp.accept(this);
- if (s.msg)
- s.msg.accept(this);
+ if (s.msgs)
+ foreach (m; (*s.msgs)[])
+ m.accept(this);
}
override void visit(AST.EnumMember em)
diff --git a/gcc/d/dmd/typesem.d b/gcc/d/dmd/typesem.d
index a75b416..0d64ba4 100644
--- a/gcc/d/dmd/typesem.d
+++ b/gcc/d/dmd/typesem.d
@@ -1,7 +1,7 @@
/**
* Semantic analysis for D types.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/typesem.d, _typesem.d)
@@ -46,6 +46,7 @@ import dmd.imphint;
import dmd.importc;
import dmd.init;
import dmd.initsem;
+import dmd.location;
import dmd.visitor;
import dmd.mtype;
import dmd.objc;
@@ -234,7 +235,7 @@ private void resolveHelper(TypeQualified mt, const ref Loc loc, Scope* sc, Dsymb
.error(loc, "`%s` is not visible from module `%s`", sm.toPrettyChars(), sc._module.toChars());
sm = null;
}
- // Same check as in Expression.semanticY(DotIdExp)
+ // Same check as in dotIdSemanticProp(DotIdExp)
else if (sm.isPackage() && checkAccess(sc, sm.isPackage()))
{
// @@@DEPRECATED_2.106@@@
@@ -3685,7 +3686,7 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, int flag)
* template opDispatch(name) if (isValid!name) { ... }
*/
uint errors = gagError ? global.startGagging() : 0;
- e = dti.semanticY(sc, 0);
+ e = dti.dotTemplateSemanticProp(sc, 0);
if (gagError && global.endGagging(errors))
e = null;
return returnExp(e);
@@ -3703,7 +3704,7 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, int flag)
auto die = new DotIdExp(e.loc, alias_e, ident);
auto errors = gagError ? 0 : global.startGagging();
- auto exp = die.semanticY(sc, gagError);
+ auto exp = die.dotIdSemanticProp(sc, gagError);
if (!gagError)
{
global.endGagging(errors);
@@ -3959,7 +3960,14 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, int flag)
Dsymbol s = mt.sym.search(e.loc, ident);
if (!s)
{
- if (ident == Id.max || ident == Id.min || ident == Id._init)
+ if (ident == Id._init)
+ {
+ return mt.getProperty(sc, e.loc, ident, flag & 1);
+ }
+
+ /* Allow special enums to not need a member list
+ */
+ if ((ident == Id.max || ident == Id.min) && (mt.sym.members || !mt.sym.isSpecial()))
{
return mt.getProperty(sc, e.loc, ident, flag & 1);
}
@@ -4880,13 +4888,6 @@ Expression getMaxMinValue(EnumDeclaration ed, const ref Loc loc, Identifier id)
return errorReturn();
if (!ed.members)
{
- if (ed.isSpecial())
- {
- /* Allow these special enums to not need a member list
- */
- return ed.memtype.getProperty(ed._scope, loc, id, 0);
- }
-
ed.error(loc, "is opaque and has no `.%s`", id.toChars());
return errorReturn();
}
diff --git a/gcc/d/dmd/typinf.d b/gcc/d/dmd/typinf.d
index b701be3..b35e03d 100644
--- a/gcc/d/dmd/typinf.d
+++ b/gcc/d/dmd/typinf.d
@@ -1,7 +1,7 @@
/**
* Generate `TypeInfo` objects, which are needed for run-time introspection of types.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/typeinf.d, _typeinf.d)
@@ -21,6 +21,7 @@ import dmd.errors;
import dmd.expression;
import dmd.globals;
import dmd.gluelayer;
+import dmd.location;
import dmd.mtype;
import dmd.visitor;
import core.stdc.stdio;
diff --git a/gcc/d/dmd/utils.d b/gcc/d/dmd/utils.d
index 5be4a19..dfb4cb5 100644
--- a/gcc/d/dmd/utils.d
+++ b/gcc/d/dmd/utils.d
@@ -1,7 +1,7 @@
/**
* This module defines some utility functions for DMD.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/utils.d, _utils.d)
@@ -13,7 +13,7 @@ module dmd.utils;
import core.stdc.string;
import dmd.errors;
-import dmd.globals;
+import dmd.location;
import dmd.root.file;
import dmd.root.filename;
import dmd.common.outbuffer;
diff --git a/gcc/d/dmd/version.h b/gcc/d/dmd/version.h
index b76393b..697d46e 100644
--- a/gcc/d/dmd/version.h
+++ b/gcc/d/dmd/version.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
diff --git a/gcc/d/dmd/visitor.d b/gcc/d/dmd/visitor.d
index e6dfa11..e4c2a91 100644
--- a/gcc/d/dmd/visitor.d
+++ b/gcc/d/dmd/visitor.d
@@ -1,7 +1,7 @@
/**
* Provides a visitor class visiting all AST nodes present in the compiler.
*
- * Copyright: Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/visitor.d, _visitor.d)
diff --git a/gcc/d/dmd/visitor.h b/gcc/d/dmd/visitor.h
index b45ef79..f8cbdb4 100644
--- a/gcc/d/dmd/visitor.h
+++ b/gcc/d/dmd/visitor.h
@@ -1,6 +1,6 @@
/* Compiler implementation of the D programming language
- * Copyright (C) 2013-2022 by The D Language Foundation, All Rights Reserved
+ * Copyright (C) 2013-2023 by The D Language Foundation, All Rights Reserved
* https://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
* https://www.boost.org/LICENSE_1_0.txt
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 078d29d..bcf8510 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -428,6 +428,7 @@ Objective-C and Objective-C++ Dialects}.
-fanalyzer-fine-grained @gol
-fno-analyzer-state-merge @gol
-fno-analyzer-state-purge @gol
+-fno-analyzer-suppress-followups @gol
-fanalyzer-transitivity @gol
-fno-analyzer-undo-inlining @gol
-fanalyzer-verbose-edges @gol
@@ -11012,6 +11013,30 @@ and which aren't relevant to leak analysis.
With @option{-fno-analyzer-state-purge} this purging of state can
be suppressed, for debugging state-handling issues.
+@item -fno-analyzer-suppress-followups
+@opindex fanalyzer-suppress-followups
+@opindex fno-analyzer-suppress-followups
+This option is intended for analyzer developers.
+
+By default the analyzer will stop exploring an execution path after
+encountering certain diagnostics, in order to avoid potentially issuing a
+cascade of follow-up diagnostics.
+
+The diagnostics that terminate analysis along a path are:
+
+@itemize
+@item @option{-Wanalyzer-null-argument}
+@item @option{-Wanalyzer-null-dereference}
+@item @option{-Wanalyzer-use-after-free}
+@item @option{-Wanalyzer-use-of-pointer-in-stale-stack-frame}
+@item @option{-Wanalyzer-use-of-uninitialized-value}
+@end itemize
+
+With @option{-fno-analyzer-suppress-followups} the analyzer will
+continue to explore such paths even after such diagnostics, which may
+be helpful for debugging issues in the analyzer, or for microbenchmarks
+for detecting undefined behavior.
+
@item -fanalyzer-transitivity
@opindex fanalyzer-transitivity
@opindex fno-analyzer-transitivity
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 2253b6e..45591f1 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,12 @@
+2023-02-21 Harald Anlauf <anlauf@gmx.de>
+
+ PR fortran/96025
+ * parse.cc (check_function_result_typed): Improve type check of
+ specification expression for character length and return status.
+ (parse_spec): Use status from above.
+ * resolve.cc (resolve_fntype): Prevent use of invalid specification
+ expression for character length.
+
2023-02-16 Patrick Palka <ppalka@redhat.com>
* gfortran.h: Mechanically drop static from static inline
diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc
index f5154d9..f1e55316 100644
--- a/gcc/fortran/parse.cc
+++ b/gcc/fortran/parse.cc
@@ -3974,21 +3974,30 @@ match_deferred_characteristics (gfc_typespec * ts)
For return types specified in a FUNCTION prefix, the IMPLICIT rules of the
scope are not yet parsed so this has to be delayed up to parse_spec. */
-static void
+static bool
check_function_result_typed (void)
{
gfc_typespec ts;
gcc_assert (gfc_current_state () == COMP_FUNCTION);
- if (!gfc_current_ns->proc_name->result) return;
+ if (!gfc_current_ns->proc_name->result)
+ return true;
ts = gfc_current_ns->proc_name->result->ts;
/* Check type-parameters, at the moment only CHARACTER lengths possible. */
/* TODO: Extend when KIND type parameters are implemented. */
if (ts.type == BT_CHARACTER && ts.u.cl && ts.u.cl->length)
- gfc_expr_check_typed (ts.u.cl->length, gfc_current_ns, true);
+ {
+ /* Reject invalid type of specification expression for length. */
+ if (ts.u.cl->length->ts.type != BT_INTEGER)
+ return false;
+
+ gfc_expr_check_typed (ts.u.cl->length, gfc_current_ns, true);
+ }
+
+ return true;
}
@@ -4096,10 +4105,7 @@ loop:
}
if (verify_now)
- {
- check_function_result_typed ();
- function_result_typed = true;
- }
+ function_result_typed = check_function_result_typed ();
}
switch (st)
@@ -4110,10 +4116,7 @@ loop:
case ST_IMPLICIT_NONE:
case ST_IMPLICIT:
if (!function_result_typed)
- {
- check_function_result_typed ();
- function_result_typed = true;
- }
+ function_result_typed = check_function_result_typed ();
goto declSt;
case ST_FORMAT:
diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index fb07459..427f901 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -17419,7 +17419,9 @@ resolve_fntype (gfc_namespace *ns)
}
}
- if (sym->ts.type == BT_CHARACTER)
+ if (sym->ts.type == BT_CHARACTER
+ && sym->ts.u.cl->length
+ && sym->ts.u.cl->length->ts.type == BT_INTEGER)
gfc_traverse_expr (sym->ts.u.cl->length, sym, flag_fn_result_spec, 0);
}
diff --git a/gcc/rust/ChangeLog b/gcc/rust/ChangeLog
index 0f4aad5..214daee 100644
--- a/gcc/rust/ChangeLog
+++ b/gcc/rust/ChangeLog
@@ -1,3 +1,842 @@
+2023-02-21 Raiki Tamura <tamaron1203@gmail.com>
+
+ * backend/rust-builtins.cc (BuiltinsContext::setup_math_fns): New functions.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * backend/rust-constexpr.cc (get_nth_callarg): Remove function.
+ (rs_bind_parameters_in_call): Use CALL_EXPR_ARG instead.
+ (potential_constant_expression_1): Likewise.
+
+2023-02-21 Thomas Schwinge <thomas@codesourcery.com>
+
+ * lang.opt: Fix ordering of file.
+
+2023-02-21 Philip Herron <herron.philip@googlemail.com>
+
+ * backend/rust-compile-type.cc (TyTyResolveCompile::visit): Remove unused parameters.
+ * backend/rust-constexpr.cc (constant_value_1): Likewise.
+ (fold_non_dependent_init): Likewise.
+ * backend/rust-tree.cc (publicly_uniquely_derived_p): Likewise.
+ (instantiation_dependent_expression_p): Likewise.
+ (type_has_nontrivial_copy_init): Likewise.
+ (is_normal_capture_proxy): Likewise.
+ (resolve_nondeduced_context): Likewise.
+ (undeduced_auto_decl): Likewise.
+ (require_deduced_type): Likewise.
+ * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise.
+ * checks/errors/privacy/rust-reachability.cc (ReachabilityVisitor::visit): Likewise.
+ * checks/errors/privacy/rust-visibility-resolver.cc (VisibilityResolver::visit): Likewise.
+ * checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise.
+ * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise.
+ * checks/lints/rust-lint-marklive.cc (MarkLive::go): Likewise.
+ * checks/lints/rust-lint-unused-var.cc (unused_var_walk_fn): Likewise.
+ * expand/rust-macro-builtins.cc (try_expand_single_string_literal): Likewise.
+ (try_expand_many_expr): Likewise.
+ (parse_single_string_literal): Likewise.
+ (MacroBuiltin::assert_handler): Likewise.
+ (MacroBuiltin::file_handler): Likewise.
+ (MacroBuiltin::column_handler): Likewise.
+ (MacroBuiltin::concat_handler): Likewise.
+ (MacroBuiltin::env_handler): Likewise.
+ (MacroBuiltin::line_handler): Likewise.
+ * hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise.
+ (ASTLoweringBase::handle_doc_item_attribute): Likewise.
+ * hir/rust-hir-dump.cc (Dump::visit): Likewise.
+ * hir/tree/rust-hir-full-test.cc (ConstGenericParam::accept_vis): Likewise.
+ * lex/rust-lex.cc (Lexer::parse_utf8_escape): Likewise.
+ (Lexer::parse_string): Likewise.
+ (Lexer::parse_char_or_lifetime): Likewise.
+ * lex/rust-lex.h: Likewise.
+ * metadata/rust-export-metadata.cc: Likewise.
+ * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Likewise.
+ * resolve/rust-ast-resolve-type.cc (ResolveType::visit): Likewise.
+ (ResolveTypeToCanonicalPath::visit): Likewise.
+ * resolve/rust-ast-verify-assignee.h: Likewise.
+ * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise.
+ * typecheck/rust-hir-type-check-expr.h: Likewise.
+ * typecheck/rust-hir-type-check-item.h: Likewise.
+ * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Likewise.
+ * typecheck/rust-tyty-rules.h: Likewise.
+ * util/rust-attributes.cc (AttributeChecker::visit): Likewise.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * hir/tree/rust-hir-expr.h: Add const `get_method_name`.
+ * hir/tree/rust-hir-full-decls.h (struct GenericArgs): Move from `struct`...
+ (class GenericArgs): ...to `class`.
+ * hir/tree/rust-hir-path.h (struct GenericArgs): Likewise.
+ (class GenericArgs): Clear `type_args` in copy constructor.
+ * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Reorder
+ debug print.
+ * typecheck/rust-tyty.h: Add default constructors for `SubstitutionArgumentMappings`.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * backend/rust-compile-context.cc (Context::push_closure_context): New function.
+ (Context::pop_closure_context): Likewise.
+ (Context::insert_closure_binding): Likewise.
+ (Context::lookup_closure_binding): Likewise.
+ * backend/rust-compile-context.h: Declare new functions and closure mappings.
+ * backend/rust-compile-expr.cc (CompileExpr::visit): Visit captures properly.
+ (CompileExpr::generate_closure_function): Compile captures properly.
+ * backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve): Check for
+ closure bindings.
+ * backend/rust-compile-type.cc (TyTyResolveCompile::visit): Compile capture list's
+ types as well.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Pass captures
+ properly to `TyTy::ClosureType` constructor.
+ * typecheck/rust-tyty.cc (ClosureType::as_string): Fix string representation.
+ (ClosureType::clone): Pass `captures` argument.
+ * typecheck/rust-tyty.h: Add `captures` field.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Use proper closure
+ contexts.
+ * resolve/rust-name-resolver.cc (Scope::lookup_decl_type): New function.
+ (Scope::lookup_rib_for_decl): Likewise.
+ (Resolver::insert_resolved_name): Insert captured items.
+ (Resolver::push_closure_context): New function.
+ (Resolver::pop_closure_context): Likewise.
+ (Resolver::insert_captured_item): Likewise.
+ (Resolver::decl_needs_capture): Likewise.
+ (Resolver::get_captures): Likewise.
+ * resolve/rust-name-resolver.h: Declare new functions.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Add Rib argument.
+ (ResolveExpr::resolve_closure_param): Likewise.
+ * resolve/rust-ast-resolve-implitem.h: Likewise.
+ * resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit): Likewise.
+ (ResolveItem::visit): Likewise.
+ * resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::visit): Likewise.
+ * resolve/rust-ast-resolve-pattern.h: Likewise.
+ * resolve/rust-ast-resolve-stmt.h: Likewise.
+ * resolve/rust-ast-resolve-toplevel.h: Likewise.
+ * resolve/rust-ast-resolve-type.h: Likewise.
+ * resolve/rust-name-resolver.cc (Rib::lookup_decl_type): Likewise.
+ (Scope::insert): Likewise.
+ (Resolver::insert_builtin_types): Likewise.
+ * resolve/rust-name-resolver.h: Likewise.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * resolve/rust-name-resolver.cc (MKBUILTIN_TYPE): Remove macro.
+ (Rib::Rib): Remove `mappings` field.
+ (Resolver::generate_builtins): Use `setup_builtin` instead of macro.
+ (Resolver::setup_builtin): New function.
+ * resolve/rust-name-resolver.h: Declare `setup_builtin`, add FIXME
+ comment.
+
+2023-02-21 Raiki Tamura <tamaron1203@gmail.com>
+
+ * lex/rust-lex.cc (Lexer::Lexer): Add `dump_lex` boolean flag.
+ (Lexer::skip_token): Dump tokens if flag is enabled.
+ (Lexer::dump_and_skip): New function.
+ * lex/rust-lex.h: Include optional.h and declare functions.
+ * parse/rust-parse-impl.h (Parser::debug_dump_lex_output): Remove old
+ unused function.
+ * parse/rust-parse.h: Likewise.
+ * rust-session-manager.cc (Session::compile_crate): Pass lexer dump
+ option to lexer.
+ (Session::dump_lex): New function.
+ * util/rust-optional.h: Add missing constructor.
+
+2023-02-21 Dave <dme2223@gmail.com>
+
+ * ast/rust-item.h: Remoe default location for Visibility class.
+ * parse/rust-parse-impl.h (Parser::parse_visibility): Pass proper location
+ when instantiating visibilities.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Fix dumping of fn params.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Remove extraneous string when
+ dumping statements.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc: Remove unused include.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
+ * ast/rust-ast-dump.h: Likewise.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
+ * ast/rust-ast-dump.h: Add missing getter declaration.
+ * ast/rust-ast-full-test.cc (BareFunctionType::as_string): Fix bare function
+ string representation.
+ * ast/rust-type.h (class BareFunctionType): Declare said getter.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add missing tuple type visitor.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add missing never type visitor.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add missing RawPointer visitor.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add missing array visitor
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add missing slice visitor.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add missing visitors.
+ * ast/rust-ast-dump.h: Likewise.
+ * ast/rust-ast.h: Add `get_lifetime_bounds` method.
+ * ast/rust-item.h: Add missing getter for lifetimes.
+ * ast/rust-type.h: Likewise.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add new reference visitor wrapper.
+ * ast/rust-ast-dump.h: Declare it.
+ * ast/rust-item.h: Add mutable visibility getters.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Fix extra call
+ to `delete`.
+
+2023-02-21 Dave <dme2223@gmail.com>
+
+ * ast/rust-item.h: Add location member.
+ * hir/rust-ast-lower.cc (translate_visibility): Pass location argument.
+ * hir/tree/rust-hir-item.h: Fix constructor to accept Location argument.
+
+2023-02-21 Raiki Tamura <tamaron1203@gmail.com>
+
+ * util/rust-lang-item.h: Add handling for `phantom_data` lang item.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add handling for unit structures.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.h: Fix documentation.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::go): Use new API.
+ (Dump::format_function_param): Refactor.
+ (Dump::visit_items_joined_by_separator): New function.
+ (Dump::emit_attrib): Refactor.
+ (Dump::visit_as_line): New function.
+ (Dump::visit_items_as_lines): Likewise.
+ (Dump::visit_items_as_block): Likewise.
+ (Dump::visit): Use new API.
+ (Dump::emit_visibility): Likewise.
+ (Dump::emit_indented_string): Likewise.
+ (Dump::emit_generic_params): Likewise.
+ (Dump::format_tuple_field): Likewise.
+ (Dump::format_struct_field): Likewise.
+ (Dump::format_function_common): Likewise.
+ (Dump::visit_function_common): Likewise.
+ * ast/rust-ast-dump.h: Declare new functions and add documentation.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add new visit function for overloading.
+ * ast/rust-ast-dump.h: Add documentation for layer.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * backend/rust-builtins.cc (BuiltinsContext::setup_atomic_fns): Declare atomic
+ load intrinsics.
+ * backend/rust-compile-intrinsic.cc (atomic_load_handler_inner): New handler.
+ (atomic_load_handler): Likewise.
+ (unchecked_op_handler): Remove `static` function qualifier.
+ (build_atomic_builtin_name): Handle load intrinsics.
+ (atomic_store_handler_inner): New handler.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * backend/rust-compile-intrinsic.cc (check_for_basic_integer_type): New function.
+ (build_atomic_builtin_name): Use HIR Type instead of `tree`.
+ (atomic_store_handler_inner): Cleanup error handling.
+ (unchecked_op_inner): Likewise.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * backend/rust-compile-intrinsic.cc (wrapping_op_handler): Refactor to return
+ an `std::function`.
+ (wrapping_op_handler_inner): Rename.
+ (wrapping_add_handler): Remove function.
+ (wrapping_sub_handler): Likewise.
+ (wrapping_mul_handler): Likewise.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * backend/rust-compile-intrinsic.cc (is_basic_integer_type): New function.
+ (unchecked_op_inner): New handler.
+ (unchecked_op_handler): New handler.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * backend/rust-builtins.cc (BuiltinsContext::setup_atomic_fns): New function.
+ (BuiltinsContext::setup): Call `setup_atomic_fns`.
+ * backend/rust-builtins.h: Declare `setup_atomic_fns`.
+ * backend/rust-compile-intrinsic.cc (atomic_store_handler_inner): New function.
+ (atomic_store_handler): New handler.
+ (make_unsigned_long_tree): Add helper around making unsigned long trees.
+ (prefetch_data_handler): Use `make_unsigned_long_tree`.
+ (build_atomic_builtin_name): New function.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * backend/rust-constexpr.cc (build_anon_member_initialization): Workaround uninitialized
+ values.
+ (build_data_member_initialization): Likewise.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * backend/rust-compile-intrinsic.cc (sorry_handler): New intrinsic handler.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * expand/rust-macro-builtins.cc (MacroBuiltin::assert): Rename to...
+ (MacroBuiltin::assert_handler): ..this.
+ (MacroBuiltin::file): Rename to...
+ (MacroBuiltin::file_handler): ..this.
+ (MacroBuiltin::column): Rename to...
+ (MacroBuiltin::column_handler): ..this.
+ (MacroBuiltin::include_bytes): Rename to...
+ (MacroBuiltin::include_bytes_handler): ..this.
+ (MacroBuiltin::include_str): Rename to...
+ (MacroBuiltin::include_str_handler): ..this.
+ (MacroBuiltin::compile_error): Rename to...
+ (MacroBuiltin::compile_error_handler): ..this.
+ (MacroBuiltin::concat): Rename to...
+ (MacroBuiltin::concat_handler): ..this.
+ (MacroBuiltin::env): Rename to...
+ (MacroBuiltin::env_handler): ..this.
+ (MacroBuiltin::cfg): Rename to...
+ (MacroBuiltin::cfg_handler): ..this.
+ (MacroBuiltin::include): Rename to...
+ (MacroBuiltin::include_handler): ..this.
+ (MacroBuiltin::line): Rename to...
+ (MacroBuiltin::line_handler): ..this.
+ * expand/rust-macro-builtins.h: Rename all handlers.
+ * util/rust-hir-map.cc (Mappings::insert_macro_def): Use new handler
+ names.
+
+2023-02-21 Simon Cook <simon.cook@embecosm.com>
+
+ * util/rust-inline-visitor.h: Remove some offending system includes.
+
+2023-02-21 YizhePKU <yizhe@pku.edu.cn>
+
+ * util/rust-inline-visitor.h: New file.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * backend/rust-compile-expr.cc (CompileExpr::visit): Refactor checking of closures.
+ (CompileExpr::generate_possible_fn_trait_call): New function.
+ * backend/rust-compile-expr.h: Declare `generate_possible_fn_trait_call`.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * typecheck/rust-tyty-bounds.cc (TypeCheckBase::get_predicate_from_bound): Add missing
+ implementation.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * Make-lang.in: Compile rust-ast-lower-type.cc.
+ * ast/rust-path.h: Add `get_locus` method to `TypePathFunction`.
+ * hir/rust-ast-lower-base.cc (ASTLowerTypePath::visit): Move implementation to
+ rust-ast-lower-type.cc.
+ (ASTLowerQualifiedPathInType::visit): Likewise.
+ (ASTLoweringType::visit): Likewise.
+ * hir/rust-ast-lower-type.h: Move implementations to source file.
+ * hir/tree/rust-hir-path.h: Likewise.
+ * hir/rust-ast-lower-type.cc: New file.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): Add missing handling of
+ function case.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * backend/rust-compile-context.h: Add new functions: `insert_closure_decl` and
+ `lookup_closure_decl`.
+ * backend/rust-compile-expr.cc (CompileExpr::visit): Start compiling Closures properly.
+ (CompileExpr::generate_closure_function): New function.
+ (CompileExpr::generate_closure_fntype): Likewise.
+ * backend/rust-compile-expr.h: Declare `generate_closure_function` and
+ `generate_closure_fntype`.
+ * backend/rust-compile-type.cc (TyTyResolveCompile::visit): Visit closure types properly.
+ * backend/rust-mangle.cc (legacy_mangle_name): Add support for closures.
+ * backend/rust-tree.h (RS_CLOSURE_FLAG): Add new tree macro.
+ (RS_CLOSURE_TYPE_P): And checking for it on tree nodes.
+ * typecheck/rust-tyty.cc (ClosureType::is_equal): Add implementation.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * hir/tree/rust-hir-expr.h: Add `get_params` method.
+ * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Typecheck closure nodes.
+ (TypeCheckExpr::resolve_fn_trait_call): New function.
+ * typecheck/rust-hir-type-check-expr.h: Declare `resolve_fn_trait_call` and
+ `resolve_possible_fn_trait_call_method_name`.
+ * typecheck/rust-hir-type-check.h: Declare `get_context_type`.
+ * typecheck/rust-tyctx.cc (TypeCheckContextItem::get_context_type): New function.
+ * typecheck/rust-tyty-cmp.h: Visit closures properly.
+ * typecheck/rust-tyty-rules.h: Likewise.
+ * typecheck/rust-tyty.cc (BaseType::bounds_compatible): Add commented out assertin.
+ (ClosureType::as_string): Implement it.
+ (ClosureType::clone): Fix closure cloning.
+ (ClosureType::setup_fn_once_output): New function.
+ * typecheck/rust-tyty.h: Improve `ClosureType` class and declare `setup_fn_once_output`.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * checks/errors/rust-const-checker.cc (ConstChecker::visit): Visit closures properly.
+ * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise.
+ * checks/lints/rust-lint-marklive.h: Likewise.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Simplify method
+ call type checking by removing visitor and instead using one static cast. Use the
+ new interface.
+ * typecheck/rust-tyty-call.cc (TypeCheckMethodCallExpr::visit): Likewise.
+ (TypeCheckMethodCallExpr::go): Likewise.
+ (TypeCheckMethodCallExpr::check): Likewise.
+ * typecheck/rust-tyty-call.h (class TypeCheckMethodCallExpr): Likewise.
+ (class Argument): Likewise.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Visit closure properly when
+ name resolving.
+ (ResolveExpr::resolve_closure_param): Implement closure name resolving.
+ * resolve/rust-ast-resolve-expr.h: Declare visitors for closure types.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::ASTLoweringPattern):
+ Improve formatting.
+ (ASTLoweringPattern::translate): Likewise.
+ * hir/rust-ast-lower-pattern.h: Likewise.
+ * resolve/rust-ast-resolve-expr.h: Likewise.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * Make-lang.in: Add new object file for expression lowering.
+ * ast/rust-expr.h: Move implementation of expr lowering to source file.
+ * backend/rust-compile-block.h: Likewise.
+ * backend/rust-compile-expr.cc (CompileExpr::visit): Likewise.
+ * backend/rust-compile-expr.h: Likewise.
+ * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise.
+ * checks/errors/privacy/rust-privacy-reporter.h: Likewise.
+ * checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise.
+ * checks/errors/rust-const-checker.h: Likewise.
+ * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise.
+ * checks/errors/rust-unsafe-checker.h: Likewise.
+ * hir/rust-ast-lower-base.h: Likewise.
+ * hir/rust-ast-lower-expr.h (RUST_AST_LOWER_EXPR): Likewise.
+ * hir/rust-ast-lower.cc (ASTLoweringBase::lower_closure_param): Likewise.
+ * hir/rust-hir-dump.cc (Dump::visit): Likewise.
+ * hir/rust-hir-dump.h: Likewise.
+ * hir/tree/rust-hir-expr.h (class ClosureExpr): Likewise.
+ (class ClosureExprInner): Likewise.
+ (class ClosureExprInnerTyped): Likewise.
+ * hir/tree/rust-hir-full-decls.h (class ClosureExprInner): Likewise.
+ (class ClosureExprInnerTyped): Likewise.
+ * hir/tree/rust-hir-full-test.cc (ClosureExprInnerTyped::as_string): Likewise.
+ (ClosureExprInner::as_string): Likewise.
+ (ClosureExprInner::accept_vis): Likewise.
+ (ClosureExpr::accept_vis): Likewise.
+ (ClosureExprInnerTyped::accept_vis): Likewise.
+ * hir/tree/rust-hir-visitor.h: Likewise.
+ * hir/tree/rust-hir.h (class Expr): Likewise.
+ * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise.
+ * typecheck/rust-hir-type-check-expr.h: Likewise.
+ * hir/rust-ast-lower-expr.cc: New file.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * util/rust-lang-item.h: Add handling for `fn_once_output`.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * ast/rust-ast-fragment.cc (Fragment::Fragment): Add better APIs.
+ (Fragment::complete): New function.
+ (Fragment::unexpanded): New function.
+ * ast/rust-ast-fragment.h: Declare new APIs and add documentation.
+ * expand/rust-attribute-visitor.h: Use new Fragment API.
+ * expand/rust-macro-builtins.cc (MacroBuiltin::file): Likewise.
+ (MacroBuiltin::column): Likewise.
+ (MacroBuiltin::include_bytes): Likewise.
+ (MacroBuiltin::include_str): Likewise.
+ (MacroBuiltin::concat): Likewise.
+ (MacroBuiltin::env): Likewise.
+ (MacroBuiltin::cfg): Likewise.
+ (MacroBuiltin::include): Likewise.
+ (MacroBuiltin::line): Likewise.
+ * expand/rust-macro-expand.cc (parse_many): Likewise.
+ (transcribe_expression): Likewise.
+ (transcribe_type): Likewise.
+ * expand/rust-macro-expand.h (struct MacroExpander): Likewise.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * ast/rust-ast.h (class ASTFragment): Remove old ASTFragment class.
+ * ast/rust-macro.h (class MacroRulesDefinition): Use new Fragment API.
+ * expand/rust-attribute-visitor.h: Likewise.
+ * expand/rust-macro-builtins.cc (macro_end_token): Likewise.
+ (MacroBuiltin::assert): Likewise.
+ (MacroBuiltin::file): Likewise.
+ (MacroBuiltin::column): Likewise.
+ (MacroBuiltin::include_bytes): Likewise.
+ (MacroBuiltin::include_str): Likewise.
+ (MacroBuiltin::compile_error): Likewise.
+ (MacroBuiltin::concat): Likewise.
+ (MacroBuiltin::env): Likewise.
+ (MacroBuiltin::cfg): Likewise.
+ (MacroBuiltin::include): Likewise.
+ (MacroBuiltin::line): Likewise.
+ * expand/rust-macro-builtins.h: Likewise.
+ * expand/rust-macro-expand.cc (MacroExpander::expand_decl_macro): Likewise.
+ (MacroExpander::expand_invoc): Likewise.
+ (MacroExpander::match_repetition): Likewise.
+ (parse_many): Likewise.
+ (transcribe_many_items): Likewise.
+ (transcribe_many_ext): Likewise.
+ (transcribe_many_trait_items): Likewise.
+ (transcribe_many_impl_items): Likewise.
+ (transcribe_many_trait_impl_items): Likewise.
+ (transcribe_expression): Likewise.
+ (transcribe_type): Likewise.
+ (transcribe_on_delimiter): Likewise.
+ (tokens_to_str): Likewise.
+ * expand/rust-macro-expand.h (struct MacroExpander): Likewise.
+ * util/rust-hir-map.cc (Mappings::insert_macro_def): Likewise.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * Make-lang.in: Add `rust-ast-fragment.o` object file.
+ * ast/rust-ast-fragment.cc: New file.
+ * ast/rust-ast-fragment.h: New file.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_trait): Check if a
+ trait query is currently in progress.
+ * typecheck/rust-hir-type-check.h (class TraitQueryGuard): Add helpers around
+ checking for trait queries and inserting them.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add missing visitors for macro definition dumping.
+ (get_delimiters): New function.
+ * ast/rust-ast-dump.h: Declare `get_delimiters` and add documentation.
+ * ast/rust-macro.h: Add `get_token_tree` method.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Properly handle unloaded modules.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Fix formatting when dumping modules.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Dump items in modules properly.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * ast/rust-ast-dump.cc: Emit visibility when dumping items.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * hir/rust-ast-lower-base.h (class ItemWrapper): New class.
+ * hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_outer_attributes): Use
+ `ItemWrapper` class.
+ (ASTLoweringBase::handle_doc_item_attribute): Likewise.
+ (ASTLoweringBase::handle_lang_item_attribute): Likewise.
+ * hir/rust-ast-lower-implitem.h: Check outer attributes on items.
+ * hir/tree/rust-hir-item.h: Add `get_trait_locus` methods.
+ * hir/tree/rust-hir.h: Likewise.
+ * util/rust-hir-map.h: Add defId mappings and associated functions.
+ * util/rust-hir-map.cc (Mappings::insert_defid_mapping): Implement insertion to said
+ mappings.
+ (Mappings::lookup_trait_item_defid): And looking up said mappings.
+
+2023-02-21 Jakub Dupak <dev@jakubdupak.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add code for dumping type aliases.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * typecheck/rust-hir-trait-resolve.cc (TraitResolver::TraitResolver): Do not nullptr init
+ `resolved_trait_reference` anymore.
+ (TraitResolver::resolve_path): Simplify function and rename to...
+ (TraitResolver::resolve_path_to_trait): ...this.
+ (TraitResolver::lookup_path): Use new interface.
+ * typecheck/rust-hir-trait-resolve.h (class TraitResolver): Do not inherit `HIRFullVisitor`
+ class anymore.
+
+2023-02-21 David Faust <david.faust@oracle.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add dump for RangeExprs.
+
+2023-02-21 David Faust <david.faust@oracle.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add dump for, BorrowExpr, DereferenceExpr,
+ ErrorPropagationExpr, NegationExpr, TypeCastExpr and GroupedExpr.
+
+2023-02-21 David Faust <david.faust@oracle.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add dump code for ArrayExpr.
+
+2023-02-21 David Faust <david.faust@oracle.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Add dumps for ComparisonExpr and
+ LazyBooleanExpr.
+
+2023-02-21 David Faust <david.faust@oracle.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Fix IfExpr formatting.
+
+2023-02-21 David Faust <david.faust@oracle.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Fix block formatting.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * typecheck/rust-autoderef.cc: Add support for multiple resolution candidates.
+ * typecheck/rust-hir-dot-operator.cc (MethodResolver::MethodResolver): Edit
+ `try_result` field and change constructor.
+ (MethodResolver::Probe): Return set of candidates instead of singular candidate.
+ (MethodResolver::select): Add better implementation to account for multiple
+ candidates.
+ * typecheck/rust-hir-dot-operator.h (struct MethodCandidate): Overload comparison
+ operator in order to store them in `std::set`.
+ * typecheck/rust-hir-inherent-impl-overlap.h: Do not fail assertion on missing type.
+ * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Adapt code to use
+ multiple candidates.
+ * typecheck/rust-tyty.cc (set_cmp_autoderef_mode): Add code to handle automatic
+ derefs properly.
+ (reset_cmp_autoderef_mode): Add helper function to reset said mode.
+ * typecheck/rust-tyty.h (set_cmp_autoderef_mode): Declare function.
+ (reset_cmp_autoderef_mode): Likewise.
+ * typecheck/rust-tyty-cmp.h: Add handling of `autoderef_cmp_flag`
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * util/rust-abi.cc (get_abi_from_string): Add missing "rust-call"
+ possibility for ABI variant.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * util/rust-lang-item.h: Add `fn_once` lang item.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * backend/rust-compile.cc: Add note about missing support for super
+ traits.
+ * typecheck/rust-tyty.cc (BaseType::satisfies_bound): New function.
+ (BaseType::bounds_compatible): New function.
+ (DynamicObjectType::get_object_items): New function.
+ * typecheck/rust-hir-trait-ref.h: Use new API to perform type resolution
+ on dyn objects.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * Make-lang.in: Compile early name resolver.
+ * expand/rust-attribute-visitor.cc (AttrVisitor::visit): Move macro
+ name resolution.
+ * expand/rust-macro-builtins.cc (try_expand_macro_expression): Run ENR
+ when recursively expanding macros.
+ * expand/rust-macro-expand.cc (MacroExpander::expand_invoc): No longer
+ perform name resolution in `expand_invoc`.
+ * expand/rust-macro-expand.h (struct MacroExpander): Keep ENR within
+ MacroExpander.
+ * rust-session-manager.cc (Session::expansion): Run ENR.
+ * resolve/rust-early-name-resolver.cc: New file.
+ * resolve/rust-early-name-resolver.h: New file.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * ast/rust-path.h: Add `accept_vis` method to `GenericArg` class.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Add note for
+ glob import resolving.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * util/rust-hir-map.h: Add new mappings.
+ * util/rust-hir-map.cc (Mappings::insert_macro_invocation): Add insertion
+ function into mappings.
+ (Mappings::lookup_macro_invocation): Add lookup function for mappings.
+
+2023-02-21 Marc Poulhiès <dkm@kataplop.net>
+
+ * parse/rust-parse-impl.h (Parser::parse_stmt_or_expr_without_block):
+ Check if `expr` is valid after parsing it.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * backend/rust-builtins.cc (BuiltinsContext::setup): Declare prefetch
+ intrinsics.
+ * backend/rust-compile-intrinsic.cc (enum class Prefetch): Add kinds of
+ prefetch intrinsics.
+ (prefetch_data_handler): New function.
+ (prefetch_read_data): Likewise.
+ (prefetch_write_data): Likewise.
+
+2023-02-21 David Faust <david.faust@oracle.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Fill empty functions for
+ structs, enums and unions.
+
+2023-02-21 David Faust <david.faust@oracle.com>
+
+ * ast/rust-ast-dump.cc (Dump::format_tuple_field): New.
+ (Dump::format_struct_field): New.
+ * ast/rust-ast-dump.h (format_tuple_field): New.
+ (format_struct_field): New.
+
+2023-02-21 David Faust <david.faust@oracle.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): move generic params dump ...
+ (Dump::emit_generic_params): ... here.
+ * ast/rust-ast-dump.h (emit_generic_params): New.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * typecheck/rust-hir-trait-ref.h (lookup_trait_item): Add lookup
+ in super_trait.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * backend/rust-compile-expr.cc
+ (CompileExpr::resolve_method_address): Use auto and minor change
+ in candidate init.
+ * typecheck/rust-hir-type-check-path.cc
+ (TypeCheckExpr::resolve_segments): Likewise.
+ * typecheck/rust-hir-type-check-type.cc: Likewise.
+ * backend/rust-compile-resolve-path.cc
+ (HIRCompileBase::query_compile): Likewise. Removecall to
+ set_ty_ref.
+ * typecheck/rust-hir-path-probe.h (struct PathProbeCandidate): Add
+ locus initializer in ctor, implement get_defid.
+ (class PathProbeType::Probe): return a set instead of vector.
+ Adjust class impl.
+ (class ReportMultipleCandidateError): Do not inherit from
+ HIRImplVisitor anymore and remove corresponding impl. Adjust for
+ change in Probe. Simplify Report handling.
+ (class PathProbeImplTrait::Probe): Adjust return type.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * typecheck/rust-hir-type-check-enumitem.cc
+ (TypeCheckEnumItem::visit): Adjust VariantDef ctor calls with
+ DefID.
+ * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit):
+ Likewise.
+ * typecheck/rust-tyty.h (VariantDef): Add defid parameter to ctor.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * Make-lang.in: Add `rust-builtins.o` as target
+ * backend/rust-builtins.h: Refactor to new file.
+ * backend/rust-builtins.cc: New file.
+
+2023-02-21 David Faust <david.faust@oracle.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Implement visitor for If
+ expressions.
+
+2023-02-21 David Faust <david.faust@oracle.com>
+
+ * ast/rust-ast-dump.cc (Dump::visit): Dump assignment and compound
+ assignment expressions.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::query_type):
+ Check for recursive queries.
+ * typecheck/rust-hir-type-check.h: New functions: `query_completed`,
+ `query_in_progress`, `insert_query`.
+ * typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::scan): Use `query_type` API.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * ast/rust-ast-dump.cc (Dump::emit_visibility): New function.
+ (Dump::visit): Call into `emit_visibility`.
+ (Dump::format_function_common): Likewise.
+ * ast/rust-ast-dump.h: Declare `emit_visibility`.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * ast/rust-item.h: Rename get_public_vis_type.
+ * hir/rust-ast-lower.cc (translate_visibility): Use new name.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * resolve/rust-name-resolver.h: Add miscellenaous item mappings.
+ * resolve/rust-name-resolver.cc (Resolver::insert_resolved_misc): Use
+ new mappings.
+ (Resolver::lookup_resolved_misc): Likewise.
+ * typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_segments):
+ Adapt function to insert into miscelleanous mappings.
+ * checks/lints/rust-lint-marklive.cc (MarkLive::find_ref_node_id):
+ Allow lookup in miscelleanous mappings in mark-live phase.
+
2023-02-20 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* backend/rust-tree.cc: Include memmodel.h.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f4f7ec2..31bd634 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,171 @@
+2023-02-21 David Malcolm <dmalcolm@redhat.com>
+
+ PR analyzer/108830
+ * gcc.dg/analyzer/attribute-nonnull.c: Update for
+ -Wanalyzer-use-of-uninitialized-value terminating analysis along
+ a path.
+ * gcc.dg/analyzer/call-summaries-2.c: Likewise.
+ * gcc.dg/analyzer/data-model-1.c: Likewise.
+ * gcc.dg/analyzer/data-model-5.c: Likewise.
+ * gcc.dg/analyzer/doom-s_sound-pr108867.c: New test.
+ * gcc.dg/analyzer/memset-CVE-2017-18549-1.c: Add
+ -fno-analyzer-suppress-followups.
+ * gcc.dg/analyzer/null-deref-pr108830.c: New test.
+ * gcc.dg/analyzer/pipe-1.c: Add -fno-analyzer-suppress-followups.
+ * gcc.dg/analyzer/pipe-void-return.c: Likewise.
+ * gcc.dg/analyzer/pipe2-1.c: Likewise.
+ * gcc.dg/analyzer/pr101547.c: Update for
+ -Wanalyzer-use-of-uninitialized-value terminating analysis along
+ a path.
+ * gcc.dg/analyzer/pr101875.c: Likewise.
+ * gcc.dg/analyzer/pr104224-split.c: New test, based on...
+ * gcc.dg/analyzer/pr104224.c: Add
+ -fno-analyzer-suppress-followups.
+ * gcc.dg/analyzer/realloc-2.c: Add
+ -fno-analyzer-suppress-followups.
+ * gcc.dg/analyzer/realloc-3.c: Likewise.
+ * gcc.dg/analyzer/realloc-5.c: Likewise.
+ * gcc.dg/analyzer/stdarg-1-ms_abi.c: Likewise.
+ * gcc.dg/analyzer/stdarg-1-sysv_abi.c: Likewise.
+ * gcc.dg/analyzer/stdarg-1.c: Likewise.
+ * gcc.dg/analyzer/symbolic-1.c: Likewise.
+ * gcc.dg/analyzer/symbolic-7.c: Update for
+ -Wanalyzer-use-of-uninitialized-value terminating analysis along a
+ path.
+ * gcc.dg/analyzer/uninit-4.c: Likewise.
+ * gcc.dg/analyzer/uninit-8.c: New test.
+ * gcc.dg/analyzer/uninit-pr94713.c: Update for
+ -Wanalyzer-use-of-uninitialized-value terminating analysis along a
+ path.
+ * gcc.dg/analyzer/zlib-6a.c: Add -fno-analyzer-suppress-followups.
+
+2023-02-21 Harald Anlauf <anlauf@gmx.de>
+
+ PR fortran/96025
+ * gfortran.dg/pr96025.f90: New test.
+
+2023-02-21 Iain Buclaw <ibuclaw@gdcproject.org>
+
+ * gdc.dg/simd2a.d: Update.
+ * gdc.dg/simd2b.d: Update.
+ * gdc.dg/simd2c.d: Update.
+ * gdc.dg/simd2d.d: Update.
+ * gdc.dg/simd2e.d: Update.
+ * gdc.dg/simd2f.d: Update.
+ * gdc.dg/simd2g.d: Update.
+ * gdc.dg/simd2h.d: Update.
+ * gdc.dg/simd2i.d: Update.
+ * gdc.dg/simd2j.d: Update.
+
+2023-02-21 Iain Buclaw <ibuclaw@gdcproject.org>
+
+ * gdc.dg/ctfeintrinsics.d: New test.
+
+2023-02-21 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/108691
+ * gcc.dg/pr108691.c: New testcase.
+
+2023-02-21 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/108793
+ * gcc.dg/torture/pr108793.c: New testcase.
+
+2023-02-21 Raiki Tamura <tamaron1203@gmail.com>
+
+ * rust/compile/torture/intrinsics-math.rs: New test.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * rust/debug/chartype.rs: Skip testcases on Darwin architectures.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * rust/execute/torture/closure3.rs: New test.
+
+2023-02-21 Raiki Tamura <tamaron1203@gmail.com>
+
+ * rust/compile/torture/phantom_data.rs: New test.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * rust/compile/torture/intrinsics-3.rs:
+ * rust/execute/torture/atomic_load.rs: New test.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * rust/compile/torture/intrinsics-5.rs: Fix error message.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * rust/compile/torture/intrinsics-6.rs: New test.
+ * rust/compile/torture/intrinsics-7.rs: New test.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * rust/compile/torture/intrinsics-4.rs: New test.
+ * rust/compile/torture/intrinsics-5.rs: New test.
+ * rust/execute/torture/atomic_store.rs: New test.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * rust/compile/torture/intrinsics-3.rs: New test.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * rust/execute/torture/closure2.rs: New test.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * rust/execute/torture/closure1.rs: New test.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * rust/compile/issue-1589.rs: New test.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * rust/compile/generics7.rs: Fix test with missing assertion.
+ * rust/execute/torture/operator_overload_9.rs: Fix test assertion.
+
+2023-02-21 Marc Poulhiès <dkm@kataplop.net>
+
+ * rust/compile/missing_closing_paren.rs: New test.
+
+2023-02-21 Arthur Cohen <arthur.cohen@embecosm.com>
+
+ * rust/execute/torture/prefetch_data.rs: New test.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * rust/compile/torture/issue-1555.rs: New test.
+
+2023-02-21 Faisal Abbas <faisal.abbas@elastica.co>
+
+ * rust/compile/const9.rs: New test.
+
+2023-02-21 Philip Herron <philip.herron@embecosm.com>
+
+ * rust/compile/issue-1272.rs: New test.
+
+2023-02-21 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/108868
+ * gcc.dg/pr108868.c: New testcase.
+
+2023-02-21 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/108855
+ * gcc.dg/pr108855.c: New testcase.
+
+2023-02-21 Richard Biener <rguenther@suse.de>
+
+ Revert:
+ 2023-02-21 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/108691
+ * gcc.dg/pr108691.c: New testcase.
+
2023-02-20 Jakub Jelinek <jakub2redhat.com>
PR target/108862
diff --git a/gcc/testsuite/gcc.dg/analyzer/attribute-nonnull.c b/gcc/testsuite/gcc.dg/analyzer/attribute-nonnull.c
index 7c71a71..5700256 100644
--- a/gcc/testsuite/gcc.dg/analyzer/attribute-nonnull.c
+++ b/gcc/testsuite/gcc.dg/analyzer/attribute-nonnull.c
@@ -16,8 +16,6 @@ void test_1 (void *p, void *q, void *r)
foo(p, q, r);
foo(NULL, q, r); /* { dg-warning "use of NULL where non-null expected" "warning" } */
/* { dg-message "argument 1 NULL where non-null expected" "note" { target *-*-* } .-1 } */
- foo(p, NULL, r);
- foo(p, q, NULL); /* { dg-warning "use of NULL where non-null expected" } */
}
void test_1a (void *q, void *r)
@@ -27,12 +25,29 @@ void test_1a (void *q, void *r)
/* { dg-message "argument 1 \\('p'\\) NULL where non-null expected" "note" { target *-*-* } .-1 } */
}
-void test_2 (void *p, void *q, void *r)
+void test_1b (void *p, void *r)
+{
+ foo(p, NULL, r);
+}
+
+void test_1c (void *p, void *q, void *r)
+{
+ foo(p, q, NULL); /* { dg-warning "use of NULL where non-null expected" } */
+}
+
+void test_2a (void *p, void *q, void *r)
{
bar(p, q, r);
- bar(NULL, q, r); /* { dg-warning "use of NULL where non-null expected" "warning" } */
+}
+
+void test_2b (void *p, void *q, void *r)
+{
bar(p, NULL, r); /* { dg-warning "use of NULL where non-null expected" "warning" } */
/* { dg-message "argument 2 NULL where non-null expected" "note" { target *-*-* } .-1 } */
+}
+
+void test_2c (void *p, void *q, void *r)
+{
bar(p, q, NULL); /* { dg-warning "use of NULL where non-null expected" "warning" } */
}
diff --git a/gcc/testsuite/gcc.dg/analyzer/call-summaries-2.c b/gcc/testsuite/gcc.dg/analyzer/call-summaries-2.c
index 2d82d02..1bac24f 100644
--- a/gcc/testsuite/gcc.dg/analyzer/call-summaries-2.c
+++ b/gcc/testsuite/gcc.dg/analyzer/call-summaries-2.c
@@ -607,17 +607,22 @@ void partially_inits (int *p, int v)
p[1] = v;
}
-void test_partially_inits (int x)
+void test_partially_inits_0 (int x)
{
int arr[2];
partially_inits (arr, x);
partially_inits (arr, x);
- __analyzer_eval (arr[0]); /* { dg-warning "UNKNOWN" "eval" } */
- /* { dg-warning "use of uninitialized value 'arr\\\[0\\\]'" "uninit" { target *-*-* } .-1 } */
+ __analyzer_eval (arr[0]); /* { dg-warning "use of uninitialized value 'arr\\\[0\\\]'" } */
+}
+
+void test_partially_inits_1 (int x)
+{
+ int arr[2];
+ partially_inits (arr, x);
+ partially_inits (arr, x);
- __analyzer_eval (arr[1] == x); /* { dg-warning "UNKNOWN" "eval" } */
- /* { dg-bogus "use of uninitialized value 'arr\\\[1\\\]'" "uninit" { xfail *-*-* } .-1 } */
+ __analyzer_eval (arr[1] == x); /* { dg-bogus "use of uninitialized value 'arr\\\[1\\\]'" "uninit" { xfail *-*-* } } */
// TODO(xfail), and eval should be "TRUE"
}
diff --git a/gcc/testsuite/gcc.dg/analyzer/data-model-1.c b/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
index d8930d1..86d1ccf 100644
--- a/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
@@ -351,9 +351,8 @@ void test_19 (void)
{
int i, j; /* { dg-message "region created on stack here" } */
/* Compare two uninitialized locals. */
- __analyzer_eval (i == j); /* { dg-warning "UNKNOWN" "unknown " } */
- /* { dg-warning "use of uninitialized value 'i'" "uninit i" { target *-*-* } .-1 } */
- /* { dg-warning "use of uninitialized value 'j'" "uninit j" { target *-*-* } .-2 } */
+ __analyzer_eval (i == j); /* { dg-warning "use of uninitialized value 'i'" "uninit i" } */
+ /* { dg-warning "use of uninitialized value 'j'" "uninit j" { target *-*-* } .-1 } */
}
void test_20 (int i, int j)
@@ -653,11 +652,6 @@ void test_29b (void)
__analyzer_eval (p[9].x == 109024); /* { dg-warning "TRUE" } */
__analyzer_eval (p[9].y == 109025); /* { dg-warning "TRUE" } */
- __analyzer_eval (p[10].x == 0); /* { dg-warning "UNKNOWN" "unknown" } */
- /* { dg-warning "use of uninitialized value 'p\\\[10\\\].x'" "uninit" { target *-*-* } .-1 } */
- __analyzer_eval (p[10].y == 0); /* { dg-warning "UNKNOWN" "unknown" } */
- /* { dg-warning "use of uninitialized value 'p\\\[10\\\].y'" "uninit" { target *-*-* } .-1 } */
-
q = &p[7];
__analyzer_eval (q->x == 107024); /* { dg-warning "TRUE" } */
@@ -679,6 +673,8 @@ void test_29b (void)
__analyzer_eval (q->x == 107024); /* { dg-warning "TRUE" } */
__analyzer_eval (q->y == 107025); /* { dg-warning "TRUE" } */
+
+ __analyzer_eval (p[10].x == 0); /* { dg-warning "use of uninitialized value 'p\\\[10\\\].x'" } */
}
void test_29c (int len)
@@ -704,11 +700,6 @@ void test_29c (int len)
__analyzer_eval (p[9].x == 109024); /* { dg-warning "TRUE" } */
__analyzer_eval (p[9].y == 109025); /* { dg-warning "TRUE" } */
- __analyzer_eval (p[10].x == 0); /* { dg-warning "UNKNOWN" "unknown" } */
- /* { dg-warning "use of uninitialized value '\\*p\\\[10\\\].x'" "uninit" { target *-*-* } .-1 } */
- __analyzer_eval (p[10].y == 0); /* { dg-warning "UNKNOWN" "unknown" } */
- /* { dg-warning "use of uninitialized value '\\*p\\\[10\\\].y'" "uninit" { target *-*-* } .-1 } */
-
q = &p[7];
__analyzer_eval (q->x == 107024); /* { dg-warning "TRUE" } */
@@ -730,6 +721,8 @@ void test_29c (int len)
__analyzer_eval (q->x == 107024); /* { dg-warning "TRUE" } */
__analyzer_eval (q->y == 107025); /* { dg-warning "TRUE" } */
+
+ __analyzer_eval (p[10].x == 0); /* { dg-warning "use of uninitialized value '\\*p\\\[10\\\].x'" } */
}
void test_30 (void *ptr)
diff --git a/gcc/testsuite/gcc.dg/analyzer/data-model-5.c b/gcc/testsuite/gcc.dg/analyzer/data-model-5.c
index 2135c70..b71bad7 100644
--- a/gcc/testsuite/gcc.dg/analyzer/data-model-5.c
+++ b/gcc/testsuite/gcc.dg/analyzer/data-model-5.c
@@ -90,10 +90,6 @@ void unref (base_obj *obj)
{
if (--obj->ob_refcnt == 0) /* { dg-bogus "dereference of uninitialized pointer 'obj'" } */
obj->ob_type->tp_dealloc (obj);
- /* { dg-warning "dereference of NULL 'obj'" "deref of NULL" { target *-*-* } .-2 } */
- /* FIXME: ideally we wouldn't issue this, as we've already issued a
- warning about str_obj which is now in the "stop" state; the cast
- confuses things. */
}
void test_1 (const char *str)
diff --git a/gcc/testsuite/gcc.dg/analyzer/doom-s_sound-pr108867.c b/gcc/testsuite/gcc.dg/analyzer/doom-s_sound-pr108867.c
new file mode 100644
index 0000000..ebbfed2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/doom-s_sound-pr108867.c
@@ -0,0 +1,653 @@
+/* Reduced from Doom's linuxdoom-1.10/s_sound.c, which is GPLv2 or later. */
+
+/* { dg-additional-options "-fno-analyzer-call-summaries -Wno-analyzer-too-complex" } */
+
+typedef struct _IO_FILE FILE;
+extern FILE* stderr;
+extern int
+fprintf(FILE* __restrict __stream, const char* __restrict __format, ...);
+extern int
+sprintf(char* __restrict __s, const char* __restrict __format, ...)
+ __attribute__((__nothrow__));
+extern int
+abs(int __x) __attribute__((__nothrow__, __leaf__)) __attribute__((__const__));
+
+typedef enum
+{
+ false,
+ true
+} boolean;
+
+typedef unsigned char byte;
+
+void
+I_Error(char* error, ...);
+
+typedef enum
+{
+ shareware,
+ registered,
+ commercial,
+ /* [...snip...] */
+} GameMode_t;
+
+typedef int fixed_t;
+
+fixed_t
+FixedMul(fixed_t a, fixed_t b);
+
+extern fixed_t finesine[5 * 8192 / 4];
+typedef unsigned angle_t;
+
+typedef struct mobj_s
+{
+ /* [...snip...] */
+ fixed_t x;
+ fixed_t y;
+ fixed_t z;
+ /* [...snip...] */
+ angle_t angle;
+ /* [...snip...] */
+} mobj_t;
+
+typedef struct player_s
+{
+ mobj_t* mo;
+ /* [...snip...] */
+} player_t;
+
+extern GameMode_t gamemode;
+extern int gameepisode;
+extern int gamemap;
+extern int consoleplayer;
+extern player_t players[4];
+
+typedef struct sfxinfo_struct sfxinfo_t;
+
+struct sfxinfo_struct
+{
+ /* [...snip...] */
+ int priority;
+ sfxinfo_t* link;
+ int pitch;
+ int volume;
+ void* data;
+ int usefulness;
+ int lumpnum;
+};
+
+typedef struct
+{
+ char* name;
+ int lumpnum;
+ void* data;
+ int handle;
+} musicinfo_t;
+
+extern sfxinfo_t S_sfx[];
+
+extern musicinfo_t S_music[];
+
+typedef enum
+{
+ mus_None,
+ mus_e1m1,
+ /* [...snip...] */
+ mus_e1m5,
+ /* [...snip...] */
+ mus_e1m9,
+ /* [...snip...] */
+ mus_e2m4,
+ mus_e2m5,
+ mus_e2m6,
+ mus_e2m7,
+ /* [...snip...] */
+ mus_e3m2,
+ mus_e3m3,
+ mus_e3m4,
+ /* [...snip...] */
+ mus_runnin,
+ /* [...snip...] */
+ NUMMUSIC
+} musicenum_t;
+
+typedef enum
+{
+ /* [...snip...] */
+ sfx_sawup,
+ /* [...snip...] */
+ sfx_sawhit,
+ /* [...snip...] */
+ sfx_itemup,
+ /* [...snip...] */
+ sfx_tink,
+ /* [...snip...] */
+ NUMSFX
+} sfxenum_t;
+
+
+void
+I_SetChannels();
+
+int
+I_GetSfxLumpNum(sfxinfo_t* sfxinfo);
+
+int
+I_StartSound(int id, int vol, int sep, int pitch, int priority);
+
+void
+I_StopSound(int handle);
+int
+I_SoundIsPlaying(int handle);
+void
+I_UpdateSoundParams(int handle, int vol, int sep, int pitch);
+
+void
+I_SetMusicVolume(int volume);
+
+void
+I_PauseSong(int handle);
+void
+I_ResumeSong(int handle);
+int
+I_RegisterSong(void* data);
+
+void
+I_PlaySong(int handle, int looping);
+
+void
+I_StopSong(int handle);
+
+void
+I_UnRegisterSong(int handle);
+void
+S_StopSound(void* origin);
+void
+S_ChangeMusic(int music_id, int looping);
+void
+S_StopMusic(void);
+
+void
+S_SetMusicVolume(int volume);
+void
+S_SetSfxVolume(int volume);
+
+void*
+Z_Malloc(int size, int tag, void* ptr);
+void
+Z_ChangeTag2(void* ptr, int tag);
+
+typedef struct memblock_s
+{
+ /* [...snip...] */
+ int id;
+ /* [...snip...] */
+} memblock_t;
+int
+M_Random(void);
+int
+W_GetNumForName(char* name);
+void*
+W_CacheLumpNum(int lump, int tag);
+angle_t
+R_PointToAngle2(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2);
+
+typedef struct
+{
+ sfxinfo_t* sfxinfo;
+ void* origin;
+ int handle;
+} channel_t;
+static channel_t* channels;
+
+int snd_SfxVolume = 15;
+int snd_MusicVolume = 15;
+static boolean mus_paused;
+static musicinfo_t* mus_playing = 0;
+int numChannels;
+static int nextcleanup;
+
+int
+S_getChannel(void* origin, sfxinfo_t* sfxinfo);
+
+int
+S_AdjustSoundParams(mobj_t* listener,
+ mobj_t* source,
+ int* vol,
+ int* sep,
+ int* pitch);
+void
+S_StopChannel(int cnum);
+
+void
+S_Init(int sfxVolume, int musicVolume)
+{
+ int i;
+
+ fprintf(stderr, "S_Init: default sfx volume %d\n", sfxVolume);
+
+ I_SetChannels();
+
+ S_SetSfxVolume(sfxVolume);
+
+ S_SetMusicVolume(musicVolume);
+
+ channels = (channel_t*)Z_Malloc(numChannels * sizeof(channel_t), 1, 0);
+
+ for (i = 0; i < numChannels; i++)
+ channels[i].sfxinfo = 0;
+
+ mus_paused = 0;
+
+ for (i = 1; i < NUMSFX; i++)
+ S_sfx[i].lumpnum = S_sfx[i].usefulness = -1;
+}
+void
+S_Start(void)
+{
+ int cnum;
+ int mnum;
+
+ for (cnum = 0; cnum < numChannels; cnum++)
+ if (channels[cnum].sfxinfo)
+ S_StopChannel(cnum);
+
+ mus_paused = 0;
+
+ if (gamemode == commercial)
+ mnum = mus_runnin + gamemap - 1;
+ else {
+ int spmus[] = {
+
+ mus_e3m4, mus_e3m2, mus_e3m3, mus_e1m5, mus_e2m7,
+ mus_e2m4, mus_e2m6, mus_e2m5, mus_e1m9
+ };
+
+ if (gameepisode < 4)
+ mnum = mus_e1m1 + (gameepisode - 1) * 9 + gamemap - 1;
+ else
+ mnum = spmus[gamemap - 1];
+ }
+
+ S_ChangeMusic(mnum, true);
+
+ nextcleanup = 15;
+}
+
+void
+S_StartSoundAtVolume(void* origin_p, int sfx_id, int volume)
+{
+
+ int rc;
+ int sep;
+ int pitch;
+ int priority;
+ sfxinfo_t* sfx;
+ int cnum;
+
+ mobj_t* origin = (mobj_t*)origin_p;
+ if (sfx_id < 1 || sfx_id > NUMSFX)
+ I_Error("Bad sfx #: %d", sfx_id);
+
+ sfx = &S_sfx[sfx_id];
+
+ if (sfx->link) {
+ pitch = sfx->pitch;
+ priority = sfx->priority;
+ volume += sfx->volume;
+
+ if (volume < 1)
+ return;
+
+ if (volume > snd_SfxVolume)
+ volume = snd_SfxVolume;
+ } else {
+ pitch = 128;
+ priority = 64;
+ }
+
+ if (origin && origin != players[consoleplayer].mo) {
+ rc = S_AdjustSoundParams(
+ players[consoleplayer].mo, origin, &volume, &sep, &pitch);
+
+ if (origin->x == players[consoleplayer].mo->x &&
+ origin->y == players[consoleplayer].mo->y) {
+ sep = 128;
+ }
+
+ if (!rc)
+ return;
+ } else {
+ sep = 128;
+ }
+
+ if (sfx_id >= sfx_sawup && sfx_id <= sfx_sawhit) {
+ pitch += 8 - (M_Random() & 15);
+
+ if (pitch < 0)
+ pitch = 0;
+ else if (pitch > 255)
+ pitch = 255;
+ } else if (sfx_id != sfx_itemup && sfx_id != sfx_tink) {
+ pitch += 16 - (M_Random() & 31);
+
+ if (pitch < 0)
+ pitch = 0;
+ else if (pitch > 255)
+ pitch = 255;
+ }
+
+ S_StopSound(origin);
+
+ cnum = S_getChannel(origin, sfx);
+
+ if (cnum < 0)
+ return;
+ if (sfx->lumpnum < 0)
+ sfx->lumpnum = I_GetSfxLumpNum(sfx);
+
+ if (!sfx->data) {
+ fprintf(stderr, "S_StartSoundAtVolume: 16bit and not pre-cached - wtf?\n");
+ }
+
+ if (sfx->usefulness++ < 0)
+ sfx->usefulness = 1;
+
+ channels[cnum].handle = I_StartSound(sfx_id,
+
+ volume,
+ sep,
+ pitch,
+ priority);
+}
+
+void
+S_StartSound(void* origin, int sfx_id)
+{
+
+ S_StartSoundAtVolume(origin, sfx_id, snd_SfxVolume);
+}
+
+void
+S_StopSound(void* origin)
+{
+
+ int cnum;
+
+ for (cnum = 0; cnum < numChannels; cnum++) {
+ if (channels[cnum].sfxinfo && channels[cnum].origin == origin) {
+ S_StopChannel(cnum);
+ break;
+ }
+ }
+}
+void
+S_PauseSound(void)
+{
+ if (mus_playing && !mus_paused) {
+ I_PauseSong(mus_playing->handle);
+ mus_paused = true;
+ }
+}
+
+void
+S_ResumeSound(void)
+{
+ if (mus_playing && mus_paused) {
+ I_ResumeSong(mus_playing->handle);
+ mus_paused = false;
+ }
+}
+
+void
+S_UpdateSounds(void* listener_p)
+{
+ int audible;
+ int cnum;
+ int volume;
+ int sep;
+ int pitch;
+ sfxinfo_t* sfx;
+ channel_t* c;
+
+ mobj_t* listener = (mobj_t*)listener_p;
+ for (cnum = 0; cnum < numChannels; cnum++) {
+ c = &channels[cnum];
+ sfx = c->sfxinfo;
+
+ if (c->sfxinfo) {
+ if (I_SoundIsPlaying(c->handle)) {
+
+ volume = snd_SfxVolume;
+ pitch = 128;
+ sep = 128;
+
+ if (sfx->link) {
+ pitch = sfx->pitch;
+ volume += sfx->volume;
+ if (volume < 1) {
+ S_StopChannel(cnum);
+ continue;
+ } else if (volume > snd_SfxVolume) {
+ volume = snd_SfxVolume;
+ }
+ }
+
+ if (c->origin && listener_p != c->origin) {
+ audible =
+ S_AdjustSoundParams(listener, c->origin, &volume, &sep, &pitch);
+
+ if (!audible) {
+ S_StopChannel(cnum);
+ } else
+ I_UpdateSoundParams(c->handle, volume, sep, pitch);
+ }
+ } else {
+
+ S_StopChannel(cnum);
+ }
+ }
+ }
+}
+
+void
+S_SetMusicVolume(int volume)
+{
+ if (volume < 0 || volume > 127) {
+ I_Error("Attempt to set music volume at %d", volume);
+ }
+
+ I_SetMusicVolume(127);
+ I_SetMusicVolume(volume);
+ snd_MusicVolume = volume;
+}
+
+void
+S_SetSfxVolume(int volume)
+{
+
+ if (volume < 0 || volume > 127)
+ I_Error("Attempt to set sfx volume at %d", volume);
+
+ snd_SfxVolume = volume;
+}
+
+void
+S_StartMusic(int m_id)
+{
+ S_ChangeMusic(m_id, false);
+}
+
+void
+S_ChangeMusic(int musicnum, int looping)
+{
+ musicinfo_t* music;
+ char namebuf[9];
+
+ if ((musicnum <= mus_None) || (musicnum >= NUMMUSIC)) {
+ I_Error("Bad music number %d", musicnum);
+ } else
+ music = &S_music[musicnum];
+
+ /* We don't know that I_Error exits, so actually a false positive;
+ see PR analyzer/108867. */
+
+ if (mus_playing == music) /* { dg-warning "use of uninitialized value 'music'" } */
+ return;
+
+ S_StopMusic();
+
+ /* We shouldn't issue further warnings about 'music' being
+ uninitialized. */
+
+ if (!music->lumpnum) { /* { dg-bogus "use of uninitialized value 'music'" } */
+ sprintf(namebuf, "d_%s", music->name); /* { dg-bogus "use of uninitialized value 'music'" } */
+ music->lumpnum = W_GetNumForName(namebuf); /* { dg-bogus "use of uninitialized value 'music'" } */
+ }
+
+ music->data = (void*)W_CacheLumpNum(music->lumpnum, 3); /* { dg-bogus "use of uninitialized value 'music'" } */
+ music->handle = I_RegisterSong(music->data); /* { dg-bogus "use of uninitialized value 'music'" } */
+
+ I_PlaySong(music->handle, looping); /* { dg-bogus "use of uninitialized value 'music'" } */
+
+ mus_playing = music; /* { dg-bogus "use of uninitialized value 'music'" } */
+}
+
+void
+S_StopMusic(void)
+{
+ if (mus_playing) {
+ if (mus_paused)
+ I_ResumeSong(mus_playing->handle);
+
+ I_StopSong(mus_playing->handle);
+ I_UnRegisterSong(mus_playing->handle);
+ {
+ if (((memblock_t*)((byte*)(mus_playing->data) - sizeof(memblock_t)))
+ ->id != 0x1d4a11)
+ I_Error("Z_CT at "
+ "s_sound.c"
+ ":%i",
+ 699);
+ Z_ChangeTag2(mus_playing->data, 101);
+ };
+ ;
+
+ mus_playing->data = 0;
+ mus_playing = 0;
+ }
+}
+
+void
+S_StopChannel(int cnum)
+{
+
+ int i;
+ channel_t* c = &channels[cnum];
+
+ if (c->sfxinfo) {
+
+ if (I_SoundIsPlaying(c->handle)) {
+
+ I_StopSound(c->handle);
+ }
+
+ for (i = 0; i < numChannels; i++) {
+ if (cnum != i && c->sfxinfo == channels[i].sfxinfo) {
+ break;
+ }
+ }
+
+ c->sfxinfo->usefulness--;
+
+ c->sfxinfo = 0;
+ }
+}
+int
+S_AdjustSoundParams(mobj_t* listener,
+ mobj_t* source,
+ int* vol,
+ int* sep,
+ int* pitch)
+{
+ fixed_t approx_dist;
+ fixed_t adx;
+ fixed_t ady;
+ angle_t angle;
+
+ adx = abs(listener->x - source->x);
+ ady = abs(listener->y - source->y);
+
+ approx_dist = adx + ady - ((adx < ady ? adx : ady) >> 1);
+
+ if (gamemap != 8 && approx_dist > (1200 * 0x10000)) {
+ return 0;
+ }
+
+ angle = R_PointToAngle2(listener->x, listener->y, source->x, source->y);
+
+ if (angle > listener->angle)
+ angle = angle - listener->angle;
+ else
+ angle = angle + (0xffffffff - listener->angle);
+
+ angle >>= 19;
+
+ *sep = 128 - (FixedMul((96 * 0x10000), finesine[angle]) >> 16);
+
+ if (approx_dist < (160 * 0x10000)) {
+ *vol = snd_SfxVolume;
+ } else if (gamemap == 8) {
+ if (approx_dist > (1200 * 0x10000))
+ approx_dist = (1200 * 0x10000);
+
+ *vol =
+ 15 + ((snd_SfxVolume - 15) * (((1200 * 0x10000) - approx_dist) >> 16)) /
+ (((1200 * 0x10000) - (160 * 0x10000)) >> 16);
+ } else {
+
+ *vol = (snd_SfxVolume * (((1200 * 0x10000) - approx_dist) >> 16)) /
+ (((1200 * 0x10000) - (160 * 0x10000)) >> 16);
+ }
+
+ return (*vol > 0);
+}
+int
+S_getChannel(void* origin, sfxinfo_t* sfxinfo)
+{
+
+ int cnum;
+
+ channel_t* c;
+
+ for (cnum = 0; cnum < numChannels; cnum++) {
+ if (!channels[cnum].sfxinfo)
+ break;
+ else if (origin && channels[cnum].origin == origin) {
+ S_StopChannel(cnum);
+ break;
+ }
+ }
+
+ if (cnum == numChannels) {
+
+ for (cnum = 0; cnum < numChannels; cnum++)
+ if (channels[cnum].sfxinfo->priority >= sfxinfo->priority) /* { dg-warning "dereference of NULL" } */
+ break;
+
+ if (cnum == numChannels) {
+
+ return -1;
+ } else {
+
+ S_StopChannel(cnum);
+ }
+ }
+
+ c = &channels[cnum];
+
+ c->sfxinfo = sfxinfo;
+ c->origin = origin;
+
+ return cnum;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/memset-CVE-2017-18549-1.c b/gcc/testsuite/gcc.dg/analyzer/memset-CVE-2017-18549-1.c
index b12408a..418168d 100644
--- a/gcc/testsuite/gcc.dg/analyzer/memset-CVE-2017-18549-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/memset-CVE-2017-18549-1.c
@@ -5,6 +5,8 @@
It was fixed by e.g. 342ffc26693b528648bdc9377e51e4f2450b4860 on linux-4.13.y
in linux-stable. */
+/* { dg-additional-options "-fno-analyzer-suppress-followups" } */
+
#include "analyzer-decls.h"
#include <string.h>
diff --git a/gcc/testsuite/gcc.dg/analyzer/null-deref-pr108830.c b/gcc/testsuite/gcc.dg/analyzer/null-deref-pr108830.c
new file mode 100644
index 0000000..417ab00
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/null-deref-pr108830.c
@@ -0,0 +1,94 @@
+/* Reduced from apr-1.7.0/tables/apr_hash.c: 'apr_hash_merge' */
+
+/* { dg-additional-options "-Wno-analyzer-too-complex" } */
+
+#define NULL ((void*)0)
+
+typedef __SIZE_TYPE__ size_t;
+
+extern void*
+memset(void* __s, int __c, size_t __n)
+ __attribute__((__nothrow__, __leaf__, __nonnull__(1)));
+
+typedef struct apr_pool_t apr_pool_t;
+
+void*
+apr_palloc(apr_pool_t* p, size_t size)
+ __attribute__((alloc_size(2), nonnull(1)));
+
+typedef struct apr_hash_t apr_hash_t;
+typedef struct apr_hash_index_t apr_hash_index_t;
+typedef unsigned int (*apr_hashfunc_t)(const char* key, size_t* klen);
+typedef struct apr_hash_entry_t apr_hash_entry_t;
+
+struct apr_hash_entry_t
+{
+ apr_hash_entry_t* next;
+ unsigned int hash;
+ const void* key;
+ size_t klen;
+ const void* val;
+};
+
+struct apr_hash_t
+{
+ apr_pool_t* pool;
+ apr_hash_entry_t** array;
+ /* [...snip.../ */
+ unsigned int count, max, seed;
+ apr_hashfunc_t hash_func;
+ apr_hash_entry_t* free;
+};
+
+static apr_hash_entry_t**
+alloc_array(apr_hash_t* ht, unsigned int max)
+{
+ return memset(apr_palloc(ht->pool, sizeof(*ht->array) * (max + 1)),
+ 0,
+ sizeof(*ht->array) * (max + 1));
+}
+
+apr_hash_t*
+apr_hash_merge(apr_pool_t* p,
+ const apr_hash_t* overlay,
+ const apr_hash_t* base)
+{
+ apr_hash_t* res;
+ apr_hash_entry_t* new_vals = NULL;
+ apr_hash_entry_t* iter;
+ unsigned int i, j, k;
+ res = apr_palloc(p, sizeof(apr_hash_t));
+ res->pool = p;
+ res->free = NULL;
+ res->hash_func = base->hash_func;
+ res->count = base->count;
+ res->max = (overlay->max > base->max) ? overlay->max : base->max;
+ if (base->count + overlay->count > res->max) {
+ res->max = res->max * 2 + 1;
+ }
+ res->seed = base->seed;
+ res->array = alloc_array(res, res->max);
+ if (base->count + overlay->count) {
+ new_vals =
+ apr_palloc(p, sizeof(apr_hash_entry_t) * (base->count + overlay->count));
+ }
+ j = 0;
+ for (k = 0; k <= base->max; k++) {
+ for (iter = base->array[k]; iter; iter = iter->next) {
+ i = iter->hash & res->max;
+ /* We should only warn for the first of these
+ (it's actually a false positive, but we don't have the
+ invariante to know that). */
+ new_vals[j].klen = iter->klen; /* { dg-warning "dereference of NULL 'new_vals'" } */
+ /* ...but not for subsequent ones: */
+ new_vals[j].key = iter->key; /* { dg-bogus "dereference of NULL 'new_vals'" "PR analyzer/108830" } */
+ new_vals[j].val = iter->val; /* { dg-bogus "dereference of NULL 'new_vals'" "PR analyzer/108830" } */
+ new_vals[j].hash = iter->hash; /* { dg-bogus "dereference of NULL 'new_vals'" "PR analyzer/108830" } */
+ new_vals[j].next = res->array[i]; /* { dg-bogus "dereference of NULL 'new_vals'" "PR analyzer/108830" } */
+ res->array[i] = &new_vals[j]; /* { dg-bogus "dereference of NULL 'new_vals'" "PR analyzer/108830" } */
+ j++;
+ }
+ }
+ /* [...snip...] */
+ return res;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pipe-1.c b/gcc/testsuite/gcc.dg/analyzer/pipe-1.c
index 6b95442..156f011 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pipe-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pipe-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-fno-analyzer-suppress-followups" } */
+
#include "analyzer-decls.h"
extern int pipe(int pipefd[2]);
diff --git a/gcc/testsuite/gcc.dg/analyzer/pipe-void-return.c b/gcc/testsuite/gcc.dg/analyzer/pipe-void-return.c
index 0de6763..8b1822d 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pipe-void-return.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pipe-void-return.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-fno-analyzer-suppress-followups" } */
+
extern void pipe(int pipefd[2]);
extern int close(int fd);
diff --git a/gcc/testsuite/gcc.dg/analyzer/pipe2-1.c b/gcc/testsuite/gcc.dg/analyzer/pipe2-1.c
index d7afc9c..aa0684e 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pipe2-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pipe2-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-fno-analyzer-suppress-followups" } */
+
#include "analyzer-decls.h"
extern int pipe2(int pipefd[2], int flags);
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr101547.c b/gcc/testsuite/gcc.dg/analyzer/pr101547.c
index b42e64c..d1c3c91 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pr101547.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pr101547.c
@@ -2,10 +2,18 @@ char *
fopen (const char *restrict, const char *restrict);
void
-k2 (void)
+k2_uninit (void)
{
char *setfiles[1];
int i; /* { dg-message "region created on stack here" } */
setfiles[i] = fopen ("", ""); /* { dg-warning "use of uninitialized value 'i'" } */
+}
+
+void
+k2_leak (int i)
+{
+ char *setfiles[1];
+
+ setfiles[i] = fopen ("", "");
} /* { dg-warning "leak of FILE" } */
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr101875.c b/gcc/testsuite/gcc.dg/analyzer/pr101875.c
index 7700c7d..4bef2f1 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pr101875.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pr101875.c
@@ -5,12 +5,22 @@ void
err (void);
void
-k2 (void)
+k2_uninit (void)
{
char *setfiles[1];
int i; /* { dg-message "region created on stack here" } */
setfiles[i] = fopen("", ""); /* { dg-warning "use of uninitialized value 'i'" } */
- if (!setfiles[i]) /* { dg-warning "use of uninitialized value 'i'" } */
+ if (!setfiles[i])
+ err ();
+}
+
+void
+k2_leak (int i)
+{
+ char *setfiles[1];
+
+ setfiles[i] = fopen("", "");
+ if (!setfiles[i])
err ();
} /* { dg-warning "leak of FILE" } */
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr104224-split.c b/gcc/testsuite/gcc.dg/analyzer/pr104224-split.c
new file mode 100644
index 0000000..b90fe55
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr104224-split.c
@@ -0,0 +1,136 @@
+#include <stdio.h>
+
+struct test {
+ int one;
+ int two;
+};
+
+void func2(const struct test *t)
+{
+ if (t->one == 0)
+ printf("init func2\n");
+
+ if (t->two == 0) /* { dg-warning "uninitialized" } */
+ printf("uninit func2\n");
+}
+
+void func1(struct test *t)
+{
+ t->one = 1;
+ func2(t);
+}
+
+int func3(int num)
+{
+ if (num)
+ return num;
+ else
+ return 0;
+}
+
+void func4(int *a, int max)
+{
+ int i;
+ // skip the first
+ for (i=1; i<max; i++)
+ a[i] = 0;
+}
+
+void func5(const int *a, int max)
+{
+ /* a[0] is uninitialized, but the rest of the array is initialized. */
+ int i;
+ for (i=0; i<max; i++) {
+ if (a[i]) /* { dg-warning "uninitialized" "" { xfail *-*-* } } */
+ printf("func5: %d\n", i);
+ }
+}
+
+int func6(const int *num)
+{
+ if (*num) /* { dg-warning "uninitialized" } */
+ return *num;
+ else
+ return 0;
+}
+
+int j;
+int func7(void)
+{
+ return j; /* { dg-bogus "uninitialized" } */
+}
+
+void func8(const int *a, int max)
+{
+ int i;
+ for (i=0; i<max; i++) {
+ if (a[i]) /* { dg-warning "uninitialized" } */
+ printf("func8: %d\n", i);
+ }
+}
+
+enum {RED, AMBER, GREEN, BLACK};
+
+int test_1 (void)
+{
+ struct test t; /* { dg-message "region created on stack here" } */
+
+ func1(&t);
+ return 0;
+}
+
+int test_2 (void)
+{
+ int num; /* { dg-message "region created on stack here" } */
+
+ func3(num); /* { dg-warning "use of uninitialized value 'num'" } */
+ return 0;
+}
+
+int test_3 (void)
+{
+ int arry[10];
+
+ func4(arry, 10);
+ func5(arry, 10);
+
+ return 0;
+}
+
+int test_4 (void)
+{
+ int num; /* { dg-message "region created on stack here" } */
+
+ func6(&num);
+ return 0;
+}
+
+int test_5 (void)
+{
+ int arry_2[10]; /* { dg-message "region created on stack here" } */
+
+ printf("func7: %d\n", func7());
+ func8(arry_2, 10);
+
+ return 0;
+}
+
+int test_6 (void)
+{
+ int go; /* { dg-message "region created on stack here" } */
+ int color = BLACK;
+
+ switch (color) {
+ case RED:
+ case AMBER:
+ go = 0;
+ break;
+ case GREEN:
+ go = 1;
+ break;
+ }
+
+ printf("go :%d\n", go); /* { dg-warning "use of uninitialized value 'go'" } */
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr104224.c b/gcc/testsuite/gcc.dg/analyzer/pr104224.c
index b047c4c..1ff5f9e 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pr104224.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pr104224.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-fno-analyzer-suppress-followups" } */
+
#include <stdio.h>
struct test {
diff --git a/gcc/testsuite/gcc.dg/analyzer/realloc-2.c b/gcc/testsuite/gcc.dg/analyzer/realloc-2.c
index a397753..ab3e4b6 100644
--- a/gcc/testsuite/gcc.dg/analyzer/realloc-2.c
+++ b/gcc/testsuite/gcc.dg/analyzer/realloc-2.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-fno-analyzer-suppress-followups" } */
+
#include "analyzer-decls.h"
typedef __SIZE_TYPE__ size_t;
diff --git a/gcc/testsuite/gcc.dg/analyzer/realloc-3.c b/gcc/testsuite/gcc.dg/analyzer/realloc-3.c
index 89676e1..eec6149 100644
--- a/gcc/testsuite/gcc.dg/analyzer/realloc-3.c
+++ b/gcc/testsuite/gcc.dg/analyzer/realloc-3.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-fno-analyzer-suppress-followups" } */
+
#include "analyzer-decls.h"
typedef __SIZE_TYPE__ size_t;
diff --git a/gcc/testsuite/gcc.dg/analyzer/realloc-5.c b/gcc/testsuite/gcc.dg/analyzer/realloc-5.c
index 75f0b70..137e05b 100644
--- a/gcc/testsuite/gcc.dg/analyzer/realloc-5.c
+++ b/gcc/testsuite/gcc.dg/analyzer/realloc-5.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-fno-analyzer-suppress-followups" } */
+
#include "analyzer-decls.h"
typedef __SIZE_TYPE__ size_t;
diff --git a/gcc/testsuite/gcc.dg/analyzer/stdarg-1-ms_abi.c b/gcc/testsuite/gcc.dg/analyzer/stdarg-1-ms_abi.c
index e55f10d..4422075 100644
--- a/gcc/testsuite/gcc.dg/analyzer/stdarg-1-ms_abi.c
+++ b/gcc/testsuite/gcc.dg/analyzer/stdarg-1-ms_abi.c
@@ -1,5 +1,6 @@
/* As per stdarg-1.c, but using the ms_abi versions of the builtins. */
+/* { dg-additional-options "-fno-analyzer-suppress-followups" } */
/* { dg-do compile { target { x86_64-*-* && lp64 } } } */
#include "analyzer-decls.h"
diff --git a/gcc/testsuite/gcc.dg/analyzer/stdarg-1-sysv_abi.c b/gcc/testsuite/gcc.dg/analyzer/stdarg-1-sysv_abi.c
index fb49b35..ba90df2 100644
--- a/gcc/testsuite/gcc.dg/analyzer/stdarg-1-sysv_abi.c
+++ b/gcc/testsuite/gcc.dg/analyzer/stdarg-1-sysv_abi.c
@@ -1,5 +1,6 @@
/* As per stdarg-1.c, but using the sysv_abi versions of the builtins. */
+/* { dg-additional-options "-fno-analyzer-suppress-followups" } */
/* { dg-do compile { target { x86_64-*-* && lp64 } } } */
#include "analyzer-decls.h"
diff --git a/gcc/testsuite/gcc.dg/analyzer/stdarg-1.c b/gcc/testsuite/gcc.dg/analyzer/stdarg-1.c
index f2766a50..4d5431b 100644
--- a/gcc/testsuite/gcc.dg/analyzer/stdarg-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/stdarg-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-fno-analyzer-suppress-followups" } */
+
#include "analyzer-decls.h"
/* Unpacking a va_list. */
diff --git a/gcc/testsuite/gcc.dg/analyzer/symbolic-1.c b/gcc/testsuite/gcc.dg/analyzer/symbolic-1.c
index 2f4e00b..0d78242 100644
--- a/gcc/testsuite/gcc.dg/analyzer/symbolic-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/symbolic-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-fno-analyzer-suppress-followups" } */
+
#include "analyzer-decls.h"
/* The example from store.h */
diff --git a/gcc/testsuite/gcc.dg/analyzer/symbolic-7.c b/gcc/testsuite/gcc.dg/analyzer/symbolic-7.c
index 665e0b6..c146455 100644
--- a/gcc/testsuite/gcc.dg/analyzer/symbolic-7.c
+++ b/gcc/testsuite/gcc.dg/analyzer/symbolic-7.c
@@ -31,16 +31,20 @@ void test_2 (int i)
__analyzer_eval (arr[i] == 42); /* { dg-warning "UNKNOWN" } */
}
-void test_3 (int i)
+void test_3_concrete_read (int i)
{
/* An array that can't have been touched. */
int arr[2];
/* Concrete reads. */
- __analyzer_eval (arr[0] == 42); /* { dg-warning "UNKNOWN" "unknown" } */
- /* { dg-warning "use of uninitialized value 'arr\\\[0\\\]'" "uninit" { target *-*-* } .-1 } */
+ __analyzer_eval (arr[0] == 42); /* { dg-warning "use of uninitialized value 'arr\\\[0\\\]'" } */
+}
+void test_3_symbolic_read (int i)
+{
+ /* An array that can't have been touched. */
+ int arr[2];
+
/* Symbolic read. */
- __analyzer_eval (arr[i] == 42); /* { dg-warning "UNKNOWN" "unknown" } */
- /* { dg-warning "use of uninitialized value 'arr\\\[i\\\]'" "uninit" { target *-*-* } .-1 } */
+ __analyzer_eval (arr[i] == 42); /* { dg-warning "use of uninitialized value 'arr\\\[i\\\]'" } */
}
diff --git a/gcc/testsuite/gcc.dg/analyzer/uninit-4.c b/gcc/testsuite/gcc.dg/analyzer/uninit-4.c
index 616cb34..31c6ae0 100644
--- a/gcc/testsuite/gcc.dg/analyzer/uninit-4.c
+++ b/gcc/testsuite/gcc.dg/analyzer/uninit-4.c
@@ -22,7 +22,7 @@ alloc_foo (int a, int b)
return p;
}
-void test (int x, int y, int z)
+void test_access_inited_fields (int x, int y, int z)
{
struct foo *p = alloc_foo (x, z);
if (!p)
@@ -30,10 +30,20 @@ void test (int x, int y, int z)
__analyzer_eval (p->i == x); /* { dg-warning "TRUE" } */
- __analyzer_eval (p->j == y); /* { dg-warning "UNKNOWN" "unknown" } */
- /* { dg-warning "use of uninitialized value '\\*p\\.j'" "uninit" { target *-*-* } .-1 } */
-
__analyzer_eval (p->k == z); /* { dg-warning "TRUE" } */
free (p);
}
+
+void test_stop_after_accessing_uninit (int x, int y, int z)
+{
+ struct foo *p = alloc_foo (x, z);
+ if (!p)
+ return;
+
+ __analyzer_eval (p->i == x); /* { dg-warning "TRUE" } */
+
+ __analyzer_eval (p->j == y); /* { dg-warning "use of uninitialized value '\\*p\\.j'" } */
+
+ __analyzer_dump_path (); /* { dg-bogus "path" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/uninit-8.c b/gcc/testsuite/gcc.dg/analyzer/uninit-8.c
new file mode 100644
index 0000000..2fa1052
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/uninit-8.c
@@ -0,0 +1,73 @@
+struct st
+{
+ int a, b, c, d, e;
+};
+
+int
+test_1 (int flag, struct st *p)
+{
+ struct st *q;
+ int result = 0;
+ if (flag)
+ q = p;
+ /* We should only warn about the first use of uninit for 'q': */
+ result += q->a; /* { dg-warning "use of uninitialized value 'q'" } */
+ /* ...and not for these: */
+ result += q->b; /* { dg-bogus "use of uninitialized value 'q'" } */
+ result += q->c; /* { dg-bogus "use of uninitialized value 'q'" } */
+ result += q->d; /* { dg-bogus "use of uninitialized value 'q'" } */
+ result += q->e; /* { dg-bogus "use of uninitialized value 'q'" } */
+ return result;
+}
+
+int
+test_2 (int flag, struct st *p, struct st *r)
+{
+ struct st *q;
+ int result = 0;
+ if (flag)
+ q = p;
+ /* We should only warn about the first use of uninit for 'q': */
+ if (q == r) /* { dg-warning "use of uninitialized value 'q'" } */
+ result += 1;
+ /* ...and not for these, after a conditional: */
+ result += q->b; /* { dg-bogus "use of uninitialized value 'q'" } */
+ result += q->c; /* { dg-bogus "use of uninitialized value 'q'" } */
+ result += q->d; /* { dg-bogus "use of uninitialized value 'q'" } */
+ result += q->e; /* { dg-bogus "use of uninitialized value 'q'" } */
+ return result;
+}
+
+int
+test_3 (int flag, int val)
+{
+ int result = 0;
+ int idx;
+ if (flag)
+ idx = val;
+ switch (idx) /* { dg-warning "use of uninitialized value 'idx'" } */
+ {
+ case 0:
+ result = 3;
+ break;
+ case 1:
+ result = 4;
+ break;
+ default:
+ result = 5;
+ break;
+ }
+ switch (idx) /* { dg-bogus "use of uninitialized value 'idx'" } */
+ {
+ case 0:
+ result += 3;
+ break;
+ case 1:
+ result += 4;
+ break;
+ default:
+ result += 5;
+ break;
+ }
+ return result;
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/uninit-pr94713.c b/gcc/testsuite/gcc.dg/analyzer/uninit-pr94713.c
index e3bb8ce..cb91462 100644
--- a/gcc/testsuite/gcc.dg/analyzer/uninit-pr94713.c
+++ b/gcc/testsuite/gcc.dg/analyzer/uninit-pr94713.c
@@ -1,11 +1,19 @@
void f1 (int *);
void f2 (int);
-int foo (void)
+int test_1 (void)
{
int *p; /* { dg-message "region created on stack here" } */
f1 (p); /* { dg-warning "use of uninitialized value 'p'" } */
+ f1 (p); /* { dg-bogus "use of uninitialized value 'p'" "no followup warnings" } */
+ return 0;
+}
+
+int test_2 (void)
+{
+ int *p; /* { dg-message "region created on stack here" } */
+
f2 (p[0]); /* { dg-warning "use of uninitialized value 'p'" } */
return 0;
}
diff --git a/gcc/testsuite/gcc.dg/analyzer/zlib-6a.c b/gcc/testsuite/gcc.dg/analyzer/zlib-6a.c
index 9676e0b..8c83de4 100644
--- a/gcc/testsuite/gcc.dg/analyzer/zlib-6a.c
+++ b/gcc/testsuite/gcc.dg/analyzer/zlib-6a.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-fno-analyzer-suppress-followups" } */
+
typedef unsigned char Byte;
typedef unsigned int uInt;
typedef unsigned long uLong;
diff --git a/gcc/testsuite/gcc.dg/pr108691.c b/gcc/testsuite/gcc.dg/pr108691.c
new file mode 100644
index 0000000..e412df1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr108691.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+extern int __attribute__((returns_twice)) setjmp(void*);
+
+void bbb(void) {
+ int (*fnptr)(void*) = setjmp;
+ fnptr(0);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr108793.c b/gcc/testsuite/gcc.dg/torture/pr108793.c
new file mode 100644
index 0000000..83973eb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr108793.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+
+typedef int *p;
+extern p a[], b[];
+int f () {
+ int n = 0;
+ for (p* i = &a[0]; i > &b[0]; i++)
+ n++;
+ return n;
+}
diff --git a/gcc/testsuite/gdc.dg/ctfeintrinsics.d b/gcc/testsuite/gdc.dg/ctfeintrinsics.d
new file mode 100644
index 0000000..0e5592b
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/ctfeintrinsics.d
@@ -0,0 +1,53 @@
+// { dg-do compile { target d_runtime_has_std_library } }
+
+//////////////////////////////////////////////////////
+// std.math.exponential
+import std.math.exponential;
+
+enum test_exp = exp(1.0L);
+enum test_expm1 = expm1(1.0L);
+enum test_exp2 = exp2(1.0L);
+enum test_log = log(1.0L);
+enum test_log2 = log2(1.0L);
+enum test_log10 = log10(1.0L);
+enum test_pow = pow(1.0L, 1L);
+enum test_powi = pow(1L, 1L);
+enum test_powf = pow(1L, 1.0L);
+enum test_powl = pow(1.0L, 1.0L);
+
+//////////////////////////////////////////////////////
+// std.math.operations
+import std.math.operations;
+
+enum test_fmin = fmin(1.0L, 2.0L);
+enum test_fmax = fmax(1.0L, 2.0L);
+enum test_fma = fma(1.0L, 2.0L, 3.0L);
+
+//////////////////////////////////////////////////////
+// std.math.rounding
+import std.math.rounding;
+
+enum test_round = round(12.34L);
+enum test_floorf = floor(12.34f);
+enum test_floor = floor(12.34);
+enum test_floorl = floor(12.34L);
+enum test_ceilf = ceil(12.34f);
+enum test_ceil = ceil(12.34);
+enum test_ceill = ceil(12.34L);
+enum test_trunc = trunc(12.34L);
+
+//////////////////////////////////////////////////////
+// std.math.traits
+import std.math.traits;
+
+enum test_isNaN = isNaN(real.nan);
+enum test_isInfinity = isInfinity(real.infinity);
+enum test_isFinite = isFinite(1.0L);
+enum test_copysign = copysign(1.0L, -1.0L);
+enum test_copysigni = copysign(1L, -1.0L);
+
+//////////////////////////////////////////////////////
+// std.math.trigonometry
+import std.math.trigonometry;
+
+enum test_tan = tan(1.0L);
diff --git a/gcc/testsuite/gdc.dg/simd2a.d b/gcc/testsuite/gdc.dg/simd2a.d
index d64f704..373d5d1 100644
--- a/gcc/testsuite/gdc.dg/simd2a.d
+++ b/gcc/testsuite/gdc.dg/simd2a.d
@@ -18,12 +18,12 @@ void test2a()
static assert(!__traits(compiles, v1 ^^ v2));
static assert(!__traits(compiles, v1 is v2));
static assert(!__traits(compiles, v1 !is v2));
- v1 = v1 == v2;
- v1 = v1 != v2;
- v1 = v1 < v2;
- v1 = v1 > v2;
- v1 = v1 <= v2;
- v1 = v1 >= v2;
+ static assert( __traits(compiles, v1 == v2));
+ static assert( __traits(compiles, v1 != v2));
+ static assert( __traits(compiles, v1 < v2));
+ static assert( __traits(compiles, v1 > v2));
+ static assert( __traits(compiles, v1 <= v2));
+ static assert( __traits(compiles, v1 >= v2));
v1 = v2 << 1;
v1 = v2 >> 1;
v1 = v2 >>> 1;
diff --git a/gcc/testsuite/gdc.dg/simd2b.d b/gcc/testsuite/gdc.dg/simd2b.d
index 71abd78..e72da0d 100644
--- a/gcc/testsuite/gdc.dg/simd2b.d
+++ b/gcc/testsuite/gdc.dg/simd2b.d
@@ -18,12 +18,12 @@ void test2b()
static assert(!__traits(compiles, v1 ^^ v2));
static assert(!__traits(compiles, v1 is v2));
static assert(!__traits(compiles, v1 !is v2));
- v1 = v1 == v2;
- v1 = v1 != v2;
- v1 = v1 < v2;
- v1 = v1 > v2;
- v1 = v1 <= v2;
- v1 = v1 >= v2;
+ static assert( __traits(compiles, v1 == v2));
+ static assert( __traits(compiles, v1 != v2));
+ static assert( __traits(compiles, v1 < v2));
+ static assert( __traits(compiles, v1 > v2));
+ static assert( __traits(compiles, v1 <= v2));
+ static assert( __traits(compiles, v1 >= v2));
v1 = v2 << 1;
v1 = v2 >> 1;
v1 = v2 >>> 1;
diff --git a/gcc/testsuite/gdc.dg/simd2c.d b/gcc/testsuite/gdc.dg/simd2c.d
index 4806b48..dc4954e 100644
--- a/gcc/testsuite/gdc.dg/simd2c.d
+++ b/gcc/testsuite/gdc.dg/simd2c.d
@@ -18,12 +18,12 @@ void test2c()
static assert(!__traits(compiles, v1 ^^ v2));
static assert(!__traits(compiles, v1 is v2));
static assert(!__traits(compiles, v1 !is v2));
- v1 = v1 == v2;
- v1 = v1 != v2;
- v1 = v1 < v2;
- v1 = v1 > v2;
- v1 = v1 <= v2;
- v1 = v1 >= v2;
+ static assert( __traits(compiles, v1 == v2));
+ static assert( __traits(compiles, v1 != v2));
+ static assert( __traits(compiles, v1 < v2));
+ static assert( __traits(compiles, v1 > v2));
+ static assert( __traits(compiles, v1 <= v2));
+ static assert( __traits(compiles, v1 >= v2));
v1 = v2 << 1;
v1 = v2 >> 1;
v1 = v2 >>> 1;
diff --git a/gcc/testsuite/gdc.dg/simd2d.d b/gcc/testsuite/gdc.dg/simd2d.d
index ce447e1..2d782ba 100644
--- a/gcc/testsuite/gdc.dg/simd2d.d
+++ b/gcc/testsuite/gdc.dg/simd2d.d
@@ -18,12 +18,12 @@ void test2d()
static assert(!__traits(compiles, v1 ^^ v2));
static assert(!__traits(compiles, v1 is v2));
static assert(!__traits(compiles, v1 !is v2));
- v1 = v1 == v2;
- v1 = v1 != v2;
- v1 = v1 < v2;
- v1 = v1 > v2;
- v1 = v1 <= v2;
- v1 = v1 >= v2;
+ static assert( __traits(compiles, v1 == v2));
+ static assert( __traits(compiles, v1 != v2));
+ static assert( __traits(compiles, v1 < v2));
+ static assert( __traits(compiles, v1 > v2));
+ static assert( __traits(compiles, v1 <= v2));
+ static assert( __traits(compiles, v1 >= v2));
v1 = v2 << 1;
v1 = v2 >> 1;
v1 = v2 >>> 1;
diff --git a/gcc/testsuite/gdc.dg/simd2e.d b/gcc/testsuite/gdc.dg/simd2e.d
index 464d1a5..b6d4ed6 100644
--- a/gcc/testsuite/gdc.dg/simd2e.d
+++ b/gcc/testsuite/gdc.dg/simd2e.d
@@ -18,12 +18,12 @@ void test2e()
static assert(!__traits(compiles, v1 ^^ v2));
static assert(!__traits(compiles, v1 is v2));
static assert(!__traits(compiles, v1 !is v2));
- v1 = v1 == v2;
- v1 = v1 != v2;
- v1 = v1 < v2;
- v1 = v1 > v2;
- v1 = v1 <= v2;
- v1 = v1 >= v2;
+ static assert( __traits(compiles, v1 == v2));
+ static assert( __traits(compiles, v1 != v2));
+ static assert( __traits(compiles, v1 < v2));
+ static assert( __traits(compiles, v1 > v2));
+ static assert( __traits(compiles, v1 <= v2));
+ static assert( __traits(compiles, v1 >= v2));
v1 = v2 << 1;
v1 = v2 >> 1;
v1 = v2 >>> 1;
diff --git a/gcc/testsuite/gdc.dg/simd2f.d b/gcc/testsuite/gdc.dg/simd2f.d
index d7e67fc..df8f13f 100644
--- a/gcc/testsuite/gdc.dg/simd2f.d
+++ b/gcc/testsuite/gdc.dg/simd2f.d
@@ -18,12 +18,12 @@ void test2f()
static assert(!__traits(compiles, v1 ^^ v2));
static assert(!__traits(compiles, v1 is v2));
static assert(!__traits(compiles, v1 !is v2));
- v1 = v1 == v2;
- v1 = v1 != v2;
- v1 = v1 < v2;
- v1 = v1 > v2;
- v1 = v1 <= v2;
- v1 = v1 >= v2;
+ static assert( __traits(compiles, v1 == v2));
+ static assert( __traits(compiles, v1 != v2));
+ static assert( __traits(compiles, v1 < v2));
+ static assert( __traits(compiles, v1 > v2));
+ static assert( __traits(compiles, v1 <= v2));
+ static assert( __traits(compiles, v1 >= v2));
v1 = v2 << 1;
v1 = v2 >> 1;
v1 = v2 >>> 1;
diff --git a/gcc/testsuite/gdc.dg/simd2g.d b/gcc/testsuite/gdc.dg/simd2g.d
index 3d15869..028b25e 100644
--- a/gcc/testsuite/gdc.dg/simd2g.d
+++ b/gcc/testsuite/gdc.dg/simd2g.d
@@ -18,12 +18,12 @@ void test2g()
static assert(!__traits(compiles, v1 ^^ v2));
static assert(!__traits(compiles, v1 is v2));
static assert(!__traits(compiles, v1 !is v2));
- v1 = v1 == v2;
- v1 = v1 != v2;
- v1 = v1 < v2;
- v1 = v1 > v2;
- v1 = v1 <= v2;
- v1 = v1 >= v2;
+ static assert( __traits(compiles, v1 == v2));
+ static assert( __traits(compiles, v1 != v2));
+ static assert( __traits(compiles, v1 < v2));
+ static assert( __traits(compiles, v1 > v2));
+ static assert( __traits(compiles, v1 <= v2));
+ static assert( __traits(compiles, v1 >= v2));
v1 = v2 << 1;
v1 = v2 >> 1;
v1 = v2 >>> 1;
diff --git a/gcc/testsuite/gdc.dg/simd2h.d b/gcc/testsuite/gdc.dg/simd2h.d
index 849b6ad..6c3e91a 100644
--- a/gcc/testsuite/gdc.dg/simd2h.d
+++ b/gcc/testsuite/gdc.dg/simd2h.d
@@ -18,12 +18,12 @@ void test2h()
static assert(!__traits(compiles, v1 ^^ v2));
static assert(!__traits(compiles, v1 is v2));
static assert(!__traits(compiles, v1 !is v2));
- v1 = v1 == v2;
- v1 = v1 != v2;
- v1 = v1 < v2;
- v1 = v1 > v2;
- v1 = v1 <= v2;
- v1 = v1 >= v2;
+ static assert( __traits(compiles, v1 == v2));
+ static assert( __traits(compiles, v1 != v2));
+ static assert( __traits(compiles, v1 < v2));
+ static assert( __traits(compiles, v1 > v2));
+ static assert( __traits(compiles, v1 <= v2));
+ static assert( __traits(compiles, v1 >= v2));
v1 = v2 << 1;
v1 = v2 >> 1;
v1 = v2 >>> 1;
diff --git a/gcc/testsuite/gdc.dg/simd2i.d b/gcc/testsuite/gdc.dg/simd2i.d
index 03130b7..2fa7f3a 100644
--- a/gcc/testsuite/gdc.dg/simd2i.d
+++ b/gcc/testsuite/gdc.dg/simd2i.d
@@ -18,12 +18,12 @@ void test2i()
static assert(!__traits(compiles, v1 ^^ v2));
static assert(!__traits(compiles, v1 is v2));
static assert(!__traits(compiles, v1 !is v2));
- v1 = v1 == v2;
- v1 = v1 != v2;
- v1 = v1 < v2;
- v1 = v1 > v2;
- v1 = v1 <= v2;
- v1 = v1 >= v2;
+ static assert( __traits(compiles, v1 == v2));
+ static assert( __traits(compiles, v1 != v2));
+ static assert( __traits(compiles, v1 < v2));
+ static assert( __traits(compiles, v1 > v2));
+ static assert( __traits(compiles, v1 <= v2));
+ static assert( __traits(compiles, v1 >= v2));
static assert(!__traits(compiles, v1 << 1));
static assert(!__traits(compiles, v1 >> 1));
static assert(!__traits(compiles, v1 >>> 1));
diff --git a/gcc/testsuite/gdc.dg/simd2j.d b/gcc/testsuite/gdc.dg/simd2j.d
index f86a448..7c2d12f 100644
--- a/gcc/testsuite/gdc.dg/simd2j.d
+++ b/gcc/testsuite/gdc.dg/simd2j.d
@@ -18,12 +18,12 @@ void test2j()
static assert(!__traits(compiles, v1 ^^ v2));
static assert(!__traits(compiles, v1 is v2));
static assert(!__traits(compiles, v1 !is v2));
- v1 = v1 == v2;
- v1 = v1 != v2;
- v1 = v1 < v2;
- v1 = v1 > v2;
- v1 = v1 <= v2;
- v1 = v1 >= v2;
+ static assert( __traits(compiles, v1 == v2));
+ static assert( __traits(compiles, v1 != v2));
+ static assert( __traits(compiles, v1 < v2));
+ static assert( __traits(compiles, v1 > v2));
+ static assert( __traits(compiles, v1 <= v2));
+ static assert( __traits(compiles, v1 >= v2));
static assert(!__traits(compiles, v1 << 1));
static assert(!__traits(compiles, v1 >> 1));
static assert(!__traits(compiles, v1 >>> 1));
diff --git a/gcc/testsuite/gdc.test/compilable/extra-files/build23499.d b/gcc/testsuite/gdc.test/compilable/extra-files/build23499.d
new file mode 100644
index 0000000..1983b4a
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/extra-files/build23499.d
@@ -0,0 +1,7 @@
+import imports.file23499;
+
+bool do_build()
+{
+ string outdir ;
+ return (exists(outdir));
+}
diff --git a/gcc/testsuite/gdc.test/compilable/imports/file23499.d b/gcc/testsuite/gdc.test/compilable/imports/file23499.d
new file mode 100644
index 0000000..76e1b78
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/imports/file23499.d
@@ -0,0 +1,19 @@
+
+///---- file.d
+struct TempCStringBuffer(To )
+{
+ ~this()
+ {
+ }
+ To* _ptr;
+}
+
+auto tempCString(To, From)(From)
+{
+ return TempCStringBuffer!To();
+}
+
+bool exists(R)(R name)
+{
+ return name.tempCString!wchar._ptr != null;
+}
diff --git a/gcc/testsuite/gdc.test/compilable/imports/test23490frop.d b/gcc/testsuite/gdc.test/compilable/imports/test23490frop.d
new file mode 100644
index 0000000..13fc78f
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/imports/test23490frop.d
@@ -0,0 +1,7 @@
+module imports.test23490frop;
+import imports.test23490pop;
+class Mu23490 : Pop23490 { }
+class Frop23490 : Pop23490 {
+ // final // does not fail if declared final
+ void frolick() {}
+}
diff --git a/gcc/testsuite/gdc.test/compilable/imports/test23490pop.d b/gcc/testsuite/gdc.test/compilable/imports/test23490pop.d
new file mode 100644
index 0000000..4757bbd
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/imports/test23490pop.d
@@ -0,0 +1,7 @@
+module imports.test23490pop;
+import imports.test23490frop;
+import imports.test23490zoo : Zoo23490;
+class Pop23490 {
+ void frop(Frop23490) { }
+ void zoo(Zoo23490) { }
+}
diff --git a/gcc/testsuite/gdc.test/compilable/imports/test23490zoo.d b/gcc/testsuite/gdc.test/compilable/imports/test23490zoo.d
new file mode 100644
index 0000000..7ae8b97
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/imports/test23490zoo.d
@@ -0,0 +1,17 @@
+module imports.test23490zoo;
+import imports.test23490pop;
+import imports.test23490frop;
+class Foo23490() : Pop23490 {
+ override void frop(Frop23490 f) {
+ f.frolick;
+ }
+}
+class Baz23490 {
+ Foo23490!() foo;
+ Frop23490 frop;
+}
+class Bar23490 {
+ static instance() { return new Baz23490; }
+ auto ss = __traits(getAttributes, instance.frop);
+}
+class Zoo23490 { }
diff --git a/gcc/testsuite/gdc.test/compilable/isexpalias.d b/gcc/testsuite/gdc.test/compilable/isexpalias.d
new file mode 100644
index 0000000..5cd8d8e
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/isexpalias.d
@@ -0,0 +1,9 @@
+// https://issues.dlang.org/show_bug.cgi?id=23578
+struct S(alias a)
+{
+}
+
+static if (is(S!int == S!av, alias av))
+ static assert(is(av == int));
+else
+ static assert(false);
diff --git a/gcc/testsuite/gdc.test/compilable/issue20618.d b/gcc/testsuite/gdc.test/compilable/issue20618.d
new file mode 100644
index 0000000..0cc90cf
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/issue20618.d
@@ -0,0 +1,10 @@
+// https://issues.dlang.org/show_bug.cgi?id=22198
+// This test was in fail_compilation, however the change in the compiler has
+// been reverted to make this code compilable again.
+void main()
+{
+ int[10] a;
+ auto b = a[1..12];
+ auto c = a[4..3];
+ auto d = a[0..$ + 1];
+}
diff --git a/gcc/testsuite/gdc.test/compilable/issue22646.d b/gcc/testsuite/gdc.test/compilable/issue22646.d
new file mode 100644
index 0000000..88a3b60
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/issue22646.d
@@ -0,0 +1,67 @@
+// https://issues.dlang.org/show_bug.cgi?id=22646
+
+static template logicalOr22646(T, const T name)
+{
+ enum bool ok = name.length < 3 || name[0..3] != "pad";
+}
+static template logicalAnd22646(T, const T name)
+{
+ enum bool ok = name.length >= 3 && name[0..3] == "pad";
+}
+
+bool runtime22646Or(T, const T name)()
+{
+ return name.length < 3 || name[0..3] != "pad";
+}
+
+// SCOPE.ctfe
+static assert(logicalOr22646!(string, "x").ok == true);
+static assert(logicalOr22646!(string, "foo").ok == true);
+static assert(logicalOr22646!(string, "pad").ok == false);
+static assert(logicalOr22646!(string, "pad123").ok == false);
+
+static assert(logicalOr22646!(char[1], "x").ok == true);
+static assert(logicalOr22646!(char[3], "foo").ok == true);
+static assert(logicalOr22646!(char[3], "pad").ok == false);
+static assert(logicalOr22646!(char[6], "pad123").ok == false);
+
+static assert(logicalAnd22646!(string, "x").ok == false);
+static assert(logicalAnd22646!(string, "foo").ok == false);
+static assert(logicalAnd22646!(string, "pad").ok == true);
+static assert(logicalAnd22646!(string, "pad123").ok == true);
+
+static assert(logicalAnd22646!(char[1], "x").ok == false);
+static assert(logicalAnd22646!(char[3], "foo").ok == false);
+static assert(logicalAnd22646!(char[3], "pad").ok == true);
+static assert(logicalAnd22646!(char[6], "pad123").ok == true);
+
+// SCOPE.compile
+enum char[1] x22646 = "x";
+enum char[3] pad22646 = "pad";
+
+static assert(__traits(compiles, x22646.length < 3 || x22646[0..3] != "pad") == true);
+static assert(__traits(compiles, x22646.length >= 3 || x22646[0..3] == "pad") == true);
+static assert(__traits(compiles, pad22646.length < 3 || pad22646[0..3] != "pad") == true);
+static assert(__traits(compiles, pad22646.length >= 3 || pad22646[0..3] == "pad") == true);
+
+// sc.intypeof
+typeof(x22646.length < 3 || x22646[0..3] != "pad") typeof22646or1;
+static assert(is(typeof(typeof22646or1) == bool));
+typeof(pad22646.length < 3 || pad22646[0..3] != "pad") typeof22646or2;
+static assert(is(typeof(typeof22646or2) == bool));
+
+typeof(x22646.length >= 3 && x22646[0..3] == "pad") typeof22646and1;
+static assert(is(typeof(typeof22646and1) == bool));
+typeof(pad22646.length >= 3 && pad22646[0..3] == "pad") typeof22646and2;
+static assert(is(typeof(typeof22646and2) == bool));
+
+// No SCOPE flags
+alias test22646a = runtime22646Or!(string, "x");
+alias test22646b = runtime22646Or!(string, "foo");
+alias test22646c = runtime22646Or!(string, "pad");
+alias test22646d = runtime22646Or!(string, "pad123");
+
+alias test22646e = runtime22646Or!(char[1], "x");
+alias test22646f = runtime22646Or!(char[3], "foo");
+alias test22646g = runtime22646Or!(char[3], "pad");
+alias test22646h = runtime22646Or!(char[6], "pad123");
diff --git a/gcc/testsuite/gdc.test/compilable/issue22854.d b/gcc/testsuite/gdc.test/compilable/issue22854.d
new file mode 100644
index 0000000..4d5a518
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/issue22854.d
@@ -0,0 +1,20 @@
+// https://issues.dlang.org/show_bug.cgi?id=22854
+void test22854()
+{
+ static foreach (ch; SomeContainer().range) { }
+}
+
+struct SomeContainer
+{
+ SomeRange range() { return SomeRange(); }
+ TypeWithDestructor data;
+}
+
+struct TypeWithDestructor { ~this() { } }
+
+struct SomeRange
+{
+ int front() { return 0; }
+ bool empty() { return true; }
+ void popFront() { }
+}
diff --git a/gcc/testsuite/gdc.test/compilable/issue22975.d b/gcc/testsuite/gdc.test/compilable/issue22975.d
new file mode 100644
index 0000000..02b59aa
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/issue22975.d
@@ -0,0 +1,12 @@
+// https://issues.dlang.org/show_bug.cgi?id=22975
+void test22975a(int) {};
+
+alias test22975b = test22975a;
+
+void test22975b(bool) {}
+
+alias test22975c = test22975b;
+
+alias test22975a = test22975c;
+
+void test22975c(float) {}
diff --git a/gcc/testsuite/gdc.test/compilable/issue23391.d b/gcc/testsuite/gdc.test/compilable/issue23391.d
new file mode 100644
index 0000000..d33242d
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/issue23391.d
@@ -0,0 +1,31 @@
+struct MyTuple {
+ string s;
+}
+
+inout(string) myfront(inout(string)[] a)
+{
+ return a[0];
+}
+
+MyTuple[] myarray(MyZip r)
+{
+ MyTuple[] result;
+ foreach (e; r)
+ result ~= e;
+ return result;
+}
+
+struct MyZip
+{
+ bool empty = false;
+ MyTuple front()
+ {
+ return MyTuple([""].myfront);
+ }
+ void popFront()
+ {
+ empty = true;
+ }
+}
+
+static foreach(t; MyZip().myarray) {}
diff --git a/gcc/testsuite/gdc.test/compilable/issue23567.d b/gcc/testsuite/gdc.test/compilable/issue23567.d
new file mode 100644
index 0000000..9c0406b
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/issue23567.d
@@ -0,0 +1,9 @@
+// https://issues.dlang.org/show_bug.cgi?id=23567
+extern(C++) abstract class CCvar
+{
+public:
+ pragma(printf) void func1(const(char)* pFormat, ...);
+ pragma(printf) void func2(const(char)* pFormat, ...);
+}
+
+static assert(__traits(getVirtualIndex, CCvar.func2) == 1);
diff --git a/gcc/testsuite/gdc.test/compilable/noreturn1.d b/gcc/testsuite/gdc.test/compilable/noreturn1.d
index e648a56..daf194d 100644
--- a/gcc/testsuite/gdc.test/compilable/noreturn1.d
+++ b/gcc/testsuite/gdc.test/compilable/noreturn1.d
@@ -150,3 +150,14 @@ void noreturnImplicit()
auto y = (throw new Exception("wow")) + value;
}
}
+
+// https://issues.dlang.org/show_bug.cgi?id=23549
+int foo(int g = assert(0)) {
+ return g;
+}
+
+// https://issues.dlang.org/show_bug.cgi?id=22587
+int front(int param)
+{
+ return param ? 1 : assert(0);
+}
diff --git a/gcc/testsuite/gdc.test/compilable/noreturn3.d b/gcc/testsuite/gdc.test/compilable/noreturn3.d
index 737125d..69689d2 100644
--- a/gcc/testsuite/gdc.test/compilable/noreturn3.d
+++ b/gcc/testsuite/gdc.test/compilable/noreturn3.d
@@ -245,13 +245,3 @@ struct S22858
static assert (S22858.arr.offsetof % size_t.sizeof == 0);
static assert (S22858.arr2.offsetof == S22858.c.offsetof + 1);
static assert (S22858.arr2.offsetof == S22858.c2.offsetof);
-
-// https://issues.dlang.org/show_bug.cgi?id=23331
-
-auto fun() { return double(new noreturn[](0)[0]); }
-auto gun() { return double(assert(0)); }
-auto hun() { return int(assert(0)); }
-
-// https://issues.dlang.org/show_bug.cgi?id=23379
-
-void casting_noreturn() { auto b = cast(double)(assert(0)); }
diff --git a/gcc/testsuite/gdc.test/compilable/test18646.d b/gcc/testsuite/gdc.test/compilable/test18646.d
new file mode 100644
index 0000000..a9d62a1
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test18646.d
@@ -0,0 +1,14 @@
+// https://issues.dlang.org/show_bug.cgi?id=18646
+class SuperClass {}
+
+class TemplatedClass(T : SuperClass) {}
+
+class A18646 : SuperClass {
+ alias T = TemplatedClass!B18646;
+}
+
+class B18646 : SuperClass {
+ alias T = TemplatedClass!C18646;
+}
+
+class C18646 : SuperClass {}
diff --git a/gcc/testsuite/gdc.test/compilable/test19585.d b/gcc/testsuite/gdc.test/compilable/test19585.d
new file mode 100644
index 0000000..a84a7ee
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test19585.d
@@ -0,0 +1,10 @@
+// https://issues.dlang.org/show_bug.cgi?id=19585
+struct S19585
+{
+ M2 stdin;
+}
+
+mixin template Handle(T, T invalid_value = T.init) {}
+
+struct M1 { mixin Handle!(size_t); }
+struct M2 { mixin Handle!(M1); }
diff --git a/gcc/testsuite/gdc.test/compilable/test22638.d b/gcc/testsuite/gdc.test/compilable/test22638.d
new file mode 100644
index 0000000..d7b5fdf
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test22638.d
@@ -0,0 +1,15 @@
+// https://issues.dlang.org/show_bug.cgi?id=22638
+
+struct S
+{
+ this(ref const(S));
+ ~this();
+}
+
+extern(C++) void set(const S s);
+
+void disp()
+{
+ S p;
+ return set(p);
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test22813.d b/gcc/testsuite/gdc.test/compilable/test22813.d
new file mode 100644
index 0000000..7cdd534
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test22813.d
@@ -0,0 +1,9 @@
+// https://issues.dlang.org/show_bug.cgi?id=22813
+struct Template(int i) { }
+uint test22813()
+{
+ Template!(1) x;
+ return 0;
+}
+immutable constant = test22813();
+alias X = Template!constant;
diff --git a/gcc/testsuite/gdc.test/compilable/test23481.d b/gcc/testsuite/gdc.test/compilable/test23481.d
new file mode 100644
index 0000000..7c03e82
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test23481.d
@@ -0,0 +1,28 @@
+// https://issues.dlang.org/show_bug.cgi?id=23481
+
+struct flagenum(I = ubyte)
+{
+ I i = 1;
+ alias i this;
+
+ auto opBinary(string s)(int j) {
+ return typeof(this)(cast(I)(i*2));
+ }
+ auto opEquals(I a) {
+ return false;
+ }
+}
+
+enum alphakey
+{
+ a = flagenum!int(), b, c, d, e, f, g, h, i, j, k, l,
+ m, n, o, p, q, r, s, t, u, v, w, x, y, z
+}
+
+flagenum!int alpha;
+
+void main()
+{
+ alpha &= alphakey.a;
+ alpha = alpha & alphakey.a; // also crashed in another way
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test23490.d b/gcc/testsuite/gdc.test/compilable/test23490.d
new file mode 100644
index 0000000..0d61a09
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test23490.d
@@ -0,0 +1,3 @@
+// https://issues.dlang.org/show_bug.cgi?id=23490
+// EXTRA_FILES: imports/test23490frop.d imports/test23490pop.d imports/test23490zoo.d
+import imports.test23490pop;
diff --git a/gcc/testsuite/gdc.test/compilable/test23497.d b/gcc/testsuite/gdc.test/compilable/test23497.d
new file mode 100644
index 0000000..7a13c04
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test23497.d
@@ -0,0 +1,19 @@
+// https://issues.dlang.org/show_bug.cgi?id=23497
+
+class A {}
+
+A getA(T t) {
+ return t.a;
+}
+
+struct T {
+ A _a;
+
+ void k() {}
+
+ auto a() in {
+ k();
+ } do {
+ return _a;
+ }
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test23499.d b/gcc/testsuite/gdc.test/compilable/test23499.d
new file mode 100644
index 0000000..12e3f25
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test23499.d
@@ -0,0 +1,6 @@
+// REQUIRED_ARGS: -inline
+// EXTRA_SOURCES: extra-files/build23499.d
+// EXTRA_FILES: imports/file23499.d
+// https://issues.dlang.org/show_bug.cgi?id=23499
+
+import imports.file23499;
diff --git a/gcc/testsuite/gdc.test/compilable/test23529.d b/gcc/testsuite/gdc.test/compilable/test23529.d
new file mode 100644
index 0000000..712c284
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test23529.d
@@ -0,0 +1,6 @@
+static assert(!__traits(compiles, ()
+{
+ char[24] x;
+ int myNumber = 4;
+ return cast(char[4]) (x[myNumber .. myNumber + 4]);
+} ()));
diff --git a/gcc/testsuite/gdc.test/compilable/test23532.d b/gcc/testsuite/gdc.test/compilable/test23532.d
new file mode 100644
index 0000000..db6bbe7
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test23532.d
@@ -0,0 +1,67 @@
+// https://issues.dlang.org/show_bug.cgi?id=23532
+// DISABLED: win32 win64
+struct _Complex(T)
+{
+ T re;
+ T im;
+ static @property epsilon()() { return _Complex(T.epsilon, T.epsilon); }
+ static @property infinity()() { return _Complex(T.infinity, T.infinity); }
+ static @property max()() { return _Complex(T.max, T.max); }
+ static @property min_normal()() { return _Complex(T.min_normal, T.min_normal); }
+ static @property nan()() { return _Complex(T.nan, T.nan); }
+ static @property dig()() { return T.dig; }
+ static @property mant_dig()() { return T.mant_dig; }
+ static @property max_10_exp()() { return T.max_10_exp; }
+ static @property max_exp()() { return T.max_exp; }
+ static @property min_10_exp()() { return T.min_10_exp; }
+ static @property min_exp()() { return T.min_exp; }
+}
+
+enum __c_complex_float : _Complex!float;
+enum __c_complex_double : _Complex!double;
+enum __c_complex_real : _Complex!real;
+
+static assert(__c_complex_float.epsilon is _Complex!float.epsilon);
+static assert(__c_complex_float.infinity is _Complex!float.infinity);
+static assert(__c_complex_float.init is _Complex!float.init);
+static assert(__c_complex_float.max is _Complex!float.max);
+static assert(__c_complex_float.min_normal is _Complex!float.min_normal);
+static assert(__c_complex_float.nan is _Complex!float.nan);
+static assert(__c_complex_float.sizeof == _Complex!float.sizeof);
+static assert(__c_complex_float.alignof == _Complex!float.alignof);
+static assert(__c_complex_float.dig == _Complex!float.dig);
+static assert(__c_complex_float.mant_dig == _Complex!float.mant_dig);
+static assert(__c_complex_float.max_10_exp == _Complex!float.max_10_exp);
+static assert(__c_complex_float.max_exp == _Complex!float.max_exp);
+static assert(__c_complex_float.min_10_exp == _Complex!float.min_10_exp);
+static assert(__c_complex_float.min_exp == _Complex!float.min_exp);
+
+static assert(__c_complex_double.epsilon is _Complex!double.epsilon);
+static assert(__c_complex_double.infinity is _Complex!double.infinity);
+static assert(__c_complex_double.init is _Complex!double.init);
+static assert(__c_complex_double.max is _Complex!double.max);
+static assert(__c_complex_double.min_normal is _Complex!double.min_normal);
+static assert(__c_complex_double.nan is _Complex!double.nan);
+static assert(__c_complex_double.sizeof == _Complex!double.sizeof);
+static assert(__c_complex_double.alignof == _Complex!double.alignof);
+static assert(__c_complex_double.dig == _Complex!double.dig);
+static assert(__c_complex_double.mant_dig == _Complex!double.mant_dig);
+static assert(__c_complex_double.max_10_exp == _Complex!double.max_10_exp);
+static assert(__c_complex_double.max_exp == _Complex!double.max_exp);
+static assert(__c_complex_double.min_10_exp == _Complex!double.min_10_exp);
+static assert(__c_complex_double.min_exp == _Complex!double.min_exp);
+
+static assert(__c_complex_real.epsilon is _Complex!real.epsilon);
+static assert(__c_complex_real.infinity is _Complex!real.infinity);
+static assert(__c_complex_real.init is _Complex!real.init);
+static assert(__c_complex_real.max is _Complex!real.max);
+static assert(__c_complex_real.min_normal is _Complex!real.min_normal);
+static assert(__c_complex_real.nan is _Complex!real.nan);
+static assert(__c_complex_real.sizeof == _Complex!real.sizeof);
+static assert(__c_complex_real.alignof == _Complex!real.alignof);
+static assert(__c_complex_real.dig == _Complex!real.dig);
+static assert(__c_complex_real.mant_dig == _Complex!real.mant_dig);
+static assert(__c_complex_real.max_10_exp == _Complex!real.max_10_exp);
+static assert(__c_complex_real.max_exp == _Complex!real.max_exp);
+static assert(__c_complex_real.min_10_exp == _Complex!real.min_10_exp);
+static assert(__c_complex_real.min_exp == _Complex!real.min_exp);
diff --git a/gcc/testsuite/gdc.test/compilable/test23533.d b/gcc/testsuite/gdc.test/compilable/test23533.d
new file mode 100644
index 0000000..6cf116e
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test23533.d
@@ -0,0 +1,10 @@
+// https://issues.dlang.org/show_bug.cgi?id=23533
+// REQUIRED_ARGS: -preview=nosharedaccess
+
+enum E { a, b }
+
+void main()
+{
+ E x = E.b;
+ E y = E.max;
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test23586.d b/gcc/testsuite/gdc.test/compilable/test23586.d
new file mode 100644
index 0000000..ee7ef3c
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test23586.d
@@ -0,0 +1,34 @@
+// https://issues.dlang.org/show_bug.cgi?id=23586
+
+int test23686a(int x)
+{
+ switch(x)
+ {
+ case 0:
+ goto Bar;
+
+ Bar:
+ default:
+ auto y = 6;
+ return y;
+ }
+}
+
+int test23686b(int x)
+{
+ switch(x)
+ {
+ case 0:
+ Bar:
+ case 1:
+ case 2:
+ auto y = 7;
+ return y;
+
+ default:
+ goto Bar;
+ }
+}
+
+static assert(test23686a(0) == 6);
+static assert(test23686b(3) == 7);
diff --git a/gcc/testsuite/gdc.test/compilable/test23587.d b/gcc/testsuite/gdc.test/compilable/test23587.d
new file mode 100644
index 0000000..6698f9c
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test23587.d
@@ -0,0 +1,18 @@
+// https://issues.dlang.org/show_bug.cgi?id=23587
+// REQUIRED_ARGS: -w
+noreturn stuff()
+{
+ assert(false);
+}
+
+void doStuff(alias fun)()
+{
+ cast(void) fun();
+ string s = "never executed";
+ static assert(is(typeof(cast(void) fun()) == void));
+}
+
+void main()
+{
+ doStuff!stuff();
+}
diff --git a/gcc/testsuite/gdc.test/compilable/test23589.d b/gcc/testsuite/gdc.test/compilable/test23589.d
new file mode 100644
index 0000000..beff31f
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/test23589.d
@@ -0,0 +1,30 @@
+// https://issues.dlang.org/show_bug.cgi?id=23589
+struct TemplStr(string Description_) {}
+
+template A() {
+ bool member;
+ alias THIS = typeof(this);
+ static THIS staticInstance;
+ static asSize()
+ {
+ return staticInstance.member;
+ }
+}
+
+template B() {
+ enum cols = columns();
+
+ enum cols_two = cols;
+ TemplStr!(cols_two) tstr;
+}
+
+struct S
+{
+ mixin A;
+ mixin B;
+
+ static string columns() {
+ auto dummy = &asSize;
+ return "as";
+ }
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail109.d b/gcc/testsuite/gdc.test/fail_compilation/fail109.d
index 7caae59..87297db 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/fail109.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail109.d
@@ -90,3 +90,19 @@ enum RegValueType2b : DWORD
DWORD = REG_DWORD,
Unknown = DWORD.min,
}
+
+/*
+TEST_OUTPUT:
+---
+fail_compilation/fail109.d(107): Error: enum member `fail109.d` initialization with `__anonymous.c+1` causes overflow for type `Q`
+---
+*/
+
+struct Q {
+ enum max = Q();
+}
+
+enum {
+ c = Q(),
+ d
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail20618.d b/gcc/testsuite/gdc.test/fail_compilation/fail20618.d
deleted file mode 100644
index ac6b33a..0000000
--- a/gcc/testsuite/gdc.test/fail_compilation/fail20618.d
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
-TEST_OUTPUT:
----
-fail_compilation/fail20618.d(13): Error: in slice `a[1 .. 12]`, upper bound is greater than array length `10`
-fail_compilation/fail20618.d(14): Error: in slice `a[4 .. 3]`, lower bound is greater than upper bound
-fail_compilation/fail20618.d(15): Error: in slice `a[0 .. 11]`, upper bound is greater than array length `10`
----
-*/
-
-void main()
-{
- int[10] a;
- auto b = a[1..12];
- auto c = a[4..3];
- auto d = a[0..$ + 1];
-}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail23151.d b/gcc/testsuite/gdc.test/fail_compilation/fail23151.d
new file mode 100644
index 0000000..e24dcc2
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail23151.d
@@ -0,0 +1,41 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/fail23151.d(30): Error: class `fail23151.makeDerivedObj.Derived` is nested within `makeDerivedObj`, but super class `Base` is nested within `makeBaseObj`
+---
+*/
+interface I
+{
+ void intfunc(int x);
+}
+
+auto makeBaseObj()
+{
+ int realPrivateX;
+ class Base : I
+ {
+ private int modulePrivateX;
+ int publicX;
+ override void intfunc(int x)
+ {
+ realPrivateX++; // expected OK
+ }
+ }
+ return new Base;
+}
+
+auto makeDerivedObj()
+{
+ int realPrivateY;
+ class Derived : typeof(makeBaseObj())
+ {
+ private int modulePrivateY;
+ int publicY;
+ override void intfunc(int x)
+ {
+ realPrivateX++; // expected NG
+ modulePrivateX++;
+ }
+ }
+ return new Derived;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail23574.d b/gcc/testsuite/gdc.test/fail_compilation/fail23574.d
new file mode 100644
index 0000000..c314d92
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail23574.d
@@ -0,0 +1,41 @@
+// https://issues.dlang.org/show_bug.cgi?id=23574
+/*
+TEST_OUTPUT:
+---
+fail_compilation/fail23574.d(26): Error: function `object._xopEquals` has no `return` statement, but is expected to return a value of type `bool`
+Error: undefined identifier `size_t` in module `object`
+fail_compilation/fail23574.d(34): Error: template instance `object.S17915!(MyClass)` error instantiating
+fail_compilation/fail23574.d(30): Error: function `object.SDL_GetKeyName` has no `return` statement, but is expected to return a value of type `const(char)`
+---
+*/
+module object;
+
+class Object
+{
+}
+
+bool opEquals(LHS, RHS)(LHS lhs, RHS)
+{
+ opEquals(cast()lhs);
+}
+
+class TypeInfo
+{
+}
+
+bool _xopEquals()
+{
+}
+
+const(char)SDL_GetKeyName()
+{
+ class MyClass
+ {
+ S17915!MyClass m_member;
+ }
+}
+
+struct S17915(T)
+{
+ T owner;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail23591.d b/gcc/testsuite/gdc.test/fail_compilation/fail23591.d
new file mode 100644
index 0000000..ddfc558
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/fail23591.d
@@ -0,0 +1,16 @@
+// https://issues.dlang.org/show_bug.cgi?id=23591
+/*
+TEST_OUTPUT:
+---
+fail_compilation/fail23591.d(13): Error: cannot implicitly convert expression `square(i) , null` of type `string` to `int`
+fail_compilation/fail23591.d(14): Error: cannot implicitly convert expression `assert(0) , null` of type `real function(char)` to `int`
+---
+*/
+noreturn square(int x);
+
+int example(int i)
+{
+ int x = cast(string)square(i);
+ int y = cast(real function(char))assert(0);
+ return x + y;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/failattr.d b/gcc/testsuite/gdc.test/fail_compilation/failattr.d
index c7f0f31..012305a 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/failattr.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/failattr.d
@@ -3,14 +3,17 @@
/*
TEST_OUTPUT:
---
-fail_compilation/failattr.d(16): Error: variable `failattr.C2901.v1` cannot be `synchronized`
-fail_compilation/failattr.d(17): Error: variable `failattr.C2901.v2` cannot be `override`
-fail_compilation/failattr.d(18): Error: variable `failattr.C2901.v3` cannot be `abstract`
-fail_compilation/failattr.d(19): Error: variable `failattr.C2901.v4` cannot be `final`, perhaps you meant `const`?
-fail_compilation/failattr.d(31): Error: variable `failattr.C2901.v13` cannot be `final abstract synchronized override`
-fail_compilation/failattr.d(33): Error: variable `failattr.C2901.v14` cannot be `final`, perhaps you meant `const`?
+fail_compilation/failattr.d(103): Error: variable `failattr.C2901.v1` cannot be `synchronized`
+fail_compilation/failattr.d(104): Error: variable `failattr.C2901.v2` cannot be `override`
+fail_compilation/failattr.d(105): Error: variable `failattr.C2901.v3` cannot be `abstract`
+fail_compilation/failattr.d(106): Error: variable `failattr.C2901.v4` cannot be `final`, perhaps you meant `const`?
+fail_compilation/failattr.d(118): Error: variable `failattr.C2901.v13` cannot be `final abstract synchronized override`
+fail_compilation/failattr.d(120): Error: variable `failattr.C2901.v14` cannot be `final`, perhaps you meant `const`?
+fail_compilation/failattr.d(123): Error: undefined identifier `ERROR`
---
*/
+#line 100
+
class C2901
{
synchronized int v1; // error
@@ -32,3 +35,5 @@ class C2901
static final int v14; // error, even if static is applied at the same time
}
+
+enum B23122 { @ERROR e }
diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice23564.d b/gcc/testsuite/gdc.test/fail_compilation/ice23564.d
new file mode 100644
index 0000000..75b5d4e
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/ice23564.d
@@ -0,0 +1,25 @@
+/* TEST_OUTPUT:
+---
+fail_compilation/ice23564.d(10): Error: cannot construct nested class `FreeList` because no implicit `this` reference to outer class `RBTree` is available
+---
+*/
+class BlockHeader
+{
+ this()
+ {
+ new FreeList;
+ }
+}
+
+class RBTree
+{
+ class FreeList
+ {
+ }
+
+ void _each_reverse()
+ {
+ }
+}
+
+alias FreeList = RBTree.FreeList;
diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice23569.d b/gcc/testsuite/gdc.test/fail_compilation/ice23569.d
new file mode 100644
index 0000000..277814f
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/ice23569.d
@@ -0,0 +1,19 @@
+// https://issues.dlang.org/show_bug.cgi?id=23569
+/*
+TEST_OUTPUT:
+---
+fail_compilation/ice23569.d(18): Error: cannot compare classes for equality because `object.Object` was not declared
+---
+*/
+module object;
+
+@safe unittest1()
+{
+ class F
+ {
+ this(int )
+ {
+ }
+ }
+ auto ice23569 = new F(0) == new F(0);
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/staticassertargs.d b/gcc/testsuite/gdc.test/fail_compilation/staticassertargs.d
new file mode 100644
index 0000000..9591fd8
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/staticassertargs.d
@@ -0,0 +1,9 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/staticassertargs.d(9): Error: static assert: abcxe3!!
+---
+*/
+
+enum e = "!!";
+static assert(false, "abc", ['x', 'e'], 3, e);
diff --git a/gcc/testsuite/gdc.test/fail_compilation/staticassertargsfail.d b/gcc/testsuite/gdc.test/fail_compilation/staticassertargsfail.d
new file mode 100644
index 0000000..911d588
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/staticassertargsfail.d
@@ -0,0 +1,10 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/staticassertargsfail.d(10): Error: incompatible types for `('x') : (new Object)`: `char` and `object.Object`
+fail_compilation/staticassertargsfail.d(10): while evaluating `static assert` argument `['x', new Object] ~ ""`
+---
+*/
+
+
+static assert(0, "abc", ['x', new Object] ~ "");
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test12228.d b/gcc/testsuite/gdc.test/fail_compilation/test12228.d
index a62eb86..d96b2a5 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test12228.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test12228.d
@@ -1,10 +1,9 @@
/*
TEST_OUTPUT:
---
-fail_compilation/test12228.d(13): Error: undefined identifier `this`, did you mean `typeof(this)`?
-fail_compilation/test12228.d(18): Error: no property `x` for type `object.Object`
+fail_compilation/test12228.d(12): Error: undefined identifier `this`, did you mean `typeof(this)`?
+fail_compilation/test12228.d(18): Error: undefined identifier `super`, did you mean `typeof(super)`?
fail_compilation/test12228.d(19): Error: undefined identifier `super`, did you mean `typeof(super)`?
-fail_compilation/test12228.d(20): Error: undefined identifier `super`, did you mean `typeof(super)`?
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test21008.d b/gcc/testsuite/gdc.test/fail_compilation/test21008.d
index 641c802..7d5bb37 100644
--- a/gcc/testsuite/gdc.test/fail_compilation/test21008.d
+++ b/gcc/testsuite/gdc.test/fail_compilation/test21008.d
@@ -12,7 +12,6 @@ fail_compilation/test21008.d(117): Error: `Monitor` has no effect
fail_compilation/test21008.d(117): Error: function `object.Object.factory(string classname)` is not callable using argument types `()`
fail_compilation/test21008.d(117): too few arguments, expected 1, got 0
fail_compilation/test21008.d(105): called from here: `handleMiddlewareAnnotation()`
-fail_compilation/test21008.d(108): Error: class `test21008.C` no size because of forward reference
---
*/
diff --git a/gcc/testsuite/gdc.test/fail_compilation/test23552.d b/gcc/testsuite/gdc.test/fail_compilation/test23552.d
new file mode 100644
index 0000000..bf9e3a6
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/test23552.d
@@ -0,0 +1,24 @@
+// https://issues.dlang.org/show_bug.cgi?id=23552
+
+/*
+TEST_OUTPUT:
+---
+fail_compilation/test23552.d(17): Error: cannot implicitly override base class method `test23552.Base.foo` with `test23552.Derived.foo`; add `override` attribute
+---
+*/
+
+abstract class Base
+{
+ void foo();
+}
+
+class Derived : Base
+{
+ void foo() { }
+ int data() { return 0; }
+}
+
+class DerivedX : Derived
+{
+ override int data() { return 1; }
+}
diff --git a/gcc/testsuite/gdc.test/runnable/issue22854.d b/gcc/testsuite/gdc.test/runnable/issue22854.d
new file mode 100644
index 0000000..c4cae17
--- /dev/null
+++ b/gcc/testsuite/gdc.test/runnable/issue22854.d
@@ -0,0 +1,27 @@
+// https://issues.dlang.org/show_bug.cgi?id=22854
+void main()
+{
+ uint loops = 0;
+ static foreach (i; 0 .. 50)
+ {
+ static foreach (ch; SomeContainer().range)
+ loops++;
+ }
+ assert(loops == 50 * 50);
+}
+
+struct SomeContainer
+{
+ SomeRange range() { return SomeRange(); }
+ TypeWithDestructor data;
+}
+
+struct TypeWithDestructor { ~this() { } }
+
+struct SomeRange
+{
+ int count = 50;
+ int front() { return count; }
+ bool empty() { return count <= 0; }
+ void popFront() { count--; }
+}
diff --git a/gcc/testsuite/gdc.test/runnable/test16098.d b/gcc/testsuite/gdc.test/runnable/test16098.d
new file mode 100644
index 0000000..16b34f1
--- /dev/null
+++ b/gcc/testsuite/gdc.test/runnable/test16098.d
@@ -0,0 +1,14 @@
+
+// https://issues.dlang.org/show_bug.cgi?id=16098
+
+void main() {
+ byte a;
+ align(128) byte b;
+ assert((cast(size_t) &b) % 128 == 0);
+
+ byte foo() { return b; }
+ dg = &foo;
+ assert(dg() == false);
+}
+
+__gshared byte delegate() dg;
diff --git a/gcc/testsuite/gdc.test/runnable/test20811.d b/gcc/testsuite/gdc.test/runnable/test20811.d
new file mode 100644
index 0000000..a300d2a
--- /dev/null
+++ b/gcc/testsuite/gdc.test/runnable/test20811.d
@@ -0,0 +1,34 @@
+// https://issues.dlang.org/show_bug.cgi?id=20811
+
+// OK: Mutable array literals are copied before CTFE takes ownership.
+string issue20811a()
+{
+ char[1] counter = ['0'];
+ counter[$-1]++;
+ return counter.dup;
+}
+
+static assert(issue20811a() == "1");
+static assert(issue20811a() == "1");
+static assert(issue20811a() == "1");
+static assert(issue20811a() == "1");
+
+// Issue 20811: String literals were assumed to be read-only, so weren't copied.
+string issue20811b()
+{
+ char[1] counter = "0";
+ counter[$-1]++;
+ return counter.dup;
+}
+
+static assert(issue20811b() == "1");
+static assert(issue20811b() == "1");
+static assert(issue20811b() == "1");
+static assert(issue20811b() == "1");
+
+void main()
+{
+ // Ensure CTFE did not overwrite the original AST.
+ assert(issue20811a() == "1");
+ assert(issue20811b() == "1");
+}
diff --git a/gcc/testsuite/gdc.test/runnable/test23307.d b/gcc/testsuite/gdc.test/runnable/test23307.d
new file mode 100644
index 0000000..a61b0d7
--- /dev/null
+++ b/gcc/testsuite/gdc.test/runnable/test23307.d
@@ -0,0 +1,93 @@
+// REQUIRED_ARGS: -inline -O
+
+// https://issues.dlang.org/show_bug.cgi?id=23307
+import core.simd;
+
+static if(__traits(compiles, int4))
+{
+
+alias __m128i = int4;
+
+uint bitwiseRotateRight_uint(const uint value, const uint count)
+{
+ assert(count < 8 * uint.sizeof);
+ return cast(uint) ((value >> count) | (value << (uint.sizeof * 8 - count)));
+}
+
+
+__m128i _mm_sha256rnds2_epu32(__m128i a, __m128i b, __m128i k)
+{
+
+ static uint Ch(uint x, uint y, uint z)
+ {
+ return z ^ (x & (y ^ z));
+ }
+
+ static uint Maj(uint x, uint y, uint z)
+ {
+ return (x & y) | (z & (x ^ y));
+ }
+
+ static uint sum0(uint x)
+ {
+ return bitwiseRotateRight_uint(x, 2) ^ bitwiseRotateRight_uint(x, 13) ^ bitwiseRotateRight_uint(x, 22);
+ }
+
+ static uint sum1(uint x)
+ {
+ return bitwiseRotateRight_uint(x, 6) ^ bitwiseRotateRight_uint(x, 11) ^ bitwiseRotateRight_uint(x, 25);
+ }
+
+ int4 dst;
+ int4 a4 = cast(int4) a;
+ int4 b4 = cast(int4) b;
+ int4 k4 = cast(int4) k;
+
+ const A0 = b4.array[3];
+ const B0 = b4.array[2];
+ const C0 = a4.array[3];
+ const D0 = a4.array[2];
+ const E0 = b4.array[1];
+ const F0 = b4.array[0];
+ const G0 = a4.array[1];
+ const H0 = a4.array[0];
+ const W_K0 = k4.array[0];
+ const W_K1 = k4.array[1];
+ const A1 = Ch(E0, F0, G0) + sum1(E0) + W_K0 + H0 + Maj(A0, B0, C0) + sum0(A0);
+ const B1 = A0;
+ const C1 = B0;
+ const D1 = C0;
+ const E1 = Ch(E0, F0, G0) + sum1(E0) + W_K0 + H0 + D0;
+ const F1 = E0;
+ const G1 = F0;
+ const H1 = G0;
+ const A2 = Ch(E1, F1, G1) + sum1(E1) + W_K1 + H1 + Maj(A1, B1, C1) + sum0(A1);
+ const B2 = A1;
+ const C2 = B1;
+ const D2 = C1;
+ const E2 = Ch(E1, F1, G1) + sum1(E1) + W_K1 + H1 + D1;
+ const F2 = E1;
+ const G2 = F1;
+ const H2 = G1;
+
+ dst.ptr[3] = A2;
+ dst.ptr[2] = B2;
+ dst.ptr[1] = E2;
+ dst.ptr[0] = F2;
+
+ return cast(__m128i) dst;
+}
+
+void main(string[] args)
+{
+ __m128i a = [15, 20, 130, 12345];
+ __m128i b = [15, 20, 130, 12345];
+ __m128i k = [15, 20, 130, 12345];
+ __m128i result = _mm_sha256rnds2_epu32(a, b, k);
+ assert(result.array == [1384123044, -2050674062, 327754346, 956342016]);
+}
+}
+else
+{
+int main() { return 0; }
+}
diff --git a/gcc/testsuite/gdc.test/runnable/test34.d b/gcc/testsuite/gdc.test/runnable/test34.d
index df46137..11543f1 100644
--- a/gcc/testsuite/gdc.test/runnable/test34.d
+++ b/gcc/testsuite/gdc.test/runnable/test34.d
@@ -1,3 +1,5 @@
+// REQUIRED_ARGS: -d
+
module test34;
import core.exception;
diff --git a/gcc/testsuite/gdc.test/runnable/xtest46.d b/gcc/testsuite/gdc.test/runnable/xtest46.d
index 8ae08ad..a0907f4 100644
--- a/gcc/testsuite/gdc.test/runnable/xtest46.d
+++ b/gcc/testsuite/gdc.test/runnable/xtest46.d
@@ -1,4 +1,4 @@
-// REQUIRED_ARGS: -preview=rvaluerefparam
+// REQUIRED_ARGS: -d -preview=rvaluerefparam
//
/* TEST_OUTPUT:
---
diff --git a/gcc/testsuite/gdc.test/runnable/xtest46_gc.d b/gcc/testsuite/gdc.test/runnable/xtest46_gc.d
index 348c05b..b0288a2 100644
--- a/gcc/testsuite/gdc.test/runnable/xtest46_gc.d
+++ b/gcc/testsuite/gdc.test/runnable/xtest46_gc.d
@@ -1,5 +1,5 @@
/*
-REQUIRED_ARGS: -lowmem -Jrunnable -preview=rvaluerefparam
+REQUIRED_ARGS: -d -lowmem -Jrunnable -preview=rvaluerefparam
EXTRA_FILES: xtest46.d
TEST_OUTPUT:
---
diff --git a/gcc/testsuite/gfortran.dg/pr96025.f90 b/gcc/testsuite/gfortran.dg/pr96025.f90
new file mode 100644
index 0000000..ce292bd
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr96025.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! PR fortran/96025 - ICE in expr_check_typed_help
+! Contributed by G.Steinmetz
+
+program p
+ print *, f()
+contains
+ character(char(1)) function f() ! { dg-error "must be of INTEGER type" }
+ f = 'f'
+ end
+end
diff --git a/gcc/tree-ssa-dce.cc b/gcc/tree-ssa-dce.cc
index ceeb0ad..0ae998f 100644
--- a/gcc/tree-ssa-dce.cc
+++ b/gcc/tree-ssa-dce.cc
@@ -1512,10 +1512,12 @@ eliminate_unnecessary_stmts (bool aggressive)
remove_edge (to_remove_edges[i]);
cfg_altered = true;
}
- /* When we cleared calls_setjmp we can purge all abnormal edges. Do so. */
- if (cfun->calls_setjmp != had_setjmp)
+ /* When we cleared calls_setjmp we can purge all abnormal edges. Do so.
+ ??? We'd like to assert that setjmp calls do not pop out of nothing
+ but we currently lack a per-stmt way of noting whether a call was
+ recognized as returns-twice (or rather receives-control). */
+ if (!cfun->calls_setjmp && had_setjmp)
{
- gcc_assert (!cfun->calls_setjmp);
/* Make sure we only remove the edges, not dominated blocks. Using
gimple_purge_dead_abnormal_call_edges would do that and we
cannot free dominators yet. */
diff --git a/gcc/tree-ssa-loop-niter.cc b/gcc/tree-ssa-loop-niter.cc
index 1ce5e73..dc4c7a4 100644
--- a/gcc/tree-ssa-loop-niter.cc
+++ b/gcc/tree-ssa-loop-niter.cc
@@ -1494,8 +1494,9 @@ number_of_iterations_until_wrap (class loop *loop, tree type, affine_iv *iv0,
if (integer_zerop (assumptions))
return false;
- num = fold_build2 (MINUS_EXPR, niter_type, wide_int_to_tree (type, max),
- iv1->base);
+ num = fold_build2 (MINUS_EXPR, niter_type,
+ wide_int_to_tree (niter_type, max),
+ fold_convert (niter_type, iv1->base));
/* When base has the form iv + 1, if we know iv >= n, then iv + 1 < n
only when iv + 1 overflows, i.e. when iv == TYPE_VALUE_MAX. */
@@ -1531,8 +1532,9 @@ number_of_iterations_until_wrap (class loop *loop, tree type, affine_iv *iv0,
if (integer_zerop (assumptions))
return false;
- num = fold_build2 (MINUS_EXPR, niter_type, iv0->base,
- wide_int_to_tree (type, min));
+ num = fold_build2 (MINUS_EXPR, niter_type,
+ fold_convert (niter_type, iv0->base),
+ wide_int_to_tree (niter_type, min));
low = min;
if (TREE_CODE (iv0->base) == INTEGER_CST)
high = wi::to_wide (iv0->base) + 1;
@@ -1546,7 +1548,6 @@ number_of_iterations_until_wrap (class loop *loop, tree type, affine_iv *iv0,
/* (delta + step - 1) / step */
step = fold_convert (niter_type, step);
- num = fold_convert (niter_type, num);
num = fold_build2 (PLUS_EXPR, niter_type, num, step);
niter->niter = fold_build2 (FLOOR_DIV_EXPR, niter_type, num, step);