]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
3 years agoAdded gcc/m2/mc-boot-ch/Gtermios.cc. devel/m2link
Gaius Mulley [Tue, 5 Jul 2022 13:49:05 +0000 (14:49 +0100)] 
Added gcc/m2/mc-boot-ch/Gtermios.cc.

gcc/m2/ChangeLog:

* mc-boot-ch/Gtermios.cc (New file).  Replacing Gtermios.c.

Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
3 years agoStatic scaffold fixes, gm2l tidyup.
Gaius Mulley [Tue, 5 Jul 2022 13:15:16 +0000 (14:15 +0100)] 
Static scaffold fixes, gm2l tidyup.

This patch fixes many static scaffold bugs and contains
a re-implementation of UnixArgs.cc and termios.cc.  gm2l
contains new options --exlude=, --include= and -flibs=.

2022-07-04  Gaius Mulley  <gaius.mulley@southwales.ac.uk>

gcc/ChangeLog:

* doc/gm2.texi (-fscaffold-c): Removed.  (-fscaffold-c++)
Removed.  (-fmodules) Removed.  (-fonlylink) Removed.

gcc/m2/ChangLog:

* Make-lang.in (UnixArgs.o): Use UnixArgs.cc.
(gm2-pge-boot/Gtermsios.o) Use mc-boot-ch/Gtermios.cc.
* bnf/gm2l.bnf: Partial re-write and introduced
--include=, --exclude= and -flibs=.  (AddUserInclude)
New procedure.  (ScanSources) Remove IncludeM2RTS
filter.  (MakeModule) Return a boolean if a new module
is seen.  (source) New field userInclude.
(source) New field userExclude.  (DisplaySources)
test for userExclude and userInclude and produce
appropriate diagnostic.  (DisplayUsage) Remove
--M2RTS.  Add -flibs=, --include-list= and --exclude-list=.
(PopulateList) New procedure.  (addInclude) New procedure.
(SetLibs) New procedure.  (SetExclude) New procedure.
(ScanArgs) Remove IncludeM2RTS.  Remove --M2RTS.
Add --include=, --exclude= and -flibs=.  Detect if multiple
source files are given and detect any unrecognized option.
* bnf/gm2m.bnf (main): Renamed as mainModule.
* gm2-compiler/M2Options.mod (SetScaffoldDynamic): Ensure that
ScaffoldStatic is not also set.  (SetScaffoldStatic) Ensure
that ScaffoldDynamic is not also set.
* gm2-compiler/M2Quads.mod (BuildM2FiniFunction):
Add ForeachModuleCallFinish for the static clause.
(BuildM2InitFunction) Add ForeachModuleCallInit for the
static clause.
* gm2-compiler/M2Scaffold.def (ForeachModuleCallInit):
New procedure.  (ForeachModuleCallFinish) New Procedure.
* gm2-compiler/M2Scaffold.mod (ForeachModuleCallInit):
New procedure implemented.  (ForeachModuleCallFinish) New
Procedure implemented.  (LookupModuleSym) New procedure.
(ReadModules) Addition parameter tok and populate
uselistModules.  (DeclareModuleExtern) Renamed from
DeclareCtorModuleExtern.
* gm2-compiler/M2Swig.mod (main): Renamed as mainModule.
* gm2-compiler/SymbolTable.def (PutModuleCtorExtern): Exported
and declared.  (MakeModuleCtor) Pass extra boolean public true.
(InitCtorFields) pub new parameter.  (PutProcedureExternPublic)
New procedure.  (PutCtorExtern) New procedure.
(PutModuleCtorExtern) New procedure.
* gm2-gcc/init.cc: Rewritten to pass envp to call init and fini
functions.
* gm2-gcc/m2expr.def: FOR "C" removed.
* gm2-libs-ch/RTcodummy.c: Undo removal of _init and _finish
functions.
* gm2-libs-ch/pthdummy.c (Removed).
* m2/gm2spec.cc (seen_scaffold_static): New boolean.
(seen_scaffold_dynamic) New boolean.  (scaffold_static)
New boolean.  (scaffold_dynamic) New boolean.
(get_libexec) Removed.  (add_exec_dir) Rewritten comment.
(lang_specific_driver) Check that dynamic scaffold and static
scaffold are not both enabled.
* mc-boot-ch/Gpth.c (Removed).
* mc-boot-ch/Gtermios.c (Removed).
* mc-boot-ch/Gtermios.cc (Added).  Converted from Gtermios.c.

gm2tools/ChangeLog:

* gm2l.1 (--M2RTS) Removed.  (-M2RTS) Removed.  (--include=) Added.
(--exclude=) Added.  (-flibs=) Added.

libgm2/ChangeLog:

* libm2iso/ErrnoCategory.cc (_finish): Changed to _fini.
* libm2iso/RTco.cc (_finish): Changed to _fini.
* libm2pim/SysExceptions.cc (_finish): Changed to _fini.
* libm2pim/errno.cc (_finish): Changed to _fini.
* libm2pim/termios.cc (_finish): Changed to _fini.

Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
3 years agoTestsuite changes reflecting changes to UnixArgs.
Gaius Mulley [Wed, 29 Jun 2022 10:01:59 +0000 (11:01 +0100)] 
Testsuite changes reflecting changes to UnixArgs.

This patch changes the tests in the testsuite which refer to UnixArgs.

2022-06-29  Gaius Mulley  <gaius.mulley@southwales.ac.uk>

gcc/testsuite/gm2/ChangeLog:

* link/pimc/pass/testgetopt.mod: Replace ArgC with
call to GetArgC and replace ArgV with a call to GetArgV.
* link/pimc/pass/testunixargs.mod: Replace ArgC with
call to GetArgC and replace ArgV with a call to GetArgV.

Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
3 years agoChanges to gcc/m2/Make-lang.in to work with the new renamed files.
Gaius Mulley [Wed, 29 Jun 2022 02:07:00 +0000 (03:07 +0100)] 
Changes to gcc/m2/Make-lang.in to work with the new renamed files.

2022-06-29  Gaius Mulley  <gaius.mulley@southwales.ac.uk>

gcc/m2/ChangeLog:

* Make-lang.in (GM2-LIBS-BOOT-C): Remove UnixArgs.c,
dtoa.c and ldtoa.c.  (GM2-LIBS-BOOT-CC) New definition
containing UnixArgs.cc, dtoa.cc and ldtoa.cc.
(GM2-LIBS-C) Remove UnixArgs.c, dtoa.c and ldtoa.c.
(GM2-LIBS-CC) New definition
containing UnixArgs.cc, dtoa.cc and ldtoa.cc.
(MC-INTERFACE-CC) New definition
containing UnixArgs.cc, dtoa.cc and ldtoa.cc.
(PPG-INTERFACE-CC) New definition
containing UnixArgs.cc, dtoa.cc and ldtoa.cc.
Adapted remaining rules to use above definitions
and added rules to build from .cc files.

Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
3 years agoRenamed files from .c to .cc and added new support header files.
Gaius Mulley [Wed, 29 Jun 2022 00:37:38 +0000 (01:37 +0100)] 
Renamed files from .c to .cc and added new support header files.

This patch also includes a mc-boot translated copy of the
module M2Dependent.

gcc/m2/ChangeLog:

* gm2-libs-ch/UnixArgs.cc: Renamed from gm2-libs-ch/UnixArgs.c.
* gm2-libs-ch/dtoa.cc: Renamed from gm2-libs-ch/dtoa.c.
* gm2-libs-ch/ldtoa.cc: Renamed from gm2-libs-ch/ldtoa.c.
* gm2-libs-ch/m2rts.h: New file.
* mc-boot-ch/GUnixArgs.cc: New file.
* mc-boot-ch/m2rts.h: New file.
* mc-boot/GM2Dependent.c: New file.
* mc-boot/GM2Dependent.h: New file.

Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
3 years agoSupport library C files changed to C++ with dynamic scaffold signature.
Gaius Mulley [Wed, 29 Jun 2022 00:02:40 +0000 (01:02 +0100)] 
Support library C files changed to C++ with dynamic scaffold signature.

This patch moves more of the C support files in the modula-2 library
into C++ files with a dynamic scaffold signature.  It also tidied
up the interface to UnixArgs and required a rebuild of the bootstrap
tool mc.

2022-06-29  Gaius Mulley  <gaius.mulley@southwales.ac.uk>

gcc/m2/ChangeLog:

* bnf/gm2l.bnf (BlockInfoPtr): Capitalized comment starts.
* gm2-libs-ch/UnixArgs.cc: Rewritten from UnixArgs.c in C++
with ctor scaffold.
* gm2-libs-ch/dtoa.cc (M2_dtoa_init): Added correct argc,
argv, envp parameters.  (M2_dtoa_finish) Added correct argc,
argv, envp parameters.  (M2_dtoa_dep) New function.
(M2_dtoa_ctor) New function.
* gm2-libs-ch/ldtoa.cc (M2_ldtoa_init): Added correct argc,
argv, envp parameters.  (M2_ldtoa_finish) Added correct argc,
argv, envp parameters.  (M2_ldtoa_dep) New function.
(M2_ldtoa_ctor) New function.
* gm2-libs-iso/ProgramArgs.mod: Changed to use GetArgC and
GetArgV.
* gm2-libs/Args.def: Renamed parameter name from i to n.
* gm2-libs/Args.mod: Changed to use GetArgC and
GetArgV.
* gm2-libs/SArgs.def: Renamed parameter name from i to n.
* gm2-libs/SArgs.mod: Changed to use GetArgC and
GetArgV.
* gm2-libs/UnixArgs.def: Rewritten to export GetArgC, GetArgV
and GetEnvV.
* init/mcinit: Commented out M2Dependent.
* mc-boot-ch/GM2LINK.c: Include cstddef.h and declare
ForcedModuleInitOrder.
* mc-boot-ch/GUnixArgs.cc: Rewritten in C++ from GUnixArgs.c.
* mc-boot/GArgs.c: Rebuilt.
* mc-boot/GArgs.h: Rebuilt.
* mc-boot/GM2RTS.c: Rebuilt.
* mc-boot/GM2RTS.h: Rebuilt.
* mc-boot/GSArgs.c: Rebuilt.
* mc-boot/GSArgs.h: Rebuilt.
* mc-boot/GUnixArgs.h: Rebuilt.
* mc-boot/Gdecl.c: Rebuilt.
* mc/mc.flex: Rebuilt.

libgm2/ChangeLog:

* libm2pim/Makefile.am (libm2pim_la_SOURCES): UnixArgs.c
removed UnixArgs.cc added.  (libm2pim_la_SOURCES) sckt.c
removed sckt.cc added.  (libm2pim_la_SOURCES) dtoa.c
removed dtoa.cc added.  (libm2pim_la_SOURCES) ldtoa.c
removed ldtoa.cc added.  (libm2pim_la_SOURCES) Selective.c
removed Selective.cc added.
* libm2pim/UnixArgs.cc: Rewritten in C++.
* libm2pim/dtoa.cc: Rewritten in C++.
* libm2pim/ldtoa.cc: Rewritten in C++.
* libm2pim/sckt.cc: Rewritten in C++.

Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
3 years agoTestsuite fixes to enable coroutine linking.
Gaius Mulley [Sun, 26 Jun 2022 23:13:57 +0000 (00:13 +0100)] 
Testsuite fixes to enable coroutine linking.

This patch allows the remaining coroutine regression tests to
link with the new dynamic module ctors and new scaffold mechanism.

2022-06-27  Gaius Mulley  <gaius.mulley@southwales.ac.uk>

gcc/testsuite/gm2/ChangeLog:

* coroutines/pim/run/pass/coroutines-pim-run-pass.exp
(gm2_link_with) Assigned to "-lm2cor -lm2pim -lm2iso".
* iso/run/pass/iso-run-pass.exp: Avoid linking the library module.
* isocoroutines/run/pass/coroutine.mod (main): Renamed mainc.
* isocoroutines/run/pass/isocoroutines-run-pass.exp
(gm2_init_pim): Configure with -fscaffold-main
-fno-scaffold-dynamic.
* link/externalscaffold/pass/scaffold.c (_M2_SYSTEM_finish):
Renamed _M2_SYSTEM_fini.  (_M2_M2RTS_finish) Renamed
_M2_M2RTS_fini.  (_M2_RTExceptions_finish) Renamed
_M2_RTExceptions_fini.  (_M2_hello_finish) Renamed
_M2_hello_fini.
* pim/options/optimize/run/pass/pim-options-optimize-run-pass.exp
(gm2_link_with): Assigned to addition.o.
* pim/run/pass/pim-run-pass.exp (gm2_link_with): Assigned to sys.o.
Avoid linking sys.mod.
* pimcoroutines/run/pass/pimcoroutines-run-pass.exp
(gm2_link_with): Assigned to "-lm2cor -lm2pim -lm2iso".
* switches/check-all/run/fail/switches-check-all-run-fail.exp
(gm2_link_with): Assigned to rangesupport.o.

Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
3 years agoRenamed libgm2 C files to C++ and removed unnecessary file.
Gaius Mulley [Sun, 26 Jun 2022 13:58:01 +0000 (14:58 +0100)] 
Renamed libgm2 C files to C++ and removed unnecessary file.

gcc/m2/ChangeLog:

* gm2-libs-iso/ErrnoCategory.c (Removed).

libgm2/ChangeLog:

* libm2iso/ErrnoCategory.cc (Renamed from ErrnoCategory.c).
* libm2iso/RTco.cc (Renamed from RTco.c).
* libm2pim/termios.cc (Renamed from termios.c).
* libm2pim/SysExceptions.cc (Renamed from SysExceptions.c).
* libm2pim/errno.cc (Renamed from errno.c).

Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
3 years agoFixes to allow -fcpp and regression test link changes.
Gaius Mulley [Sun, 26 Jun 2022 12:50:27 +0000 (13:50 +0100)] 
Fixes to allow -fcpp and regression test link changes.

This patch fixes (re-introduces) the -fcpp option and it
migrates more testsuite tcl files to use the new linking mechanism.

2022-06-26  Gaius Mulley  <gaius.mulley@southwales.ac.uk>

gcc/m2/ChangeLog:

* bnf/gm2l.bnf (ScanArgs): -fcppbegin changed to -fcpp-begin.
* gm2-compiler/M2DriverOptions.mod (ScanCppArgs):
-fcppbegin changed to -fcpp-begin, -fcppend changed to
-fcpp-end.
* gm2-compiler/M2GenGCC.mod (CodeFinallyEnd): Check
we are compiling the main module before generating
the scaffold.
* gm2-compiler/M2Options.mod (CppRemember): -fcppbegin
changed to -fcpp-begin.  (CppArg) -fcppbegin
changed to -fcpp-begin, -fcppend changed to -fcpp-end.
-fcppprog changed to -fcpp-prog.
* gm2-compiler/P2SymBuild.mod (BlockEnd): Added assert.
(PopBlock) bug fix, curModuleSym is popped in
correct sequence.
* gm2-lang.cc (gm2_langhook_init_options):
-fcppbegin changed to -fcpp-begin.  -fcppend changed to
-fcpp-end.  -fcppprog changed to -fcpp-prog.
* gm2spec.cc (get_libexec):  New function.
(gen_gm2_libexec) New function.  (add_exec_dir) New function.
(lang_register_spec_functions) add exec_prefix.
* lang-specs.h: -fcppbegin changed to -fcpp-begin.
-fcppend changed to -fcpp-end.
* lang.opt: Uniform internal switch statement used
where necessary.  -fcppbegin changed to -fcpp-begin.
-fcppend changed to -fcpp-end.  -fcppprog= changed to -fcpp-prog=.

libgm2/Changelog:

* libm2iso/m2rts.h: (New file).

Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
3 years agoFurther driver cleanup and allow forced linking of ctors.
Gaius Mulley [Sat, 25 Jun 2022 14:13:53 +0000 (15:13 +0100)] 
Further driver cleanup and allow forced linking of ctors.

This patch further cleans up the driver gm2.  It also moves
some of the C support libraries into C++ mimicing m2 ctor
behaviour.  -fuselist= is also implemented which forces
module ctors to be referenced in the scaffold.

2022-06-25  Gaius Mulley  <gaius.mulley@southwales.ac.uk>

gcc/ChangeLog:

* doc/gm2.texi (-fobject-path=): Removed.  (-fmakeinit)
Removed.  (-fmakelist) Removed.  (-fuselist) Removed.
(-fuselist=@file{filename}) Added.

gcc/m2/ChangeLog:

* m2/gm2-compiler/Lists.mod: Corrected spacing.
* m2/gm2-compiler/M2Options.def (SetUselist): New procedure.
(GetUselist) New procedure function.
* m2/gm2-compiler/M2Options.mod (UselistFilename): New
variable.  (SetUselist) New procedure implementation.
(GetUselist) New procedure implementation.
* m2/gm2-compiler/M2Quads.mod (BuildM2LinkFunction)
New procedure.  (BuildM2MainFunction) build call to
linkFunction.  (BuildScaffold) call BuildM2MainFunction.
(MakeLengthConst) Re-implemented.
* m2/gm2-compiler/M2Scaffold.def (linkFunction):
New variable.  (PopulateCtorArray) New procedure.
* m2/gm2-compiler/M2Scaffold.mod (DeclareCtorArrayType):
New procedure function.  (DeclareCtorGlobal) New procedure.
(PopulateCtorArray) New procedure.  (ReadModules) New
procedure.  (CreateCtorList) New procedure function.
(DeclareCtorModuleExtern) New procedure.
(DeclareScaffoldFunctions) Declare the ctor global array and
declare all external modules ctors.
* m2/gm2-compiler/PCSymBuild.mod: Remove stop.
* m2/gm2-compiler/SymbolTable.def (MakeProcedureCtorExtern)
New procedure function.  (PutExtern) New procedure function.
(IsExtern) New procedure function.  (MakeConstant) New
procedure function.
* m2/gm2-compiler/SymbolTable.mod (Procedure): New field IsExtern.
(MakeProcedureCtorExtern) New procedure function.
(PutExtern) New procedure.  (IsExtern) New procedure function.
(MakeConstant) New procedure function implemented.
* m2/gm2-gcc/m2options.h (SetUselist): New procedure.
* m2/gm2-lang.cc (fuselist): Removed.  (fmakelist) Removed.
(fmodules) Removed.  (fuselist_) Added.
* m2/gm2spec.cc (fuselist): Removed.
* m2/lang.opt (fuselist): Removed.  (fmakelist) Removed.
(fmodules) Removed.  (fuselist=) Added.

libgm2/Changelog:

* libm2pim/Makefile.am (M2MODS): Add M2Dependent.mod
(M2DEFS) Add M2Dependent.def.
* libm2iso/ErrnoCategory.cc (Renamed from ErrnoCategory.c).
Converted to C++.
* libm2iso/Makefile.am: Changed .c extensions to .cc.
* libm2iso/RTco.cc (Renamed from RTco.c): Converted to C++.
* libm2pim/Makefile.am: Changed .c extensions to .cc.
* libm2pim/SysExceptions.cc (Renamed from SysExceptions.c):
Converted to C++.
* libm2pim/errno.cc (Renamed from errno.c): Converted to C++.
* libm2pim/termios.cc (Renamed from termios.c): Converted to C++.

Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
3 years agoDriver cleanup and purge of unnecessary code.
Gaius Mulley [Wed, 22 Jun 2022 13:21:45 +0000 (14:21 +0100)] 
Driver cleanup and purge of unnecessary code.

This patch cleans up the driver gm2 by removing the old scaffold
support routines.  The driver is now much closer to other language
drivers with the exception of adding default libraries and include
paths if different dialects are chosen.

2022-06-22  Gaius Mulley  <gaius.mulley@southwales.ac.uk>

gcc/m2/ChangeLog:

* m2/gm2-lang.cc (gm2_langhook_init_options_struct): Remove
blank line.  (gm2_langhook_handle_option) purged options.
(ftarget_ar) Removed.  (ftarget_ranlib) Removed.  (fmakeinit)
Removed.  (fobject-path) Removed.  (fonlylink) Removed.
* m2/gm2spec.cc (GM2_PREFIX_ENV): Removed.
(add_exec_prefix) Removed.  (add_B_prefix) Removed.
(get_objects) Removed.  (*get_link_args) Removed.  (*add_exec_dir)
Removed.  (*add_exec_name) Removed.  (is_object) Removed.
(remember_object) Removed.  (remember_link_arg) Removed.
(scan_for_link_args) Removed.  (add_link_from_include) Removed.
(check_gm2_root) Removed.  (*gen_gm2_prefix) Removed.
(*gen_gm2_libexec) Removed.  (*get_libexec) Removed.
(object_list) Removed.  (head_objects) Removed.
(head_link_args) Removed.  (inclPos) Removed.
(linkPos) Removed.  (seen_fonlylink) Removed.
(seen_fmakeall0) Removed.  (seen_fmakeall) Removed.
* m2/lang.opt: (fmakeinit) Removed.  (fobject-path) Removed.

libgm2/Changelog:

* libm2pim/Makefile.am (M2MODS): Add M2Dependent.mod
(M2DEFS) Add M2Dependent.def.

Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
3 years agoNew files implementing the scaffold at compile/runtime.
Gaius Mulley [Mon, 20 Jun 2022 23:26:46 +0000 (00:26 +0100)] 
New files implementing the scaffold at compile/runtime.

gcc/m2/ChangeLog:

* gm2-compiler/M2Scaffold.def (New file).
* gm2-compiler/M2Scaffold.mod (New file).
* gm2-libs-ch/M2LINK.c (New file).
* gm2-libs/M2Dependent.def (New file).
* gm2-libs/M2Dependent.mod (New file).
* gm2-libs/M2LINK.def (New file).
* m2-link-support.h (Removed file).
* mc-boot-ch/GM2LINK.c (New file).
* mc-boot/GM2LINK.h (New file).

Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
3 years agoFirst working commit of the new scaffold implementation.
Gaius Mulley [Mon, 20 Jun 2022 22:30:19 +0000 (23:30 +0100)] 
First working commit of the new scaffold implementation.

A large commit consisting of a re-implementing of the scaffold
generation for modula-2.  The changes allow the compiler
to be built, installed and hello world can be compiled and linked.
The default scaffold generated by modula-2 is propagated to M2RTS
via ctors.  At runtime M2RTS resolves the dependency import graph
and calls each module init/fini code.

2022-06-20  Gaius Mulley  <gaius.mulley@southwales.ac.uk>

gcc/ChangeLog:

* doc/gm2.texi: Replaced English spelling to American.
(-fscaffold-static) New option documented.  (-fscaffold-dynamic)
New option documented.  (-fscaffold-c) New option documented.
(-fscaffold-c++) New option documented.

gcc/m2/ChangeLog:

* Make-lang.in (stage1/m2/cc1gm2$(exeext)): M2LINK.o added.
(GM2-LIBS-BOOT-MODS) M2Dependent.mod added.  (GM2-COMP-BOOT-MODS)
M2Scaffold.mod added.  (GM2-LIBS-DEFS) M2Dependent.def added.
(GM2-LIBS-MODS) added.  (GM2-COMP-DEFS) M2Scaffold.def added.
(GM2-COMP-MODS) M2Scaffold.mod added.
(m2/gm2-libs-boot/M2LINK.o) New rule.  (stage1/m2/gm2l$(exeext))
added M2LINK.o.  (stage1/m2/gm2lcc$(exeext)) added M2LINK.o
(stage1/m2/gm2lcc$(exeext)) added M2LINK.o.
(stage1/m2/gm2lgen$(exeext)) added M2LINK.o.
(stage1/m2/gm2lgen$(exeext)) added M2Link.o.
(stage1/m2/gm2lorder$(exeext)) added M2Link.o.
(stage1/m2/gm2m$(exeext)) added M2Link.o.
(MC-LIB-DEFS) M2LINK.def added.  (MC-INTERFACE-C)
M2LINK.c added.  (PPG-LIB-DEFS) M2Dependent.def added.
(PPG-LIB-MODS) M2Dependent.mod added.
(m2/gm2-ppg-boot/$(SRC_PREFIX)%.o) search m2/gm2-libs-boot.
(m2/ppg$(exeext)) added M2LINK.o.
(m2/gm2-pg-boot/$(SRC_PREFIX)%.o) added M2LINK.o.
(m2/gm2-pge-boot/$(SRC_PREFIX)%.o) added M2LINK.o.
* bnf/m2-1.bnf: Added production rules to record import
statements and module dependents.
* bnf/m2-2.bnf: Added production rules to record block
begin/end pairs.
* bnf/m2-3.bnf (ProgramModule): Call BuildScaffold.
(ImplementationModule) Call BuildScaffold.
* gm2-compiler/M2Base.mod: Reformatted.
* gm2-compiler/M2GCCDeclare.mod (DeclareProcedureToGcc):
Re-implemented.  (DeclareModuleInit) re-implemented.
* gm2-compiler/M2GenGCC.mod (IsExportedGcc): Check IsPublic.
(CallInnerInit) get init function using GetModuleCtors
and build call to init.  (CallInnerFinally) get fini
function using GetModuleCtors and build call to fini.
(CodeInitEnd) call GetModuleCtors and finish call to init.
(CodeFinallyStart) call GetModuleCtors and start function fini.
(CodeFinallyEnd) call GetModuleCtors and finish function fini.
Call DeclareM2linkGlobals to set the ScaffoldStatic and
ForcedModuleInitOrder variables in the main program.
(CodeKillLocalVar) test the procedure is a ctor if so call
DeclareModuleCtor and BuildModuleCtor.
(ConvertForComparison) Removed.  (DetermineFieldOf) Removed.
* gm2-compiler/M2MetaError.mod: Added import of Storage.
* gm2-compiler/M2Options.def (ScaffoldDynamic): New procedure.
(ScaffoldStatic) New procedure. (SetScaffoldDynamic) New procedure.
(SetScaffoldStatic) New procedure. (SetScaffoldMain) New
procedure.  (ScaffoldMain) New procedure.
(SetRuntimeModuleOverride) New procedure.
(GetRuntimeModuleOverride) New procedure.
* gm2-compiler/M2Options.mod: (ScaffoldDynamic): New procedure
implemented.  (ScaffoldStatic) New procedure implemented.
(SetScaffoldDynamic) New procedure implemented.
(SetScaffoldStatic) New procedure implemented.
(SetScaffoldMain) New procedure implemented.
(ScaffoldMain) New procedure implemented.
(SetRuntimeModuleOverride) New procedure implemented.
(GetRuntimeModuleOverride) New procedure implemented.
* gm2-compiler/M2Quads.def (BuildScaffold) New procedure defined.
* gm2-compiler/M2Quads.mod (BuildScaffold) New procedure
implemented.  (callRequestDependant) New procedure.
(ForeachImportedModuleDo) New procedure.  (BuildM2DepFunction)
New procedure.  (BuildM2MainFunction) New procedure.
(BuildM2InitFunction) New procedure.  (BuildM2FiniFunction)
New procedure.  (BuildM2CtorFunction) New procedure.
(BuildScaffold) New procedure.  (GetQualidentImport) use %1a
rather than %Ea.
* gm2-compiler/P1SymBuild.def (BuildImportStatement): New
procedure definition.  (AddImportToImportStatement) New
procedure definition.
* gm2-compiler/P1SymBuild.mod: (BuildImportStatement): New
procedure implementation.  (AddImportToImportStatement) New
procedure implementation.
* gm2-compiler/P2SymBuild.def (BlockStart): New procedure
definition.  (BlockEnd) New procedure definition.
(BlockBegin) New procedure definition.  (BlockFinally)
New procedure definition.
* gm2-compiler/P2SymBuild.mod (BlockStart): New procedure
implementation.  (BlockEnd) New procedure implementation.
(BlockBegin) New procedure implementation.  (BlockFinally)
New procedure implementation.
* gm2-compiler/SymbolTable.def (MakeModuleCtor):
New procedure definition.  (PutPublic) New procedure.
(IsPublic) New procedure.  (PutCtor) New procedure.
(IsCtor) New procedure.  (GetModuleCtors) New procedure.
(MakeModuleCtor) New procedure.  (MakeImport) New procedure.
(MakeImportStatement) New procedure.  (IsImport) New procedure.
(IsImportStatement) New procedure.  (GetImportModule) New
procedure.  (GetImportDeclared) New procedure.
(GetImportStatementList) New procedure.
(GetModuleDefImportStatementList) New procedure.
(GetModuleModImportStatementList) New procedure.
(AppendModuleImportStatement) New procedure.
(AppendModuleOnImportStatement) New procedure.
* gm2-compiler/SymbolTable.mod (MakeModuleCtor):
New procedure definition.  (PutPublic) New procedure.
(IsPublic) New procedure.  (PutCtor) New procedure.
(IsCtor) New procedure.  (GetModuleCtors) New procedure.
(MakeModuleCtor) New procedure.  (MakeImport) New procedure.
(MakeImportStatement) New procedure.  (IsImport) New procedure.
(IsImportStatement) New procedure.  (GetImportModule) New
procedure.  (GetImportDeclared) New procedure.
(GetImportStatementList) New procedure.
(GetModuleDefImportStatementList) New procedure.
(GetModuleModImportStatementList) New procedure.
(AppendModuleImportStatement) New procedure.
(AppendModuleOnImportStatement) New procedure.
* gm2-gcc/m2decl.cc (DeclareM2linkGlobals) New function
implementation.
(BuildModuleCtor) New function implementation.
(DeclareModuleCtor) New function implementation.
* gm2-gcc/m2decl.def (DeclareM2linkGlobals) New function.
(BuildModuleCtor) New function.  (DeclareModuleCtor)
New function.
* gm2-gcc/m2decl.h (DeclareM2linkGlobals) New function.
(BuildModuleCtor) New function.  (DeclareModuleCtor)
New function.
* gm2-gcc/m2options.h (SetScaffoldStatic) New function.
(SetScaffoldDynamic) New function.  (SetScaffoldMain)
New function.  (SetRuntimeModuleOverride) New function.
* gm2-lang.cc (fscaffold_dynamic) Handle option.
(fscaffold_static) Handle option.  (fscaffold_main)
Handle option.  (fonlylink) Commented out.
* gm2-libs-iso/M2RTS.def (ConstructModules) New procedure.
(DeconstructModules) New procedure.  (RegisterModule)
New procedure.  (RequestDependant) New procedure.
* gm2-libs-iso/M2RTS.mod (ConstructModules) New procedure.
(DeconstructModules) New procedure.  (RegisterModule)
New procedure.  (RequestDependant) New procedure.
Replace termination and initial procedures using a dynamic
data structure.  Call upon M2Dependent to solve module
dependencies.
* gm2-libs/M2RTS.def (ConstructModules) New procedure.
(DeconstructModules) New procedure.  (RegisterModule)
New procedure.  (RequestDependant) New procedure.
* gm2-libs/M2RTS.mod (ConstructModules) New procedure.
(DeconstructModules) New procedure.  (RegisterModule)
New procedure.  (RequestDependant) New procedure.
Replace termination and initial procedures using a dynamic
data structure.  Call upon M2Dependent to solve module
dependencies.
* gm2spec.cc (check_gm2_root): Commented out.
(add_exec_prefix) Commented out.  (fonlylink) Commented out.
(fmakeall) Commented out.  (fmakeall0) Commented out.
(add_exec_prefix) Commented out.  (lang_register_spec_functions)
body commented out.
* lang-specs.h (m2-link-support.h) no longer included.
(M2CPP) defined.
* lang.opt (fuselist) New description.  (fmakelist)
New description.  (fonlylink) removed.  (fscaffold-static)
New option.  (fscaffold-dynamic) New option.  (ftarget-ranlib=)
Removed.  (fscaffold-c) New option.  (fscaffold-c++) New option.
(fscaffold-main) New option.
* mc-boot-ch/GM2LINK.c: New file.
* mc-boot/GAssertion.h: Rebuilt.
* mc-boot/GDynamicStrings.c: Rebuilt.
* mc-boot/GDynamicStrings.h: Rebuilt.
* mc-boot/GEnvironment.h: Rebuilt.
* mc-boot/GFIO.c: Rebuilt.
* mc-boot/GFIO.h: Rebuilt.
* mc-boot/GFormatStrings.h: Rebuilt.
* mc-boot/GIndexing.c: Rebuilt.
* mc-boot/GM2EXCEPTION.c: Rebuilt.
* mc-boot/GM2RTS.c: Rebuilt.
* mc-boot/GM2RTS.h: Rebuilt.
* mc-boot/GPushBackInput.c: Rebuilt.
* mc-boot/GRTExceptions.c: Rebuilt.
* mc-boot/GRTint.c: Rebuilt.
* mc-boot/GSYSTEM.h: Rebuilt.
* mc-boot/GStdIO.c: Rebuilt.
* mc-boot/GStringConvert.c: Rebuilt.
* mc-boot/GSysStorage.c:
* mc-boot/Gdecl.c: Rebuilt.
* mc-boot/Gkeyc.c: Rebuilt.
* mc-boot/GmcComment.c: Rebuilt.
* mc-boot/GmcComp.c: Rebuilt.
* mc-boot/GmcDebug.c: Rebuilt.
* mc-boot/GmcMetaError.c: Rebuilt.
* mc-boot/GmcStack.c: Rebuilt.
* mc-boot/GnameKey.c: Rebuilt.
* mc-boot/GsymbolKey.c: Rebuilt.
* mc/decl.mod (isLastStatement) Check if n = NIL
* mc/mcComp.mod: Change spelling to initialization.
and return FALSE.
* tools-src/makeSystem (MINIMAL): New variable.
Use MINIMAL when invoking gm2 to generate the SYSTEM exports.

libgm2/Changelog:

* libm2min/Makefile.am (libm2min_la_M2FLAGS):
Added -fno-scaffold-dynamic -fno-scaffold-main.
* libm2pim/Makefile.am (M2DEFS): Added M2LINK.def.

Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
3 years agoRemove m2 front end linking support.
Gaius Mulley [Mon, 30 May 2022 20:05:35 +0000 (21:05 +0100)] 
Remove m2 front end linking support.

2022-05-30  Gaius Mulley  <gaius.mulley@southwales.ac.uk>

All m2 linking assistance by the Modula-2 front end is disabled.
cc1gm2 handles the -c option but currently does nothing with the option.
New gcc/testsuite/gm2/link/externalscaffold added to check the compiler
can link trivial application against a hand built scaffold.

gcc/testsuite/gm2/ChangeLog:

* link/externalscaffold: (New regression test).  Manual linking
test using external scaffold.

gcc/m2/ChangeLog:

* gm2-compiler/M2Options.def (cflag): New boolean.
(Setc) New procedure.  (Getc) New procedure function.
* gm2-compiler/M2Options.mod (Setc): New procedure.
(Getc) New procedure function.  Initialize cflag to
FALSE.
* gm2-gcc/m2options.h (Setc): New external function.
(Getc) New external function.
* gm2-lang.cc: Handle OPT_c and call M2Options_Setc.
* lang-specs.h: Remove all link rules for m2.
* lang.opt: Allow m2 to process the -c option.

Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
3 years agoMerge branch 'master' into devel/m2link.
Gaius Mulley [Mon, 30 May 2022 13:42:14 +0000 (14:42 +0100)] 
Merge branch 'master' into devel/m2link.

3 years agox86: correct bmi2_umul<mode><dwi>3_1's MEM_P() uses
Jan Beulich [Mon, 30 May 2022 09:29:59 +0000 (11:29 +0200)] 
x86: correct bmi2_umul<mode><dwi>3_1's MEM_P() uses

It's pretty clear that the operand numbers in the MEM_P() checks are
off by one, perhaps due to a copy-and-paste oversight (unlike in most
other places here we're dealing with two outputs).

gcc/

* config/i386/i386.md (bmi2_umul<mode><dwi>3_1): Correct MEM_P()
arguments.

3 years ago[Ada] Fix spurious options being inserted in -fdiagnostics-format=json output
Ghjuvan Lacambre [Fri, 29 Apr 2022 14:53:05 +0000 (16:53 +0200)] 
[Ada] Fix spurious options being inserted in -fdiagnostics-format=json output

Without this patch, gnat would use `-gnatw?` as the default option for
some of the default warnings.

gcc/ada/

* erroutc.adb (Get_Warning_Option): Don't consider `?` as a
valid option switch.

3 years ago[Ada] Add "option" field to GNAT's -fdiagnostics-format=json output
Ghjuvan Lacambre [Wed, 27 Apr 2022 13:01:28 +0000 (15:01 +0200)] 
[Ada] Add "option" field to GNAT's -fdiagnostics-format=json output

This enables better integration with tools that handle GNAT's output.

gcc/ada/

* erroutc.ads (Get_Warning_Option): New function returning the
option responsible for a warning if it exists.
* erroutc.adb (Get_Warning_Option): Likewise.
(Get_Warning_Tag): Rely on Get_Warning_Option when possible.
* errout.adb (Output_JSON_Message): Emit option field.

3 years ago[Ada] Remove contract duplication in formal doubly linked lists
Julien Bortolussi [Mon, 25 Apr 2022 08:53:15 +0000 (10:53 +0200)] 
[Ada] Remove contract duplication in formal doubly linked lists

Remove a minor duplication in Post of a function of formal doubly linked
lists.

gcc/ada/

* libgnat/a-cfdlli.ads (Insert): Remove the duplication.

3 years ago[Ada] Fix expansion of structural subprogram variants
Piotr Trojanek [Wed, 27 Apr 2022 15:30:59 +0000 (17:30 +0200)] 
[Ada] Fix expansion of structural subprogram variants

When implementing structural subprogram variants we ignored them in
expansion of the pragma itself, but not in expansion of a recursive
subprogram call. Now fixed.

gcc/ada/

* exp_ch6.adb (Check_Subprogram_Variant): Ignore structural
variants.

3 years ago[Ada] Simplify construction of a path to file
Piotr Trojanek [Fri, 25 Mar 2022 23:11:35 +0000 (00:11 +0100)] 
[Ada] Simplify construction of a path to file

Code cleanup; semantics is unaffected.

gcc/ada/

* osint.adb (Locate_File): Change variable to constant and
initialize it by concatenation of directory, file name and NUL.

3 years ago[Ada] Remove repeated description of support for Address clauses
Piotr Trojanek [Fri, 8 Apr 2022 21:27:24 +0000 (23:27 +0200)] 
[Ada] Remove repeated description of support for Address clauses

The GNAT behaviour regarding the Ada RM requirement to support Address
clauses for imported subprograms was documented twice: in section about
packed types (which was a mistake) and in section about address clauses
(where it belongs).

Cleanup related to the use of packed arrays for bitset operations to
detect uses of uninitialized scalars in GNAT.

gcc/ada/

* doc/gnat_rm/implementation_advice.rst (Packed Types): Remove
duplicated and wrongly placed paragraph.
* gnat_rm.texi: Regenerate.

3 years ago[Ada] Add insertion character to Ineffective_Inline_Warnings messages
Ghjuvan Lacambre [Tue, 26 Apr 2022 07:55:04 +0000 (09:55 +0200)] 
[Ada] Add insertion character to Ineffective_Inline_Warnings messages

This enables tools that ingest GNAT's output to properly classify these
messages.

gcc/ada/

* inline.adb (Check_Package_Body_For_Inlining): Add insertion
character.

3 years ago[Ada] Add insertion character for overlay modification warnings
Ghjuvan Lacambre [Tue, 26 Apr 2022 07:50:24 +0000 (09:50 +0200)] 
[Ada] Add insertion character for overlay modification warnings

This enables tools that ingest GNAT's output to properly classify these
messages.

gcc/ada/

* freeze.adb (Warn_Overlay): Add 'o' insertion character.
* sem_ch13.adb (Analyze_Attribute_Definition_Clause): Likewise.
* sem_util.adb (Note_Possible_Modifications): Likewise.

3 years ago[Ada] Fix Warn_On_All_Unread_Out_Parameters not being properly tagged
Ghjuvan Lacambre [Tue, 26 Apr 2022 07:32:59 +0000 (09:32 +0200)] 
[Ada] Fix Warn_On_All_Unread_Out_Parameters not being properly tagged

This caused tools ingesting GNAT's output to mislabel these messages.

gcc/ada/

* sem_warn.adb (Warn_On_Useless_Assignment): Fix insertion
character.

3 years ago[Ada] Fix Warn_On_Late_Primitives messages not being properly tagged
Ghjuvan Lacambre [Tue, 26 Apr 2022 07:25:52 +0000 (09:25 +0200)] 
[Ada] Fix Warn_On_Late_Primitives messages not being properly tagged

This caused tools ingesting GNAT's output to mislabel these messages.

gcc/ada/

* sem_disp.adb (Warn_On_Late_Primitive_After_Private_Extension):
Fix insertion character.

3 years ago[Ada] Fix -gnatw.f warnings not having the right insertion characters
Ghjuvan Lacambre [Tue, 26 Apr 2022 07:21:01 +0000 (09:21 +0200)] 
[Ada] Fix -gnatw.f warnings not having the right insertion characters

This caused these warnings not to be tagged with the switch causing
them, which is an issue for tools ingesting GNAT's output.

gcc/ada/

* sem_elab.adb (Process_Conditional_ABE_Access_Taken): Add '.f'
insertion characters.

3 years ago[Ada] Deconstruct deferred references
Piotr Trojanek [Tue, 26 Apr 2022 13:21:00 +0000 (15:21 +0200)] 
[Ada] Deconstruct deferred references

While cleaning up and modifying code for unreferenced warnings we
removed all calls to Defer_Reference, which was the only routine that
populated the Deferred_References table. Consequently, all the code
related to this table became dead.

gcc/ada/

* lib-xref.ads (Deferred_Reference_Entry, Defer_Reference,
Process_Deferred_References, Has_Deferred_Reference): Remove
client API.
* lib-xref.adb (Deferred_References, Defer_Reference,
Has_Deferred_Reference, Process_Deferred_References): Remove
implementation.
* frontend.adb, sem_ch11.adb, sem_ch5.adb, sem_res.adb,
sem_util.adb, sem_warn.adb: Remove uses of Deferred_References.

3 years ago[Ada] Avoid creating a finalization wrapper block for functions
Bob Duff [Tue, 26 Apr 2022 11:16:20 +0000 (07:16 -0400)] 
[Ada] Avoid creating a finalization wrapper block for functions

This patch fixes a bug whereby if a function body has local objects that
are finalizable, and has a return statement that requires generation of
transient finalizable temps, and there are dynamic-sized objects
requiring pushing/popping the (primary) stack at run time, and the
function body has exception handlers, then incorrect code is
generated. In particular, the transient objects are finalized after they
have been deallocated. This can cause seg faults, corrupted heap, and
the like.

Note that if there are no dynamic-sized objects, then the bug does
not occur, because the back end allocates objects of compile-time-known
size based on where they are referenced, rather than which local
block they are declared in.

This patch relies on the fact that an At_End handler and regular
exception handlers CAN coexist in the same handled statement sequence,
which was not true some years ago.

gcc/ada/

* exp_ch7.adb (Wrap_HSS_In_Block): Do not create a new block in
the case of function bodies. We include all subprogram bodies,
because it's harmless for procedures. We cannot easily avoid
creating this block in ALL cases, because some transformations
of (e.g.) task bodies end up moving some code such that the
wrong exception handlers apply to that code.
(Build_Finalizer_Call): Remove code for creating a new block.
This was unreachable code, given that Wrap_HSS_In_Block has
already done that, but with the above change to
Wrap_HSS_In_Block, this code becomes reachable, and triggers
essentially the same bug.
* exp_ch7.ads: Adjust comment.

3 years ago[Ada] Incorrect unreferenced warnings on null subprograms and formals with aspects
Justin Squirek [Thu, 21 Apr 2022 20:35:20 +0000 (20:35 +0000)] 
[Ada] Incorrect unreferenced warnings on null subprograms and formals with aspects

This patch corrects an error in the compiler whereby spurious
unreferenced warnings are generated on formal parameters of null generic
subprograms.

These changes also fix the parsing of aspects on formal parameters such
that the aspects now get properly set for all formal parameters in a
parameter list.

gcc/ada/

* par-ch6.adb (P_Formal_Part): Set Aspect_Specifications on all
formals instead of just the last in a formal id list.
* sem_ch6.adb (Analyze_Null_Procedure): Mark expanded null
generic procedures as trivial in order to avoid spurious
unreferenced warnings.

3 years ago[Ada] Fix illegal Ada in s-dwalin.adb
Romain Beguet [Mon, 25 Apr 2022 13:57:25 +0000 (15:57 +0200)] 
[Ada] Fix illegal Ada in s-dwalin.adb

Both the `System.Mmap` and `System.Object_Reader` packages are defining
entities named `Offset` and they are both `use`d at the top of
s-dwalin.adb.

Therefore, the references to `Offset` throughout this file are
ambiguous, and GNAT is supposed to complain. Since it does not for the
moment, we fix the ambiguity by declaring a subtype `Offset` at the top
of the file simply renames `System.Object_Reader.Offset`.

gcc/ada/

* libgnat/s-dwalin.adb: Add a subtype declaration to fix the
ambiguity.

3 years ago[Ada] Incorrect determination of whether an expression is predicate-static
Steve Baird [Wed, 20 Apr 2022 21:48:11 +0000 (14:48 -0700)] 
[Ada] Incorrect determination of whether an expression is predicate-static

The expression given in a Static_Predicate aspect specification is
required to be predicate-static. The implementation of this compile-time
check was incorrect in some cases. There were problems in both
directions: expressions that are not predicate-static were incorrectly
treated as though they were and vice versa. This led to both accepting
invalid code and to rejecting valid code.

gcc/ada/

* sem_ch13.adb (Is_Predicate_Static): Do not generate warnings
about subexpressions of enclosing expressions. Generate warnings
for predicates that are known to be always true or always false,
except in the case where the predicate is expressed as a Boolean
literal. Deal with non-predicate-static expressions that have
been transformed into predicate-static expressions.  Add missing
Is_Type_Ref call to N_Membership_Test case.

3 years ago[Ada] Fix expansion of aggregate for discriminated limited extension
Eric Botcazou [Sat, 23 Apr 2022 10:28:28 +0000 (12:28 +0200)] 
[Ada] Fix expansion of aggregate for discriminated limited extension

The presence of the discriminants prevents the values associated with the
components of the parent type from being put into the sub-aggregate built
for the _Parent component.

gcc/ada/

* exp_aggr.adb (Expand_Record_Aggregate.Build_Back_End_Aggregate):
Skip the discriminants at the start of the component list before
looking for the components inherited from the parent in the case
of a tagged extension.

3 years ago[Ada] Do not freeze specifically for dispatch tables
Eric Botcazou [Fri, 22 Apr 2022 23:09:39 +0000 (01:09 +0200)] 
[Ada] Do not freeze specifically for dispatch tables

The left-overs of the old freezing code in Make_DT are now redundant since
the semantic analyzer performs the same task for the 'Access attribute.

gcc/ada/

* exp_disp.adb (Make_DT): Remove remaining freezing code.

3 years ago[Ada] Do not analyze expression functions for dispatch tables
Eric Botcazou [Fri, 22 Apr 2022 20:27:22 +0000 (22:27 +0200)] 
[Ada] Do not analyze expression functions for dispatch tables

There is no need to analyze expression functions that are primitives of a
tagged type for its dispatch table because they will be analyzed at the end
of the current scope.

gcc/ada/

* sem_attr.adb (Resolve_Attribute) <Attribute_Access>: Don't analyze
the body of an expression function in the case of a dispatch table.

3 years ago[Ada] Introduce Opt.CCG_Mode
Arnaud Charlet [Fri, 22 Apr 2022 08:32:37 +0000 (08:32 +0000)] 
[Ada] Introduce Opt.CCG_Mode

To handle code common to the old and the new CCG code generator.

gcc/ada/

* gnat1drv.adb, opt.ads, sem_ch7.adb: Introduce CCG_Mode.

3 years ago[Ada] Update proofs of double arithmetic unit after prover changes
Yannick Moy [Tue, 19 Apr 2022 15:46:05 +0000 (15:46 +0000)] 
[Ada] Update proofs of double arithmetic unit after prover changes

Changes in GNATprove (translation to Why3 and provers) result in proofs
being much less automatic, and requiring ghost code to detail
intermediate steps. In some cases, it is better to use the new By
mechanism to prove assertions in steps, as this avoids polluting the
proof context for other proofs. For that reason, add units s-spark.ads
and s-spcuop.ads/b to the runtime sources.

gcc/ada/

* Makefile.rtl: Add new units.
* libgnat/s-aridou.adb (Scaled_Divide): Add ghost code for provers.
* libgnat/s-spcuop.adb: New unit for ghost cut operations.
* libgnat/s-spcuop.ads: New unit for ghost cut operations.
* libgnat/s-spark.ads: New unit.

3 years ago[Ada] Tweaks to hardening docs
Alexandre Oliva [Thu, 21 Apr 2022 03:17:28 +0000 (00:17 -0300)] 
[Ada] Tweaks to hardening docs

Mention when security hardening features are available in other
languages.

Expand the strub documentation a little, for clarity and completeness.

Add missing 'aliased' and attribute to variables in strub example.

gcc/ada/

* doc/gnat_rm/security_hardening_features.rst: Mention
availability in other languages when applicable.
(Stack Scrubbing): Associate the attribute with types, expand
some comments, fix the example involving access to variables.
* gnat_rm.texi: Regenerate.

3 years ago[Ada] Fix typo in comment for functional sets
Piotr Trojanek [Thu, 21 Apr 2022 19:36:15 +0000 (21:36 +0200)] 
[Ada] Fix typo in comment for functional sets

Minor fix in a recently added comment.

gcc/ada/

* libgnat/a-cofuse.ads (Empty_Set): Fix typo in comment.

3 years ago[Ada] Restore hiding of predefined "=" operator through class-wide type
Eric Botcazou [Wed, 20 Apr 2022 22:03:59 +0000 (00:03 +0200)] 
[Ada] Restore hiding of predefined "=" operator through class-wide type

The previous change introduced a backward incompatibility in the handling
of a user-defined "=" operator for a class-wide type of a tagged type: it
would previously hide the predefined "=" operator of the tagged type in
the private case, but it no longer does in this case, while it still does
in the nonprivate case.

This hiding is a non-portability, but is fundamentally what the compiler
implements, instead of the RM rule which requires homographs.  The reason
lies in the implementation of the "=" operator in GNAT: internally, there
is not a "=" predefined operator for every nonlimited type, but instead
there is a single, universal "=" predefined operator for all the nonlimited
types.  The consequence is that the hiding rule implemented in GNAT for "="
is effectively that a user-declared symmetrical "=" operator returning
boolean hides the predefined "=" operator of any type that is covered by
the user-declared operator.

Whether it is desirable to implement the exact RM rule in GNAT is to be
discussed, but existing code relies on the non-portability and would thus
need to be changed.

gcc/ada/

* sem_ch6.adb (New_Overloaded_Entity): Deal specifically with the
overriding of the "=" operator for tagged types.

3 years ago[Ada] Do not freeze profiles for dispatch tables
Eric Botcazou [Wed, 20 Apr 2022 07:54:49 +0000 (09:54 +0200)] 
[Ada] Do not freeze profiles for dispatch tables

When static dispatch tables are built for library-level tagged types, the
primitives (the subprogram themselves) are frozen; that's necessary because
their address is taken.  However, their profile, i.e. all the types present
therein, is also frozen, which is not necessary after AI05-019 and is also
inconsistent with the handling of attribute references.

The change also removes a couple of pragma Inline on subprograms that are
too large for inlining to bring any benefit.

gcc/ada/

* exp_ch3.adb (Expand_N_Object_Declaration): Adjust call to Make_DT.
* exp_disp.ads (Building_Static_DT): Remove pragma Inline.
(Building_Static_Secondary_DT): Likewise.
(Convert_Tag_To_Interface): Likewise.
(Make_DT): Remove second parameter.
* exp_disp.adb (Make_DT): Likewise.
(Check_Premature_Freezing): Delete.
Pass Do_Freeze_Profile as False in call to Freeze_Entity.
* freeze.ads (Freezing_Library_Level_Tagged_Type): Delete.
* freeze.adb (Freeze_Profile): Remove obsolete code.
(Freeze_Entity): Tweak comment.

3 years ago[Ada] Adapt proof of runtime unit s-arit32
Yannick Moy [Wed, 20 Apr 2022 09:39:11 +0000 (09:39 +0000)] 
[Ada] Adapt proof of runtime unit s-arit32

After changes in GNATprove, adapt proof. Simply move an assertion up
before it is first needed here.

gcc/ada/

* libgnat/s-arit32.adb (Scaled_Divide32): Move assertion up.

3 years ago[Ada] PR ada/105303 Fix use of Assertion_Policy in internal generics unit
Yannick Moy [Tue, 19 Apr 2022 12:37:58 +0000 (14:37 +0200)] 
[Ada] PR ada/105303 Fix use of Assertion_Policy in internal generics unit

The internal unit System.Generic_Array_Operations defines only generic
subprograms. Thus, pragma Assertion_Policy inside the spec has no
effect, as each instantiation is only subject to the assertion policy at
the program point of the instantiation. Remove this confusing pragma,
and add the pragma inside each generic body making use of additional
assertions or ghost code, so that running time of instantiations is not
impacted by assertions meant for formal verification.

gcc/ada/

PR ada/105303
* libgnat/s-gearop.adb: Add pragma Assertion_Policy in generic
bodies making use of additional assertions or ghost code.
* libgnat/s-gearop.ads: Remove confusing Assertion_Policy.

3 years ago[Ada] Delete no-longer-used Convert_To_Return_False flag
Steve Baird [Fri, 15 Apr 2022 20:30:34 +0000 (13:30 -0700)] 
[Ada] Delete no-longer-used Convert_To_Return_False flag

As a result of other recent changes, the Convert_To_Return_False flag
is never set. The flag can be therefore be deleted.

gcc/ada/

* exp_ch11.adb (Expand_N_Raise_Expression): Remove
Convert_To_Return_False test.
* gen_il-fields.ads: Remove Convert_To_Return_False field.
* gen_il-gen-gen_nodes.adb: Remove use of
Convert_To_Return_False field.
* sinfo.ads: Remove comment describing Convert_To_Return_False
flag.

3 years ago[Ada] Add empty constructors to the functional containers
Julien Bortolussi [Thu, 14 Apr 2022 14:09:30 +0000 (16:09 +0200)] 
[Ada] Add empty constructors to the functional containers

This patch adds empty constructors to the functional containers so that
we can use them in expression functions.

gcc/ada/

* libgnat/a-cofuma.ads, libgnat/a-cofuma.adb,
libgnat/a-cofuse.ads, libgnat/a-cofuse.adb,
libgnat/a-cofuve.ads, libgnat/a-cofuve.adb: Add empty
constructors.

3 years ago[Ada] Fix new CUDA kernel registration scheme
Ghjuvan Lacambre [Tue, 19 Apr 2022 08:01:49 +0000 (10:01 +0200)] 
[Ada] Fix new CUDA kernel registration scheme

Removal of the previous kernel registration scheme unearthed mistakes in
the new one, which were:
- The new kernel registration code relied on the binder expansion phase,
  which didn't happen because the registration code was already
  generated by the binder.
- The kernel handle passed to CUDA_Register_Function was the first eight
  bytes of the code of the host-side procedure representing the kernel
  rather than its address.

gcc/ada/

* bindgen.adb (Gen_CUDA_Init): Remove code generating CUDA
definitions.
(Gen_CUDA_Defs): New function, generating definitions
initialized by Gen_CUDA_Init.
(Gen_Output_File_Ada): Call Gen_CUDA_Defs instead of
Gen_CUDA_Init.
(Gen_Adainit): Call Gen_CUDA_Init.

3 years ago[ARM] Fix prototype for vec_perm_const hook.
Prathamesh Kulkarni [Mon, 30 May 2022 07:53:50 +0000 (13:23 +0530)] 
[ARM] Fix prototype for vec_perm_const hook.

gcc/ChangeLog:

* config/arm/arm.cc (arm_vectorize_vec_perm_const): Adjust prototype.

3 years agoRISC-V/testsuite: constraint some of tests to hard_float
Vineet Gupta [Fri, 27 May 2022 02:36:36 +0000 (19:36 -0700)] 
RISC-V/testsuite: constraint some of tests to hard_float

Commit 9ddd44b58649d1d ("RISC-V: Provide `fmin'/`fmax' RTL pattern") added
tests which check for hard float instructions which obviously fails on
soft-float ABI builds.

And my recent commit b646d7d279ae ("RISC-V: Inhibit FP <--> int register
moves via tune param") is guilty of same crime.

So constraint with "dg-require-effective-target hard_float"

This reduces bunch of new RV failures.

|               ========= Summary of gcc testsuite =========
|                            | # of unexpected case / # of unique unexpected case
|                            |          gcc |          g++ |     gfortran |
|   rv64imac/   lp64/ medlow |  134 /    22 |    0 /     0 |            - |  BEFORE
|   rv64imac/   lp64/ medlow |   22 /     9 |    0 /     0 |            - |  AFTER
|

gcc/testsuite/Changelog:
* gcc.target/riscv/fmax.c: Add dg-require-effective-target hard_float.
* gcc.target/riscv/fmaxf.c: Ditto.
* gcc.target/riscv/fmin.c: Ditto.
* gcc.target/riscv/fminf.c: Ditto.
* gcc.target/riscv/smax-ieee.c: Ditto.
* gcc.target/riscv/smax.c: Ditto.
* gcc.target/riscv/smaxf-ieee.c: Ditto.
* gcc.target/riscv/smaxf.c: Ditto.
* gcc.target/riscv/smin-ieee.c: Ditto.
* gcc.target/riscv/smin.c: Ditto.
* gcc.target/riscv/sminf-ieee.c: Ditto.
* gcc.target/riscv/sminf.c: Ditto.
* gcc.target/riscv/pr105666.c: Ditto.

Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
3 years agoDaily bump.
GCC Administrator [Mon, 30 May 2022 00:16:21 +0000 (00:16 +0000)] 
Daily bump.

3 years agolibcpp: Ignore CPP_PADDING tokens in _cpp_parse_expr [PR105732]
Jakub Jelinek [Sun, 29 May 2022 19:57:51 +0000 (21:57 +0200)] 
libcpp: Ignore CPP_PADDING tokens in _cpp_parse_expr [PR105732]

The first part of the following testcase (m1-m3 macros and its use)
regressed with my PR89971 fix, but as the m1,m4-m5 and its use part shows,
the problem isn't new, we can emit a CPP_PADDING token to avoid it from
being adjacent to whatever comes after the __VA_OPT__ (in this case there
is nothing afterwards, true).

In most cases these CPP_PADDING tokens don't matter, all other
callers of cpp_get_token_with_location either ignore CPP_PADDING tokens
completely (e.g. c_lex_with_flags) or they just remember them and
take them into account when printing stuff whether there should be
added whitespace or not (scan_translation_unit + token_streamer::stream).
So, I think we should just ignore CPP_PADDING tokens the same way in
_cpp_parse_expr.

2022-05-27  Jakub Jelinek  <jakub@redhat.com>

PR preprocessor/105732
* expr.cc (_cpp_parse_expr): Handle CPP_PADDING by just another
token.

* c-c++-common/cpp/va-opt-10.c: New test.

3 years agoDarwin: Fix empty g++ command lines [PR105599].
Iain Sandoe [Sun, 29 May 2022 15:14:32 +0000 (16:14 +0100)] 
Darwin: Fix empty g++ command lines [PR105599].

An empty g++ command line should produce a diagnostic that there are no
inputs.  The PR is that currently Darwin produces a dignostic about missing
link items instead - this is because (errnoeously), for this driver, we are
creating a link job for empty command lines.

The problem occurs in four stages:

 The g++ driver appends -shared-libgcc to the command line.

 The Darwin driver_init code in the backend does not see this (it sees an
 empty command line).

 When the back end driver code driver sees an empty command line, it does not
 add any supplementary flags (e.g. asm-macosx-version-min) - precisely to
 avoid anything being claimed as an input_file and therefore triggering a link
 line.

 Since we do not have a value for asm-macosx-version-min when processing the
 driver specs, we unconditionally inject 'multiply_defined suppress' which is
 used with shared libgcc (but only intended on very old Darwin).  This then
 causes the generation of a link job.

The solution, for the present, is to move version-specific link params to the
LINK_SPEC so that they are only processed when a link job has already been
decided.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR target/105599

gcc/ChangeLog:

* config/darwin.h: Move versions-specific handling of multiply_defined
from SUBTARGET_DRIVER_SELF_SPECS to LINK_SPEC.

3 years agosourcebuild.texi: Document toplevel directories
Eric Gallager [Sun, 29 May 2022 04:57:05 +0000 (00:57 -0400)] 
sourcebuild.texi: Document toplevel directories

Fixes PR82383

gcc/ChangeLog:

PR other/82383
* doc/sourcebuild.texi: Add entries for the c++tools,
gotools, libbacktrace, libcc1, libcody, liboffloadmic,
and libsanitizer directories. Remove entry for boehm-gc.
Fix alphabetization for libquadmath.

3 years agoDaily bump.
GCC Administrator [Sun, 29 May 2022 00:16:31 +0000 (00:16 +0000)] 
Daily bump.

3 years ago[PATCH 1/2] avr: Added AVR-DA and DB MCU series
Joel Holdsworth [Sat, 28 May 2022 19:16:01 +0000 (13:16 -0600)] 
[PATCH 1/2] avr: Added AVR-DA and DB MCU series

gcc/
* config/avr/avr-mcus.def: Add device definitions.
* doc/avr-mmcu.texi: Corresponding changes.
* config/avr/gen-avr-mmcu-texi.cc: Added support for avr
device prefix.
* config/avr/gen-avr-mmcu-specs.cc: Prevent -mmcu=avr* flags
from leaking into cc1.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
3 years agoOpenMP/Fortran: Add support for enter clause on declare target
Tobias Burnus [Sat, 28 May 2022 18:42:38 +0000 (20:42 +0200)] 
OpenMP/Fortran: Add support for enter clause on declare target

Fortran version to C/C++ commit r13-797-g0ccba4ed8571c18c7015413441e971

gcc/fortran/ChangeLog:

* dump-parse-tree.cc (show_omp_clauses): Handle OMP_LIST_ENTER.
* gfortran.h: Add OMP_LIST_ENTER.
* openmp.cc (enum omp_mask2, OMP_DECLARE_TARGET_CLAUSES): Add
OMP_CLAUSE_ENTER.
(gfc_match_omp_clauses, gfc_match_omp_declare_target,
resolve_omp_clauses): Handle 'enter' clause.

libgomp/ChangeLog:

* libgomp.texi (OpenMP 5.2): Mark 'enter' clause as supported.
* testsuite/libgomp.fortran/declare-target-1.f90: Extend to test
explicit 'to' and 'enter' clause.
* testsuite/libgomp.fortran/declare-target-2.f90: Update accordingly.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/declare-target-2.f90: Add 'enter' clause test.
* gfortran.dg/gomp/declare-target-4.f90: Likewise.

3 years agoFix ICE on sh
Vladimir Makarov [Sat, 28 May 2022 18:08:38 +0000 (12:08 -0600)] 
Fix ICE on sh

gcc/
PR target/103722
* config/sh/sh.cc (sh_register_move_cost): Avoid cost "2" (which
is special) for various scenarios.

3 years agoVim swap files not ignored
Bruce Korb [Sat, 28 May 2022 15:36:10 +0000 (09:36 -0600)] 
Vim swap files not ignored

ChangeLog:

* .gitignore: Ignore vim swap files

3 years agolibbacktrace: update README
Ian Lance Taylor [Sat, 28 May 2022 14:57:32 +0000 (07:57 -0700)] 
libbacktrace: update README

PR libbacktrace/105721
* README: Update.

3 years agoDarwin: Amend REAL_LIBGCC_SPEC comment [NFC].
Iain Sandoe [Sat, 28 May 2022 10:55:00 +0000 (11:55 +0100)] 
Darwin: Amend REAL_LIBGCC_SPEC comment [NFC].

This comment had got out of sync with reality, partly due to merging
of patches.  Updated to reflect the current implementation.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/ChangeLog:

* config/darwin.h (REAL_LIBGCC_SPEC): Update the comment block
describing this macro.

3 years agoRename OSCONS_CC to GCC_FOR_ADA_RTS
Alexandre Oliva [Sat, 28 May 2022 06:50:17 +0000 (03:50 -0300)] 
Rename OSCONS_CC to GCC_FOR_ADA_RTS

Several gnatlib* targets perform, with a subshell and sed, the same
GCC_FOR_TARGET pathname transformation that OSCONS_CC performs with
make subst macros.  Rename OSCONS_CC to a more general name, and use
it for gnatlib as well.

for  gcc/ada/ChangeLog

* gcc-interface/Makefile.in (OSCONS_CC): Rename to...
(GCC_FOR_ADA_RTS): ... this.  Adjust users.
(gnatlib): Pass it down as CC.
(gnatlib-shared-default): Likewise.
(gnatlib-shared-win32, gnatlib-shared-darwin): Likewise.

3 years agolibgomp: Don't define GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC for _aligned_malloc [PR105745]
Jakub Jelinek [Sat, 28 May 2022 06:30:47 +0000 (08:30 +0200)] 
libgomp: Don't define GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC for _aligned_malloc [PR105745]

since apparently _aligned_malloc requires freeing with _aligned_free and:
 /* Defined if gomp_aligned_alloc doesn't use fallback version
    and free can be used instead of gomp_aligned_free.  */
 #define GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC 1
so the second condition isn't satisfied.  For uses inside of the OpenMP
allocators we can still use _aligned_malloc but we need to call _aligned_free
in gomp_aligned_free.

2022-05-28  Jakub Jelinek  <jakub@redhat.com>

PR libgomp/105745
* libgomp.h (GOMP_HAVE_EFFICIENT_ALIGNED_ALLOC): Don't define for
defined(HAVE__ALIGNED_MALLOC) case.
* alloc.c (gomp_aligned_alloc): Move defined(HAVE__ALIGNED_MALLOC)
handling as last option before fallback instead of first.
(gomp_aligned_free): For defined(HAVE__ALIGNED_MALLOC) call
_aligned_free.

3 years agoopenmp: Adjust diagnostics about same variable in link and to/enter clauses
Jakub Jelinek [Sat, 28 May 2022 06:26:57 +0000 (08:26 +0200)] 
openmp: Adjust diagnostics about same variable in link and to/enter clauses

On Fri, May 27, 2022 at 04:52:17PM +0200, Tobias Burnus wrote:
> The 'TO'/'ENTER' usage is first stored in a linked list – and
> then as attribute to the symbol. I am not sure how to handle it best.

This reminds me I've left the C/C++ FE diagnostics about mixing link and
to/enter on the same variable in separate directives as is, so it always
talked about mixing link and to clauses.

This patch adjusts it, so that if link is first, it talks about the
clause actually used and if link is later, uses to or enter together
in the wording.

2022-05-28  Jakub Jelinek  <jakub@redhat.com>

gcc/c/
* c-parser.cc (c_parser_omp_declare_target): If OMP_CLAUSE_LINK was
seen first, use "%<to%>" or "%<enter%>" depending on
OMP_CLAUSE_ENTER_TO of the current clause, otherwise use
"%<to%> or %<enter%>" wording.
gcc/cp/
* parser.cc (handle_omp_declare_target_clause): If OMP_CLAUSE_LINK was
seen first, use "%<to%>" or "%<enter%>" depending on
OMP_CLAUSE_ENTER_TO of the current clause, otherwise use
"%<to%> or %<enter%>" wording.
gcc/testsuite/
* c-c++-common/gomp/declare-target-2.c: Add further tests for mixing of
link and to/enter clauses on separate directives.

3 years agoc++: lambda in concept [PR105652]
Jason Merrill [Fri, 27 May 2022 02:43:05 +0000 (22:43 -0400)] 
c++: lambda in concept [PR105652]

We currently check satisfaction in the context of the constrained
declaration (which may be wrong, see PR104111).  When checking C<int>
for S<int>, we currently substitute into the lambda in the context of
S<T> (rather than S<int>, which seems wrong if the above isn't wrong), so
the new closure type thinks its context is S<T>, which confuses debug
output.  For the moment, let's work around all of this by overriding the
context of the closure.

PR c++/105652

gcc/cp/ChangeLog:

* pt.cc (tsubst_lambda_expr): Don't let a namespace-scope lambda
instantiate into a class-scope lambda.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-lambda20.C: New test.

3 years agoDaily bump.
GCC Administrator [Sat, 28 May 2022 00:16:40 +0000 (00:16 +0000)] 
Daily bump.

3 years agod: Merge upstream dmd 4d07f22f2, druntime f89da313, phobos d46814c86.
Iain Buclaw [Fri, 27 May 2022 17:36:06 +0000 (19:36 +0200)] 
d: Merge upstream dmd 4d07f22f2, druntime f89da313, phobos d46814c86.

D front-end changes:

    - `scope' semantics are now enforced in `@safe' code on pointers to
      stack memory, but only as deprecation warnings.
    - Overriding virtual functions are now marked with the `override'
      and `final' in the generated headers of `-fdump-c++-spec='.
    - `-fpreview=fiximmmutableconv` has been added that disallows
      implicitly converting a return value with indirections to
      immutable if it determines the result must be unique.

D runtime changes:

    - Posix (excluding Darwin): Switch default GC signals from SIGUSR1/2
      to SIGRTMIN/SIGRTMIN+1

Phobos changes:

    - Import latest bug fixes to mainline.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 4d07f22f2
* d-lang.cc (d_handle_option): Handle OPT_fpreview_fiximmutableconv.
* lang.opt (fpreview=fiximmutableconv): New option.
* runtime.def (ARRAYAPPENDT): Remove.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime f89da313.
* src/MERGE: Merge upstream phobos d46814c86.

Signed-off-by: Iain Buclaw <ibuclaw@gdcproject.org>
3 years agoc++: Fix ICE with -Wmismatched-tags [PR105725]
Marek Polacek [Fri, 27 May 2022 14:51:30 +0000 (10:51 -0400)] 
c++: Fix ICE with -Wmismatched-tags [PR105725]

Here we ICE with -Wmismatched-tags on something like

  template <class T>
  bool B<T, enable_if_t<is_class_v<class T::foo>>>;

Specifically, the "class T::foo" bit.  There, class_decl_loc_t::add gets
a TYPENAME_TYPE as TYPE, rather than a class/union type, so checking
TYPE_BEING_DEFINED will crash.  I think it's OK to allow a TYPENAME_TYPE to
slip into that function; we just shouldn't consider the 'class' tag redundant
(which works as a 'typename').  In fact, every other compiler *requires* it.

PR c++/105725

gcc/cp/ChangeLog:

* parser.cc (class_decl_loc_t::add): Check CLASS_TYPE_P.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wmismatched-tags-10.C: New test.

3 years agoc-family: fix attribute constructor ICE [PR90658]
Marek Polacek [Thu, 26 May 2022 22:59:44 +0000 (18:59 -0400)] 
c-family: fix attribute constructor ICE [PR90658]

Here the C compiler crashes because a FUNCTION_DECL got into
get_priority -> default_conversion, and the C FE's version of d_c
specifically asserts that it doesn't get a FUNCTION_DECL.  All uses
of default_conversion in c-attribs.cc are guarded by != IDENTIFIER_NODE
&& != FUNCTION_DECL, but get_priority was only checking IDENTIFIER_NODE.

PR c/90658

gcc/c-family/ChangeLog:

* c-attribs.cc (get_priority): Check FUNCTION_DECL.

gcc/testsuite/ChangeLog:

* c-c++-common/attr-cdtor-1.c: New test.

3 years agolibstdc++: Mark non-exported function always_inline [PR105671]
Jonathan Wakely [Fri, 27 May 2022 11:43:18 +0000 (12:43 +0100)] 
libstdc++: Mark non-exported function always_inline [PR105671]

This new function was added for gcc 11.1 but is not exported from the
shared library. Depending on inlining decisions, its callers might get
inlined but an external definition be needed for this function. That
then fails to link.

Since we can't add the export to the gcc-11 release branch now, mark it
always_inline. We can consider exporting it for gcc-13 if/when we bump
the shared library version (and maybe also for gcc-12 which is currently
at the same version as trunk). For now, the attribute will solve the
problem on all affected branches. The function is small enough that
force-inlining it shouldn't cause problems.

libstdc++-v3/ChangeLog:

PR libstdc++/105671
* include/std/sstream (basic_stringbuf::_M_high_mark): Add
always_inline attribute.

3 years agoFortran: Fix OpenMP clause name in error message
Tobias Burnus [Fri, 27 May 2022 11:12:45 +0000 (13:12 +0200)] 
Fortran: Fix OpenMP clause name in error message

gcc/fortran/ChangeLog:

* openmp.cc (gfc_check_omp_requires): Fix clause name in error.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/requires-4.f90: Update dg-error.
* gfortran.dg/gomp/requires-8.f90: Update dg-error.

Co-authored-by: Chung-Lin Tang <cltang@codesourcery.com>
3 years agoAvoid shift in get_ref_base_and_extent
Richard Biener [Fri, 27 May 2022 12:07:03 +0000 (14:07 +0200)] 
Avoid shift in get_ref_base_and_extent

This avoids one instance of a shift from bytes to bits in
get_ref_base_and_extent by using TYPE_SIZE instead of TYPE_SIZE_UNIT.

* tree-dfa.cc (get_ref_base_and_extent): Avoid shift.

3 years agoipa: Check cst type when propagating controled uses info
Martin Jambor [Fri, 27 May 2022 11:05:40 +0000 (13:05 +0200)] 
ipa: Check cst type when propagating controled uses info

PR 105639 shows that code with type-mismatches can trigger an assert
after runnning into a branch that was inteded only for references to
variables - as opposed to references to functions.  Fixed by moving
the condition from the assert to the guarding if statement.

gcc/ChangeLog:

2022-05-25  Martin Jambor  <mjambor@suse.cz>

PR ipa/105639
* ipa-prop.cc (propagate_controlled_uses): Check type of the
constant before adding a LOAD reference.

gcc/testsuite/ChangeLog:

2022-05-25  Martin Jambor  <mjambor@suse.cz>

PR ipa/105639
* gcc.dg/ipa/pr105639.c: New test.

3 years agoopenmp: Add support for enter clause on declare target
Jakub Jelinek [Fri, 27 May 2022 10:48:48 +0000 (12:48 +0200)] 
openmp: Add support for enter clause on declare target

OpenMP 5.1 and earlier had 2 different uses of to clause, one for target
update construct with one semantics, and one for declare target directive
with a different semantics.
Under the hood we were using OMP_CLAUSE_TO_DECLARE to represent the latter.
OpenMP 5.2 renamed the declare target clause to to enter, the old one is
kept as a deprecated alias.

As we are far from having full OpenMP 5.2 support, this patch adds support
for the enter clause (and renames OMP_CLAUSE_TO_DECLARE to OMP_CLAUSE_ENTER
with a flag to tell the spelling of the clause for better diagnostics),
but doesn't deprecate the to clause on declare target just yet (that
should be done as one of the last steps in 5.2 support).

2022-05-27  Jakub Jelinek  <jakub@redhat.com>

gcc/
* tree-core.h (enum omp_clause_code): Rename OMP_CLAUSE_TO_DECLARE
to OMP_CLAUSE_ENTER.
* tree.h (OMP_CLAUSE_ENTER_TO): Define.
* tree.cc (omp_clause_num_ops, omp_clause_code_name): Rename
OMP_CLAUSE_TO_DECLARE to OMP_CLAUSE_ENTER.
* tree-pretty-print.cc (dump_omp_clause): Handle OMP_CLAUSE_ENTER
instead of OMP_CLAUSE_TO_DECLARE, if OMP_CLAUSE_ENTER_TO, print
"to" instead of "enter".
* tree-nested.cc (convert_nonlocal_omp_clauses,
convert_local_omp_clauses): Handle OMP_CLAUSE_ENTER instead of
OMP_CLAUSE_TO_DECLARE.
gcc/c-family/
* c-pragma.h (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_ENTER.
gcc/c/
* c-parser.cc (c_parser_omp_clause_name): Parse enter clause.
(c_parser_omp_all_clauses): For to clause on declare target, use
OMP_CLAUSE_ENTER clause with OMP_CLAUSE_ENTER_TO instead of
OMP_CLAUSE_TO_DECLARE clause.  Handle PRAGMA_OMP_CLAUSE_ENTER.
(OMP_DECLARE_TARGET_CLAUSE_MASK): Add enter clause.
(c_parser_omp_declare_target): Use OMP_CLAUSE_ENTER instead of
OMP_CLAUSE_TO_DECLARE.
* c-typeck.cc (c_finish_omp_clauses): Handle OMP_CLAUSE_ENTER instead
of OMP_CLAUSE_TO_DECLARE, to OMP_CLAUSE_ENTER_TO use "to" as clause
name in diagnostics instead of
omp_clause_code_name[OMP_CLAUSE_CODE (c)].
gcc/cp/
* parser.cc (cp_parser_omp_clause_name): Parse enter clause.
(cp_parser_omp_all_clauses): For to clause on declare target, use
OMP_CLAUSE_ENTER clause with OMP_CLAUSE_ENTER_TO instead of
OMP_CLAUSE_TO_DECLARE clause.  Handle PRAGMA_OMP_CLAUSE_ENTER.
(OMP_DECLARE_TARGET_CLAUSE_MASK): Add enter clause.
(cp_parser_omp_declare_target): Use OMP_CLAUSE_ENTER instead of
OMP_CLAUSE_TO_DECLARE.
* semantics.cc (finish_omp_clauses): Handle OMP_CLAUSE_ENTER instead
of OMP_CLAUSE_TO_DECLARE, to OMP_CLAUSE_ENTER_TO use "to" as clause
name in diagnostics instead of
omp_clause_code_name[OMP_CLAUSE_CODE (c)].
gcc/testsuite/
* c-c++-common/gomp/clauses-3.c: Add tests with enter clause instead
of to or modify some existing to clauses to enter.
* c-c++-common/gomp/declare-target-1.c: Likewise.
* c-c++-common/gomp/declare-target-2.c: Likewise.
* c-c++-common/gomp/declare-target-3.c: Likewise.
* g++.dg/gomp/attrs-9.C: Likewise.
* g++.dg/gomp/declare-target-1.C: Likewise.
libgomp/
* testsuite/libgomp.c-c++-common/target-40.c: Modify some existing to
clauses to enter.
* testsuite/libgomp.c/target-41.c: Likewise.

3 years agotree-optimization/105726 - adjust array bound heuristic
Richard Biener [Wed, 25 May 2022 09:49:03 +0000 (11:49 +0200)] 
tree-optimization/105726 - adjust array bound heuristic

There's heuristic to detect ptr[1].a[...] out of bound accesses
reasoning that if ptr points to an array of aggregates a trailing
incomplete array has to have size zero.  The following more
thoroughly constrains the cases this applies to avoid false
positive diagnostics.

2022-05-25  Richard Biener  <rguenther@suse.de>

PR tree-optimization/105726
* gimple-ssa-warn-restrict.cc (builtin_memref::set_base_and_offset):
Constrain array-of-flexarray case more.

* g++.dg/warn/Warray-bounds-27.C: New testcase.

3 years agofold-const: Fix up -fsanitize=null in C++ [PR105729]
Jakub Jelinek [Fri, 27 May 2022 09:40:42 +0000 (11:40 +0200)] 
fold-const: Fix up -fsanitize=null in C++ [PR105729]

The following testcase triggers a false positive UBSan binding a reference
to null diagnostics.
In the FE we instrument conversions from pointer to reference type
to diagnose at runtime if the operand of such a conversion is 0.
The problem is that a GENERIC folding folds
((const struct Bar *) ((const struct Foo *) this)->data) + (sizetype) range_check (x)
conversion to const struct Bar & by converting to that the first
operand of the POINTER_PLUS_EXPR.  But that changes when the -fsanitize=null
binding to reference runtime check occurs.  Without the optimization,
it is invoked on the result of the POINTER_PLUS_EXPR, and as range_check
call throws, that means it never triggers in the testcase.
With the optimization, it checks whether this->data is NULL and it is.

The following patch avoids that optimization during GENERIC folding when
-fsanitize=null is enabled and it is a cast from non-REFERENCE_TYPE to
REFERENCE_TYPE.

2022-05-27  Jakub Jelinek  <jakub@redhat.com>

PR sanitizer/105729
* fold-const.cc (fold_unary_loc): Don't optimize (X &) ((Y *) z + w)
to (X &) z + w if -fsanitize=null during GENERIC folding.

* g++.dg/ubsan/pr105729.C: New test.

3 years agolibgomp.texi: Add more to-be-implemented OpenMP 5.2 features
Tobias Burnus [Fri, 27 May 2022 08:09:10 +0000 (10:09 +0200)] 
libgomp.texi: Add more to-be-implemented OpenMP 5.2 features

libgomp/
* libgomp.texi (Other new OpenMP 5.1 features): Add
'begin declare target'.
(Other new OpenMP 5.2 features): New.

3 years agoCanonicalize X&-Y as X*Y in match.pd when Y is [0,1].
Roger Sayle [Fri, 27 May 2022 07:57:46 +0000 (08:57 +0100)] 
Canonicalize X&-Y as X*Y in match.pd when Y is [0,1].

"For every pessimization, there's an equal and opposite optimization".

In the review of my original patch for PR middle-end/98865, Richard
Biener pointed out that match.pd shouldn't be transforming X*Y into
X&-Y as the former is considered cheaper by tree-ssa's cost model
(operator count).  A corollary of this is that we should instead be
transforming X&-Y into the cheaper X*Y as a preferred canonical form
(especially as RTL expansion now intelligently selects the appropriate
implementation based on the target's costs).

With this patch we now generate identical code for:
int foo(int x, int y) { return -(x&1) & y; }
int bar(int x, int y) { return (x&1) * y; }

specifically on x86_64-pc-linux-gnu both use and/neg/and with -O2,
but both use and/mul with -Os.

One minor wrinkle/improvement is that this patch includes three
additional optimizations (that account for the change in canonical
form) to continue to optimize PR92834 and PR94786.

2022-05-27  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* match.pd (match_zero_one_valued_p): New predicate.
(mult @0 @1): Use zero_one_valued_p for optimization to the
expression "bit_and @0 @1".
(bit_and (negate zero_one_valued_p@0) @1): Optimize to MULT_EXPR.
(plus @0 (mult (minus @1 @0) zero_one_valued_p@2)): New transform.
(minus @0 (mult (minus @0 @1) zero_one_valued_p@2)): Likewise.
(bit_xor @0 (mult (bit_xor @0 @1) zero_one_valued_p@2)): Likewise.
Remove three redundant transforms obsoleted by the three above.

gcc/testsuite/ChangeLog
* gcc.dg/pr98865.c: New test case.

3 years agoPre-reload splitter to transform and;cmp into not;test on x86.
Roger Sayle [Fri, 27 May 2022 07:52:03 +0000 (08:52 +0100)] 
Pre-reload splitter to transform and;cmp into not;test on x86.

A common idiom for testing if a specific set of bits is set in a value
is to use "(X & Y) == Y", which on x86 results in an AND followed by a
CMP.  A slightly improved implementation is to instead use (~X & Y)==0,
that uses a NOT and a TEST (or ANDN where available); still two "fast"
instructions, but typically shorter especially if Y is an immediate
constant.  Because the above transformation would require more gimple
statements in SSA, and may only be a win on targets with flags registers,
it isn't performed by the middle-end, instead leaving this choice to
the backend.

As an example, here's the change in code generation for pr91400-1.c
[which now requires a tweak to its dg-final clauses].

Before:
        movl    __cpu_model+12(%rip), %eax
        andl    $68, %eax // 3 bytes
        cmpl    $68, %eax // 3 bytes
        sete    %al
        ret

After:
        movl    __cpu_model+12(%rip), %eax
        notl    %eax // 2 bytes
        testb   $68, %al // 2 bytes
        sete    %al
        ret

2022-05-27  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* config/i386/i386.md (*test<mode>_not): New define_insn_and_split
to split a combined "and;cmp" sequence into "not;test".

gcc/testsuite/ChangeLog
* gcc.target/i386/pr91400-1.c: Update for improved code generation.
* gcc.target/i386/pr91400-2.c: Likewise.
* gcc.target/i386/testnot-1.c: New test case.
* gcc.target/i386/testnot-2.c: Likewise.

3 years agoClose gcc-9 branch
Richard Biener [Fri, 27 May 2022 07:04:32 +0000 (09:04 +0200)] 
Close gcc-9 branch

This removes gcc-9 from getting DATESTAMP updates.

gcc/contrib/
* gcc-changelog/git_update_version.py (active_refs): Remove
releases/gcc-9.

3 years agoxtensa: Improve bswap[sd]i2 insn patterns
Takayuki 'January June' Suwa [Fri, 13 May 2022 13:33:59 +0000 (22:33 +0900)] 
xtensa: Improve bswap[sd]i2 insn patterns

This patch makes bswap[sd]i2 better register allocation, and reconstructs
bswapsi2 in order to take advantage of GIMPLE manual byte-swapping
recognition.

gcc/ChangeLog:

* config/xtensa/xtensa.md (bswapsi2): New expansion pattern.
(bswapsi2_internal): Revise the template and condition, and add
detection code for preceding the same insn in order to omit a
"SSAI 8" instruction of the latter.
(bswapdi2): Suppress built-in insn expansion with the corresponding
library call when optimizing for size.

gcc/testsuite/ChangeLog:

* gcc.target/xtensa/bswap.c: Remove test.
* gcc.target/xtensa/bswap-O1.c: New.
* gcc.target/xtensa/bswap-O2.c: Ditto.
* gcc.target/xtensa/bswap-Os.c: Ditto.

3 years agoxtensa: Add setmemsi insn pattern
Takayuki 'January June' Suwa [Mon, 23 May 2022 15:52:44 +0000 (00:52 +0900)] 
xtensa: Add setmemsi insn pattern

This patch introduces setmemsi insn pattern of two kinds, unrolled loop and
small loop, for fixed small length and constant initialization value.

gcc/ChangeLog:

* config/xtensa/xtensa-protos.h
(xtensa_expand_block_set_unrolled_loop,
xtensa_expand_block_set_small_loop): New prototypes.
* config/xtensa/xtensa.cc (xtensa_sizeof_MOVI,
xtensa_expand_block_set_unrolled_loop,
xtensa_expand_block_set_small_loop): New functions.
* config/xtensa/xtensa.md (setmemsi): New expansion pattern.
* config/xtensa/xtensa.opt (mlongcalls): Add target mask.

3 years agoDaily bump.
GCC Administrator [Fri, 27 May 2022 00:16:19 +0000 (00:16 +0000)] 
Daily bump.

3 years agolibstdc++: Fix narrowing conversions for 16-bit size_t [PR105681]
Jonathan Wakely [Thu, 26 May 2022 20:32:55 +0000 (21:32 +0100)] 
libstdc++: Fix narrowing conversions for 16-bit size_t [PR105681]

On a 16-bit target such as msp430 we get errors about narrowing long
values to size_t, which is only 16-bit. When --enable-libstdcxx-pch is
used the <bits/extc++.h> header breaks the build because of these
narrowing errors.

libstdc++-v3/ChangeLog:

PR libstdc++/105681
* include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp:
Limit ga_sizes array to values that fit in size_t.
* include/ext/random [__SIZE_WIDTH < 32] (sfmt86243)
(sfmt86243_64, sfmt132049, sfmt132049_64, sfmt216091)
(sfmt216091_64): Do not declare.

3 years agolibstdc++: Fix atomic and error_code printers for versioned namespace
Jonathan Wakely [Thu, 26 May 2022 14:44:08 +0000 (15:44 +0100)] 
libstdc++: Fix atomic and error_code printers for versioned namespace

This fixes the printers to work with std::__8::atomic and
std::__v8::ios_errc and std::__v8::future_errc.

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py (StdErrorCodePrinter): Make
lookup for ios_errc and future_errc check versioned namespace.
(StdAtomicPrinter): Strip versioned namespace from typename.

3 years agolibstdc++: Move std::iostream_category() definition to new file
Jonathan Wakely [Thu, 26 May 2022 14:42:50 +0000 (15:42 +0100)] 
libstdc++: Move std::iostream_category() definition to new file

This fixes a missing symbol when the dual ABI is disabled, e.g. for the
versioned namespace build.

libstdc++-v3/ChangeLog:

* src/c++11/Makefile.am: Add new source file.
* src/c++11/Makefile.in: Regenerate.
* src/c++11/cxx11-ios_failure.cc (iostream_category):
Move to ...
* src/c++11/ios_errcat.cc: New file.
* testsuite/27_io/ios_base/failure/error_code.cc: Check that
std::iostream_category() is defined and used for std::io_errc.

3 years agoc++: improve -Waddress warnings with *_cast [PR105569]
Marek Polacek [Wed, 11 May 2022 18:38:49 +0000 (14:38 -0400)] 
c++: improve -Waddress warnings with *_cast [PR105569]

This patch improves the diagnostic for -Waddress when it warns for

  if (dynamic_cast<A*>(&ref))
    // ...

where 'ref' is a reference, which cannot be null.  In particular, it
changes
warning: comparing the result of pointer addition '(((A*)ref) + ((sizetype)(*(long int*)((& ref)->B::_vptr.B + -24))))' and NULL
to
warning: the compiler can assume that the address of 'ref' will never be NULL

PR c++/105569

gcc/cp/ChangeLog:

* typeck.cc (warn_for_null_address): Improve the warning when
the POINTER_PLUS_EXPR's base is of reference type.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Waddress-9.C: New test.

3 years agoxtensa: Fix instruction counting regarding block move expansion
Takayuki 'January June' Suwa [Fri, 13 May 2022 13:29:22 +0000 (22:29 +0900)] 
xtensa: Fix instruction counting regarding block move expansion

This patch makes counting the number of instructions of the remainder
(modulo 4) part more accurate.

gcc/ChangeLog:

* config/xtensa/xtensa.cc (xtensa_expand_block_move):
Make instruction counting more accurate, and simplify emitting insns.

3 years agoxtensa: Make use of IN_RANGE macro where appropriate
Takayuki 'January June' Suwa [Fri, 13 May 2022 13:27:36 +0000 (22:27 +0900)] 
xtensa: Make use of IN_RANGE macro where appropriate

No functional changes.

gcc/ChangeLog:

* config/xtensa/constraints.md (M, O): Use the macro.
* config/xtensa/predicates.md (addsubx_operand, extui_fldsz_operand,
sext_fldsz_operand): Ditto.
* config/xtensa/xtensa.cc (xtensa_simm8, xtensa_simm8x256,
xtensa_simm12b, xtensa_uimm8, xtensa_uimm8x2, xtensa_uimm8x4,
xtensa_mask_immediate, smalloffset_mem_p, printx, xtensa_call_save_reg,
xtensa_expand_prologue): Ditto.
* config/xtensa/xtensa.h (FUNCTION_ARG_REGNO_P): Ditto.

3 years agoxtensa: Simplify EXTUI instruction maskimm validations
Takayuki 'January June' Suwa [Fri, 13 May 2022 13:26:30 +0000 (22:26 +0900)] 
xtensa: Simplify EXTUI instruction maskimm validations

No functional changes.

gcc/ChangeLog:

* config/xtensa/predicates.md (extui_fldsz_operand): Simplify.
* config/xtensa/xtensa.cc (xtensa_mask_immediate, print_operand):
Ditto.

3 years agolibstdc++: Add constexpr to std::counted_iterator post-increment (LWG 3643)
Jonathan Wakely [Thu, 26 May 2022 11:41:03 +0000 (12:41 +0100)] 
libstdc++: Add constexpr to std::counted_iterator post-increment (LWG 3643)

libstdc++-v3/ChangeLog:

* include/bits/stl_iterator.h (counted_iterator::operator++(int)):
Add 'constexpr' as per LWG 3643.
* testsuite/24_iterators/counted_iterator/lwg3643.cc: New test.

3 years agoc++: constrained partial spec forward decl [PR96363]
Patrick Palka [Thu, 26 May 2022 13:43:14 +0000 (09:43 -0400)] 
c++: constrained partial spec forward decl [PR96363]

Here during cp_parser_single_declaration for #2, we were calling
associate_classtype_constraints for TPL<T> (the primary template type)
before maybe_process_partial_specialization could get a chance to
notice that we're in fact declaring a distinct constrained partial
spec and not redeclaring the primary template.  This caused us to
emit a bogus error about differing constraints b/t the primary template
and #2's constraints.  This patch fixes this by moving the call to
associate_classtype_constraints after the call to shadow_tag (which
calls maybe_process_partial_specialization) and adjusting shadow_tag to
use the return value of m_p_p_s.

Moreover, if we later try to define a constrained partial specialization
that's been declared earlier (as in the third testcase), then
maybe_new_partial_specialization correctly notices it's a redeclaration
and returns NULL_TREE.  But in this case we also need to update TYPE to
point to the redeclared partial spec (it'll otherwise continue pointing
to the primary template type, eventually leading to a bogus error).

PR c++/96363

gcc/cp/ChangeLog:

* decl.cc (shadow_tag): Use the return value of
maybe_process_partial_specialization.
* parser.cc (cp_parser_single_declaration): Call shadow_tag
before associate_classtype_constraints.
* pt.cc (maybe_new_partial_specialization): Change return type
to bool.  Take 'type' argument by mutable reference.  Set 'type'
to point to the correct constrained specialization when
appropriate.
(maybe_process_partial_specialization): Adjust accordingly.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-partial-spec12.C: New test.
* g++.dg/cpp2a/concepts-partial-spec12a.C: New test.
* g++.dg/cpp2a/concepts-partial-spec13.C: New test.

3 years agolibstdc++: Refactor includes for unordered containers
Jonathan Wakely [Tue, 24 May 2022 11:17:01 +0000 (12:17 +0100)] 
libstdc++: Refactor includes for unordered containers

This moves some #include directives to the relevant place. For example,
<bits/hashtable_policy.h> needs <bits/stl_pair.h> so should include it
directly instead of relying on <unordered_map> and <unordered_set> to do
so first.

libstdc++-v3/ChangeLog:

* include/bits/functional_hash.h (__is_fast_hash): Add doxygen
comment.
* include/bits/hashtable.h: Do not include <bits/stl_function.h>
here.
* include/bits/hashtable_policy.h: Include <bits/stl_pair.h> and
<bits/functional_hash.h>.
* include/bits/unordered_map.h: Include required headers.
* include/bits/unordered_set.h: Likewise.
* include/std/unordered_map: Do not include headers for indirect
dependencies.
* include/std/unordered_set: Likewise.

3 years agolibstdc++: Remove some unnecessary includes
Jonathan Wakely [Tue, 24 May 2022 11:15:00 +0000 (12:15 +0100)] 
libstdc++: Remove some unnecessary includes

These headers do not use anything in <bits/stl_iterator_base_types.h>
directly, and it's included by <bits/stl_iterator_base_funcs.h> and
<bits/stl_iterator.h> anyway, because they do need it.

libstdc++-v3/ChangeLog:

* include/bits/ranges_algobase.h: Do not include
<bits/stl_iterator_base_types.h>.
* include/std/string: Likewise.
* include/std/variant: Likewise.

3 years agolibstdc++: Make headers include their prerequisites
Nathan Sidwell [Tue, 24 May 2022 09:17:18 +0000 (10:17 +0100)] 
libstdc++: Make headers include their prerequisites

These headers were relying on their includers having already included
some prerequisites.  That makes them unsuitable to be header-units.

So directly include the needed headers.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/bits/hashtable.h: Include required headers.
* include/bits/hashtable_policy.h: Likewise.
* include/bits/stl_heap.h: Likewise.
* include/bits/stl_iterator_base_funcs.h: Likewise.

3 years agolibstdc++: Fix printing of std::span for versioned namespace
François Dumont [Wed, 25 May 2022 20:05:48 +0000 (22:05 +0200)] 
libstdc++: Fix printing of std::span for versioned namespace

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py (StdSpanPrinter.__init__):
Strip typename from version namespace.

3 years agolibstdc++: Fix printing of std::atomic<shared_ptr<T>> for versioned namespace
Jonathan Wakely [Thu, 26 May 2022 08:49:40 +0000 (09:49 +0100)] 
libstdc++: Fix printing of std::atomic<shared_ptr<T>> for versioned namespace

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py (SharedPointerPrinter): Strip
versioned namespace from the template argument too.

3 years agolibstdc++: Rename tests like .../wchar_t/1.cc to .../wchar_t.cc
Jonathan Wakely [Fri, 20 May 2022 09:41:53 +0000 (10:41 +0100)] 
libstdc++: Rename tests like .../wchar_t/1.cc to .../wchar_t.cc

There's no need to have directories containing a single test file, we
can rename the files to the directory names and remove the directories.

The dejagnu proc that filters out wchar_t tests just checks for
"wchar_t" anywhere in the path, so will work just as well on wchar_t.cc
or constexpr-wchar_t.cc paths.

libstdc++-v3/ChangeLog:

* testsuite/21_strings/basic_string/modifiers/pop_back/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string/modifiers/pop_back/char.cc:
...here.
* testsuite/21_strings/basic_string/modifiers/pop_back/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/modifiers/pop_back/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string/modifiers/swap/wchar_t/constexpr.cc:
Moved to...
* testsuite/21_strings/basic_string/modifiers/swap/constexpr-wchar_t.cc:
...here.
* testsuite/21_strings/basic_string/modifiers/swap/char/constexpr.cc:
Moved to...
* testsuite/21_strings/basic_string/modifiers/swap/constexpr.cc:
...here.
* testsuite/21_strings/basic_string/operations/contains/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string/operations/contains/char.cc:
...here.
* testsuite/21_strings/basic_string/operations/contains/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/operations/contains/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string/operations/data/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string/operations/data/char.cc:
...here.
* testsuite/21_strings/basic_string/operations/data/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/operations/data/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string/operations/ends_with/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string/operations/ends_with/char.cc:
...here.
* testsuite/21_strings/basic_string/operations/ends_with/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/operations/ends_with/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string/operations/starts_with/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string/operations/starts_with/char.cc:
...here.
* testsuite/21_strings/basic_string/operations/starts_with/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/operations/starts_with/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string/operations/substr/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string/operations/substr/char.cc:
...here.
* testsuite/21_strings/basic_string/operations/substr/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/operations/substr/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string/range_access/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string/range_access/char.cc:
...here.
* testsuite/21_strings/basic_string/range_access/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/range_access/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/char.cc:
...here.
* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/char.cc:
...here.
* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string_view/modifiers/swap/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/modifiers/swap/char.cc:
...here.
* testsuite/21_strings/basic_string_view/modifiers/swap/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/modifiers/swap/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string_view/operations/contains/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/operations/contains/char.cc:
...here.
* testsuite/21_strings/basic_string_view/operations/contains/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/operations/contains/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string_view/operations/data/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/operations/data/char.cc:
...here.
* testsuite/21_strings/basic_string_view/operations/data/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/operations/data/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string_view/operations/ends_with/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/operations/ends_with/char.cc:
...here.
* testsuite/21_strings/basic_string_view/operations/ends_with/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/operations/ends_with/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string_view/operations/starts_with/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/operations/starts_with/char.cc:
...here.
* testsuite/21_strings/basic_string_view/operations/starts_with/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/operations/starts_with/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string_view/operations/substr/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/operations/substr/char.cc:
...here.
* testsuite/21_strings/basic_string_view/operations/substr/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/operations/substr/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string_view/range_access/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/range_access/char.cc:
...here.
* testsuite/21_strings/basic_string_view/range_access/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/range_access/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char.cc:
...here.
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char16_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char16_t.cc:
...here.
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char32_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char32_t.cc:
...here.
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char8_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char8_t.cc:
...here.
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/1.cc:
Moved to...
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/int.cc:
...here.
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string/requirements/explicit_instantiation/wchar_t.cc:
...here.
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char.cc:
...here.
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char16_t.cc:
...here.
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char32_t.cc:
...here.
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char8_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char8_t.cc:
...here.
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/int.cc:
...here.
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/wchar_t.cc:
...here.
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char/1.cc:
Moved to...
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char.cc:
...here.
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char16_t/1.cc:
Moved to...
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char16_t.cc:
...here.
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char32_t/1.cc:
Moved to...
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char32_t.cc:
...here.
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char8_t/1.cc:
Moved to...
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char8_t.cc:
...here.
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/short/1.cc:
Moved to...
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/short.cc:
...here.
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/wchar_t/1.cc:
Moved to...
* testsuite/21_strings/char_traits/requirements/explicit_instantiation/wchar_t.cc:
...here.

3 years agolibstdc++: Remove redundancy in test pathnames
Jonathan Wakely [Fri, 20 May 2022 09:26:07 +0000 (10:26 +0100)] 
libstdc++: Remove redundancy in test pathnames

Repeating "explicit_instantiation" in these long pathnames is not
necessary.

libstdc++-v3/ChangeLog:

* testsuite/20_util/duration/requirements/explicit_instantiation/explicit_instantiation.cc:
Moved to...
* testsuite/20_util/duration/requirements/explicit_instantiation.cc: ...here.
* testsuite/20_util/time_point/requirements/explicit_instantiation/explicit_instantiation.cc:
Moved to...
* testsuite/20_util/time_point/requirements/explicit_instantiation.cc: ...here.
* testsuite/20_util/unique_ptr/requirements/explicit_instantiation/explicit_instantiation.cc:
Moved to...
* testsuite/20_util/unique_ptr/requirements/explicit_instantiation.cc: ...here.

3 years agoDaily bump.
GCC Administrator [Thu, 26 May 2022 00:16:30 +0000 (00:16 +0000)] 
Daily bump.

3 years agoc++: fix ICE on invalid attributes [PR96637]
Marek Polacek [Thu, 28 Apr 2022 17:21:41 +0000 (13:21 -0400)] 
c++: fix ICE on invalid attributes [PR96637]

When chaining attributes, attr_chainon should be used rather than plain
chainon, so that we don't end up with a TREE_LIST where one of the elements
is error_mark_node, which causes problems.  parser.cc has already been
fixed to use attr_chainon, but decl.cc has not.  Until now.

PR c++/96637

gcc/cp/ChangeLog:

* cp-tree.h (attr_chainon): Declare.
* decl.cc (start_decl): Use attr_chainon.
(grokdeclarator): Likewise.
* parser.cc (cp_parser_statement): No longer static.

gcc/testsuite/ChangeLog:

* g++.dg/parse/error64.C: New test.

3 years agoc++: CTAD with alias and nested template [PR105655]
Jason Merrill [Wed, 25 May 2022 16:38:58 +0000 (12:38 -0400)] 
c++: CTAD with alias and nested template [PR105655]

Here, alias_ctad_tweaks expect tsubst_decl of a FUNCTION_DECL to return a
FUNCTION_DECL.  A reasonable expectation, but in this case we were replacing
the template args of the class-scope deduction guide with equivalent args,
so looking in the hash table we found the partial instantiation stored when
instantiating A<int>, which is a TEMPLATE_DECL.  It's fine for that to be
what is stored, but tsubst_function_decl should never return it.

PR c++/105655

gcc/cp/ChangeLog:

* pt.cc (build_template_decl): Add assert.
(tsubst_function_decl): Don't return a template.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/class-deduction-alias13.C: New test.