aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/Make-lang.in
AgeCommit message (Collapse)AuthorFilesLines
2023-06-15configure: Implement --enable-host-pieMarek Polacek1-4/+4
[ This is my third attempt to add this configure option. The first version was approved but it came too late in the development cycle. The second version was also approved, but I had to revert it: <https://gcc.gnu.org/pipermail/gcc-patches/2022-November/607082.html>. I've fixed the problem (by moving $(PICFLAG) from INTERNAL_CFLAGS to ALL_COMPILERFLAGS). Another change is that since r13-4536 I no longer need to touch Makefile.def, so this patch is simplified. ] This patch implements the --enable-host-pie configure option which makes the compiler executables PIE. This can be used to enhance protection against ROP attacks, and can be viewed as part of a wider trend to harden binaries. It is similar to the option --enable-host-shared, except that --e-h-s won't add -shared to the linker flags whereas --e-h-p will add -pie. It is different from --enable-default-pie because that option just adds an implicit -fPIE/-pie when the compiler is invoked, but the compiler itself isn't PIE. Since r12-5768-gfe7c3ecf, PCH works well with PIE, so there are no PCH regressions. When building the compiler, the build process may use various in-tree libraries; these need to be built with -fPIE so that it's possible to use them when building a PIE. For instance, when --with-included-gettext is in effect, intl object files must be compiled with -fPIE. Similarly, when building in-tree gmp, isl, mpfr and mpc, they must be compiled with -fPIE. With this patch and --enable-host-pie used to configure gcc: $ file gcc/cc1{,plus,obj,gm2} gcc/f951 gcc/lto1 gcc/cpp gcc/go1 gcc/rust1 gcc/gnat1 gcc/cc1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=98e22cde129d304aa6f33e61b1c39e144aeb135e, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/cc1plus: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=859d1ea37e43dfe50c18fd4e3dd9a34bb1db8f77, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/cc1obj: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=1964f8ecee6163182bc26134e2ac1f324816e434, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/cc1gm2: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=a396672c7ff913d21855829202e7b02ecf42ff4c, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/f951: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=59c523db893186547ac75c7a71f48be0a461c06b, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/lto1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=084a7b77df7be2d63c2d4c655b5bbc3fcdb6038d, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/cpp: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=3503bf8390d219a10d6653b8560aa21158132168, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/go1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=988cc673af4fba5dcb482f4b34957b99050a68c5, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/rust1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=b6a5d3d514446c4dcdee0707f086ab9b274a8a3c, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/gnat1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=bb11ccdc2c366fe3fe0980476bcd8ca19b67f9dc, for GNU/Linux 3.2.0, with debug_info, not stripped I plan to add an option to link with -Wl,-z,now. Bootstrapped on x86_64-pc-linux-gnu with --with-included-gettext --enable-host-pie as well as without --enable-host-pie. Also tested on a Debian system where the system gcc was configured with --enable-default-pie. Co-Authored by: Iain Sandoe <iain@sandoe.co.uk> ChangeLog: * configure.ac (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate. c++tools/ChangeLog: * Makefile.in: Rename PIEFLAG to PICFLAG. Set LD_PICFLAG. Use it. Use pic/libiberty.a if PICFLAG is set. * configure.ac (--enable-default-pie): Set PICFLAG instead of PIEFLAG. (--enable-host-pie): New check. * configure: Regenerate. fixincludes/ChangeLog: * Makefile.in: Set and use PICFLAG and LD_PICFLAG. Use the "pic" build of libiberty if PICFLAG is set. * configure.ac: * configure: Regenerate. gcc/ChangeLog: * Makefile.in: Set LD_PICFLAG. Use it. Set enable_host_pie. Remove NO_PIE_CFLAGS and NO_PIE_FLAG. Pass LD_PICFLAG to ALL_LINKERFLAGS. Use the "pic" build of libiberty if --enable-host-pie. * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this check. * configure: Regenerate. * doc/install.texi: Document --enable-host-pie. gcc/ada/ChangeLog: * gcc-interface/Make-lang.in (ALL_ADAFLAGS): Remove NO_PIE_CFLAGS. Add PICFLAG. Use PICFLAG when building ada/b_gnat1.o and ada/b_gnatb.o. * gcc-interface/Makefile.in: Use pic/libiberty.a if PICFLAG is set. Remove NO_PIE_FLAG. gcc/m2/ChangeLog: * Make-lang.in: New var, GM2_PICFLAGS. Use it. gcc/d/ChangeLog: * Make-lang.in: Remove NO_PIE_CFLAGS. intl/ChangeLog: * Makefile.in: Use @PICFLAG@ in COMPILE as well. * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate. libcody/ChangeLog: * Makefile.in: Pass LD_PICFLAG to LDFLAGS. * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this check. * configure: Regenerate. libcpp/ChangeLog: * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate. libdecnumber/ChangeLog: * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate. libiberty/ChangeLog: * configure.ac: Also set shared when enable_host_pie. * configure: Regenerate. zlib/ChangeLog: * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate.
2023-05-30ada: Disable PIE mode during the build of the Ada front-endEric Botcazou1-13/+3
This also removes some obsolete stuff. gcc/ada/ * gcc-interface/Make-lang.in (ADA_CFLAGS): Move up. (ALL_ADAFLAGS): Add $(NO_PIE_CFLAGS). (ada/mdll.o): Remove. (ada/mdll-fil.o): Likewise. (ada/mdll-utl.o): Likewise.
2023-05-15ada: Fix proof of runtime unit System.Value*Claire Dross1-0/+2
Use cut operations to restore the proof of System.Value*. gcc/ada/ * libgnat/s-valueu.adb: Use cut operations inside assertion to restore proofs * gcc-interface/Make-lang.in (GNAT_ADA_OBJS): Add s-spark and s-spcuop dependencies.
2023-01-16ada: Update copyright years.Marc Poulhiès1-3/+1
gcc/ada/ * gcc-interface/Make-lang.in: Update copyright years. * gcc-interface/Makefile.in: Likewise. * gcc-interface/ada-builtin-types.def: Likewise. * gcc-interface/ada-builtins.def: Likewise. * gcc-interface/ada-tree.def: Likewise. * gcc-interface/ada-tree.h: Likewise. * gcc-interface/ada.h: Likewise. * gcc-interface/config-lang.in: Likewise. * gcc-interface/cuintp.cc: Likewise. * gcc-interface/decl.cc: Likewise. * gcc-interface/gadaint.h: Likewise. * gcc-interface/gigi.h: Likewise. * gcc-interface/lang-specs.h: Likewise. * gcc-interface/lang.opt: Likewise. * gcc-interface/misc.cc: Likewise. * gcc-interface/system.ads: Likewise. * gcc-interface/targtyps.cc: Likewise. * gcc-interface/trans.cc: Likewise. * gcc-interface/utils.cc: Likewise. * gcc-interface/utils2.cc: Likewise.
2023-01-02Ada,Darwin: Do not link libgcc statically on Darwin 8 and 9 [PR108202].Iain Sandoe1-2/+11
Normally, GCC executables are built with -static-libstdc++ -static-libgcc on Darwin. This is fine in most cases, because GCC executables typically do no use exceptions. However gnat1 does use exceptions and also pulls in system libraries that are linked against the installed shared libgcc which contains the system unwinder. This means that gnat1 effectively has two unwinder instances (which does not work reliably since the unwinders have global state). A recent change in the initialization of FDEs has made this a hard error now on Darwin versions (8 and 9) with libgcc installed in /usr/lib (gnat1 now hangs when an exception is thrown). The solution is to link libgcc dynamically, picking up the installed system version. To do this we strip -static-libgcc from the link flags. PR ada/108202 gcc/ada/ChangeLog: * gcc-interface/Make-lang.in (GCC_LINKERFLAGS, GCC_LDFLAGS): Versions of ALL_LINKERFLAGS, LDFLAGS with -Werror and -static-libgcc filtered out for Darwin8 and 9 (-Werror is filtered out for other hosts).
2022-12-06ada: Accessibility code reorganization and bug fixesJustin Squirek1-0/+1
This patch performs a large reorganization of accessibility related sources, and also corrects some latent issues with accessibility checks - namely the calculation of accessibility levels for expanded iterators and type conversions. gcc/ada/ * accessibility.adb, accessibility.ads (Accessibility_Message): Moved from sem_attr. (Apply_Accessibility_Check): Moved from checks. (Apply_Accessibility_Check_For_Allocator): Moved from exp_ch4 and renamed (Check_Return_Construct_Accessibility): Moved from sem_ch6. (Innermost_Master_Scope_Depth): Moved from sem_util. Add condition to detect expanded iterators. (Prefix_With_Safe_Accessibility_Level): Moved from sem_attr. (Static_Accessibility_Level): Moved from sem_util. (Has_Unconstrained_Access_Discriminants): Likewise. (Has_Anonymous_Access_Discriminant): Likewise. (Is_Anonymous_Access_Actual): Likewise. (Is_Special_Aliased_Formal_Access): Likewise. (Needs_Result_Accessibility_Level): Likewise. (Subprogram_Access_Level): Likewise. (Type_Access_Level): Likewise. (Deepest_Type_Access_Level): Likewise. (Effective_Extra_Accessibility): Likewise. (Get_Dynamic_Accessibility): Likewise. (Has_Access_Values): Likewise. (Accessibility_Level): Likewise. * exp_attr.adb (Access_Cases): Obtain the proper enclosing object which applies to a given 'Access by looking through type conversions. * exp_ch4.adb (Apply_Accessibility_Check): Moved to accessibility. * exp_ch5.adb: Likewise. * exp_ch6.adb: Likewise. * exp_ch9.adb: Likewise. * exp_disp.adb: Likewise. * gen_il-fields.ads: Add new flag Comes_From_Iterator. * gen_il-gen-gen_nodes.adb: Add new flag Comes_From_Iterator for N_Object_Renaming_Declaration. * sem_ch5.adb (Analyze_Iterator_Specification): Mark object renamings resulting from iterator expansion with the new flag Comes_From_Iterator. * sem_aggr.adb (Resolve_Container_Aggregate): Refine test. * sem_ch13.adb: Add dependence on the accessibility package. * sem_ch3.adb: Likewise. * sem_ch4.adb: Likewise. * sem_ch9.adb: Likewise. * sem_res.adb: Likewise. * sem_warn.adb: Likewise. * exp_ch3.adb: Likewise. * sem_attr.adb (Accessibility_Message): Moved to accessibility. (Prefix_With_Safe_Accessibility_Level): Likewise. * checks.adb, checks.ads (Apply_Accessibility_Check): Likewise. * sem_ch6.adb (Check_Return_Construct_Accessibility): Likewise. * sem_util.adb, sem_util.ads (Accessibility_Level): Likewise. (Deepest_Type_Access_Level): Likewise. (Effective_Extra_Accessibility): Likewise. (Get_Dynamic_Accessibility): Likewise. (Has_Access_Values): Likewise. (Has_Anonymous_Access_Discriminant): Likewise. (Static_Accessibility_Level): Likewise. (Has_Unconstrained_Access_Discriminants): Likewise. (Is_Anonymous_Access_Actual): Likewise. (Is_Special_Aliased_Formal_Access): Likewise. (Needs_Result_Accessibility_Level): Likewise. (Subprogram_Access_Level): Likewise. (Type_Access_Level): Likewise. * sinfo.ads: Document new flag Comes_From_Iterator. * gcc-interface/Make-lang.in: Add entry for new Accessibility package.
2022-11-14Revert "sphinx: ada: port to Sphinx"Martin Liska1-41/+57
This reverts commit 0a543515957ff47feba739e6f71062fb2fb99125.
2022-11-14Revert "sphinx: add --with-sphinx-build"Martin Liska1-12/+12
This reverts commit 1f5a932e89b0c2c4a7af7f849ca2e2e3dbf329e0.
2022-11-14Revert "sphinx: support installation if sphinx-build is missing"Martin Liska1-3/+6
This reverts commit e5821d3f62b5bf532db1be661459b7553a956fa2.
2022-11-09sphinx: support installation if sphinx-build is missingMartin Liska1-6/+3
gcc/ChangeLog: * Makefile.in: Support installation if sphinx-build is missing. gcc/ada/ChangeLog: * gcc-interface/Make-lang.in: Support installation if sphinx-build is missing. gcc/cp/ChangeLog: * Make-lang.in: Support installation if sphinx-build is missing. gcc/d/ChangeLog: * Make-lang.in: Support installation if sphinx-build is missing. gcc/fortran/ChangeLog: * Make-lang.in: Support installation if sphinx-build is missing. gcc/go/ChangeLog: * Make-lang.in: Support installation if sphinx-build is missing. Support installation if sphinx-build is missing. gcc/jit/ChangeLog: * Make-lang.in: Support installation if sphinx-build is missing.
2022-11-09sphinx: add --with-sphinx-buildMartin Liska1-12/+12
gcc/ChangeLog: * Makefile.in: Support --with-sphinx-build. * configure.ac: * configure: Regenerate. gcc/ada/ChangeLog: * gcc-interface/Make-lang.in: Support --with-sphinx-build. gcc/d/ChangeLog: * Make-lang.in: Support --with-sphinx-build. gcc/fortran/ChangeLog: * Make-lang.in: Support --with-sphinx-build. gcc/go/ChangeLog: * Make-lang.in: Support --with-sphinx-build. gcc/jit/ChangeLog: * Make-lang.in: Support --with-sphinx-build. libgomp/ChangeLog: * Makefile.in: Support --with-sphinx-build. * configure.ac: Likewise.. * configure: Regenerate. libiberty/ChangeLog: * Makefile.in: Support --with-sphinx-build. * configure.ac: Likewise. * configure: Regenerate. libitm/ChangeLog: * Makefile.in: Support --with-sphinx-build. * configure.ac: Likewise. * configure: Regenerate. libquadmath/ChangeLog: * Makefile.in: Support --with-sphinx-build. * configure.ac: Likewise. * configure: Regenerate.
2022-11-09sphinx: ada: port to SphinxMartin Liska1-57/+41
gcc/ada/ChangeLog: * doc/gnat-style.rst: Moved to... * doc/gnat-style/index.rst: ...here. * doc/gnat_rm.rst: Moved to... * doc/gnat_rm/index.rst: ...here. * doc/gnat_ugn.rst: Moved to... * doc/gnat_ugn/index.rst: ...here. * doc/share/latex_elements.py: Moved to... * doc/share/ada_latex_elements.py: ...here. * gcc-interface/Make-lang.in: * doc/Makefile: Removed. * doc/share/conf.py: Removed. * doc/share/gnu_free_documentation_license.rst: Removed. * gnat-style.texi: Removed. * gnat_rm.texi: Removed. * gnat_ugn.texi: Removed. * doc/gnat-style/conf.py: New file. * doc/gnat-style/gnu_free_documentation_license.rst: New file. * doc/gnat_rm/conf.py: New file. * doc/gnat_rm/gnu_free_documentation_license.rst: New file. * doc/gnat_ugn/conf.py: New file. * doc/gnat_ugn/gnu_free_documentation_license.rst: New file. * doc/share/adabaseconf.py: New file. * doc/gnat_rm/security_hardening_features.rst: Add role. * doc/gnat_ugn/platform_specific_information.rst: Remove duplicate definition of |nbsp|.
2022-11-08ada: Move warnings switches -- initial workBob Duff1-1/+1
This patch prepares to move warning switches from Opt into Warnsw. gcc/ada/ * warnsw.ads, warnsw.adb, fe.h, err_vars.ads, errout.ads: Move Warning_Doc_Switch from Err_Vars to Warnsw. Access Warn_On_Questionable_Layout on the C side via a function rather than a variable, because we plan to turn the variables into renamings, and you can't Export renamings. * erroutc.adb, switch-c.adb, errout.adb: Likewise. * gcc-interface/decl.cc: Use Get_Warn_On_Questionable_Layout instead of Warn_On_Questionable_Layout. * gcc-interface/Makefile.in (GNATMAKE_OBJS): Add warnsw.o, because it is indirectly imported via Errout. * gcc-interface/Make-lang.in (GNATBIND_OBJS): Likewise and remove restrict.o (not needed).
2022-07-06[Ada] Simplify regular expression that matches 8 consecutive digitsPiotr Trojanek1-1/+1
Makefile cleanup; behaviour is unaffected. gcc/ada/ * gcc-interface/Make-lang.in (ada/generated/gnatvsn.ads): Simplify regular expression. The "interval expression", i.e. \{8\} is part of the POSIX regular expressions, so it should not be a problem for modern implementations of sed.
2022-05-11[Ada] Proof of 'Image support for unsigned integersYannick Moy1-1/+7
Prove System.Image_U, making the connection with the space available in the string as computed with System.Width_U and the functions that support the other direction of 'Value in System.Value_U. The units that support 'Image cannot be marked Pure anymore, as they now depend on non-pure units. gcc/ada/ * libgnat/s-imaged.ads: Remove Pure. * libgnat/s-imagef.ads: Remove Pure. * libgnat/s-imager.ads: Remove Pure. * libgnat/s-imageu.adb: Add ghost code. * libgnat/s-imageu.ads: Add contracts. * libgnat/s-imde128.ads: Remove Pure. * libgnat/s-imde32.ads: Remove Pure. * libgnat/s-imde64.ads: Remove Pure. * libgnat/s-imfi128.ads: Remove Pure. * libgnat/s-imfi32.ads: Remove Pure. * libgnat/s-imfi64.ads: Remove Pure. * libgnat/s-imgflt.ads: Remove Pure. * libgnat/s-imglfl.ads: Remove Pure. * libgnat/s-imgllf.ads: Remove Pure. * libgnat/s-imglllu.ads: Instantiate with ghost subprograms. * libgnat/s-imgllu.ads: Instantiate with ghost subprograms. * libgnat/s-imgrea.ads: Remove Pure. * libgnat/s-imguns.ads: Instantiate with ghost subprograms. * libgnat/s-imguti.ads: Remove Pure. * libgnat/s-valueu.adb (Prove_Iter_Scan_Based_Number_Ghost, Prove_Scan_Only_Decimal_Ghost): New lemmas. * libgnat/s-valueu.ads (Uns_Option): Do not make type ghost to be able to use it as formal in instantiations. (Only_Decimal_Ghost): New ghost query. (Prove_Iter_Scan_Based_Number_Ghost, Prove_Scan_Only_Decimal_Ghost): New lemmas. * libgnat/s-widlllu.ads: Adapt to changes in Width_U. * libgnat/s-widllu.ads: Adapt to changes in Width_U. * libgnat/s-widthu.adb: Change generic function in generic package in order to complete the postcondition. Tighten the upper bound on the result by 1. * libgnat/s-widthu.ads: Same. * libgnat/s-widuns.ads: Adapt to changes in Width_U. * gcc-interface/Make-lang.in: Add dependencies on a-nubinu, a-numeri.ads and a-widuns.ads.
2022-01-17Manual changes for .cc renaming.Martin Liska1-3/+3
gcc/ChangeLog: * Makefile.in: Rename .c names to .cc. * config.gcc: Likewise. * configure: Regenerate. Likewise. * configure.ac: Likewise. * gengtype.cc (set_gc_used): Likewise. (source_dot_c_frul): Likewise. (source_dot_cc_frul): Likewise. (struct file_rule_st): Likewise. (close_output_files): Likewise. * config/avr/t-avr: Use CXXFLAGS_* and CXX_FOR_BUILD. gcc/ada/ChangeLog: * Makefile.rtl: Rename .c names to .cc. * gcc-interface/Make-lang.in: Likewise. * gcc-interface/Makefile.in: Likewise. libgcc/ChangeLog: * libgcov-driver.c: Rename .c names to .cc. libcpp/ChangeLog: * Makefile.in: Rename .c names to .cc.
2022-01-10[Ada] Reduce runtime dependencies on stage1Arnaud Charlet1-29/+26
gcc/ada/ * gcc-interface/Make-lang.in (ADA_GENERATED_FILES): Remove s-casuti.ad?, s-crtl.ad?, s-os_lib.ad?. Update list of object files accordingly.
2022-01-05[Ada] Remove obsolete s-sopco* and s-strops unitsMarc Poulhiès1-10/+1
gcc/ada/ * libgnat/s-sopco3.ads, libgnat/s-sopco3.adb: Remove. * libgnat/s-sopco4.ads, libgnat/s-sopco4.adb: Remove. * libgnat/s-sopco5.ads, libgnat/s-sopco5.adb: Remove. * libgnat/s-strops.ads, libgnat/s-strops.adb: Remove. * Makefile.rtl (ADA_EXCLUDE_SRCS): Remove occurences of removed units. * gcc-interface/Make-lang.in (ada/sdefault.o): Remove dependencies on removed units. (GNATBIND_OBJS): Remove occurences of removed units.
2021-12-02[Ada] Add warning in comment about files copied from libgnatEric Botcazou1-0/+4
gcc/ada/ * gcc-interface/Make-lang.in (ADA_GENERATED_FILES): Add warning.
2021-11-29Make etags path used by build system configurableEric Gallager1-2/+2
This commit allows users to specify a path to their "etags" executable for use when doing "make tags". I based this patch off of this one from upstream automake: https://git.savannah.gnu.org/cgit/automake.git/commit/m4?id=d2ccbd7eb38d6a4277d6f42b994eb5a29b1edf29 This means that I just supplied variables that the user can override for the tags programs, rather than having the configure scripts actually check for them. I handle etags and ctags separately because the intl subdirectory has separate targets for them. This commit only affects the subdirectories that use handwritten Makefiles; the ones that use automake will have to wait until we update the version of automake used to be 1.16.4 or newer before they'll be fixed. Addresses #103021 gcc/ChangeLog: PR other/103021 * Makefile.in: Substitute CTAGS, ETAGS, and CSCOPE variables. Use ETAGS variable in TAGS target. * configure: Regenerate. * configure.ac: Allow CTAGS, ETAGS, and CSCOPE variables to be overridden. gcc/ada/ChangeLog: PR other/103021 * gcc-interface/Make-lang.in: Use ETAGS variable in TAGS target. gcc/c/ChangeLog: PR other/103021 * Make-lang.in: Use ETAGS variable in TAGS target. gcc/cp/ChangeLog: PR other/103021 * Make-lang.in: Use ETAGS variable in TAGS target. gcc/d/ChangeLog: PR other/103021 * Make-lang.in: Use ETAGS variable in TAGS target. gcc/fortran/ChangeLog: PR other/103021 * Make-lang.in: Use ETAGS variable in TAGS target. gcc/go/ChangeLog: PR other/103021 * Make-lang.in: Use ETAGS variable in TAGS target. gcc/objc/ChangeLog: PR other/103021 * Make-lang.in: Use ETAGS variable in TAGS target. gcc/objcp/ChangeLog: PR other/103021 * Make-lang.in: Use ETAGS variable in TAGS target. intl/ChangeLog: PR other/103021 * Makefile.in: Use ETAGS variable in TAGS target, CTAGS variable in CTAGS target, and MKID variable in ID target. * configure: Regenerate. * configure.ac: Allow CTAGS, ETAGS, and MKID variables to be overridden. libcpp/ChangeLog: PR other/103021 * Makefile.in: Use ETAGS variable in TAGS target. * configure: Regenerate. * configure.ac: Allow ETAGS variable to be overridden. libiberty/ChangeLog: PR other/103021 * Makefile.in: Use ETAGS variable in TAGS target. * configure: Regenerate. * configure.ac: Allow ETAGS variable to be overridden.
2021-11-09[Ada] Improve integration of strub with type systemsAlexandre Oliva1-0/+1
gcc/ada/ * strub.adb, strub.ads: New files. * exp_attr.adb (Access_Cases): Copy strub mode to subprogram type. * exp_disp.adb (Expand_Dispatching_Call): Likewise. * freeze.adb (Check_Inherited_Conditions): Check that strub modes match overridden subprograms and interfaces. (Freeze_All): Renaming declarations too. * sem_attr.adb (Resolve_Attribute): Reject 'Access to strub-annotated data object. * sem_ch3.adb (Derive_Subprogram): Copy strub mode to inherited subprogram. * sem_prag.adb (Analyze_Pragma): Propagate Strub Machine_Attribute from access-to-subprogram to subprogram type when required, but not from access-to-data to data type. Mark the entity that got the pragma as having a gigi rep item. * sem_res.adb (Resolve): Reject implicit conversions that would change strub modes. (Resolve_Type_Conversions): Reject checked conversions between incompatible strub modes. * doc/gnat_rm/security_hardening_features.rst: Update. * gnat_rm.texi: Regenerate. * libgnat/a-except.ads (Raise_Exception): Revert strub-callable annotation in public subprogram. * libgnat/s-arit128.ads (Multiply_With_Ovflo_Check128): Likewise. * libgnat/s-arit64.ads (Multiply_With_Ovflo_Check64): Likewise. * libgnat/s-secsta.ads (SS_Allocate): Likewise. (SS_Mark, SS_Release): Likewise. * gcc-interface/Make-lang.in (GNAT_ADA_OBJS): Add ada/strub.o.
2021-11-05Darwin, aarch64 : Ada fixes for hosted tools.Iain Sandoe1-5/+13
This will allow someone (with an existing Ada compiler on the platform - which can be provided by the experimental aarch64-darwin branch) - to build the host tools (gnatmake and friends) for a non-native cross. The existing provisions for iOS are OK for cross-compilation from an x86-64-darwin platform, but we need some adjustments so that these host tools can be built to run on aarch64-darwin. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/ada/ * gcc-interface/Make-lang.in: Use iOS signal trampoline code for hosted Ada tools. * sigtramp-ios.c: Wrap the declarations in extern "C" when the code is built by a C++ compiler.
2021-10-25[Ada] Remove gnatfind and gnatxrefArnaud Charlet1-5/+2
gcc/ada/ * gcc-interface/Make-lang.in, gcc-interface/Makefile.in: Remove gnatfind and gnatxref.
2021-10-22Add install-dvi Makefile targets.Eric Gallager1-2/+14
Closes #102663 ChangeLog: PR other/102663 * Makefile.def: Handle install-dvi target. * Makefile.tpl: Likewise. * Makefile.in: Regenerate. c++tools/ChangeLog: PR other/102663 * Makefile.in: Add dummy install-dvi target. gcc/ChangeLog: PR other/102663 * Makefile.in: Handle dvidir and install-dvi target. * configure: Regenerate. * configure.ac: Add install-dvi to target_list. gcc/ada/ChangeLog: PR other/102663 * gcc-interface/Make-lang.in: Allow dvi-formatted documentation to be installed. gcc/c/ChangeLog: PR other/102663 * Make-lang.in: Add dummy c.install-dvi target. gcc/cp/ChangeLog: PR other/102663 * Make-lang.in: Add dummy c++.install-dvi target. gcc/d/ChangeLog: PR other/102663 * Make-lang.in: Allow dvi-formatted documentation to be installed. gcc/fortran/ChangeLog: PR other/102663 * Make-lang.in: Allow dvi-formatted documentation to be installed. gcc/lto/ChangeLog: PR other/102663 * Make-lang.in: Add dummy lto.install-dvi target. gcc/objc/ChangeLog: PR other/102663 * Make-lang.in: Add dummy objc.install-dvi target. gcc/objcp/ChangeLog: PR other/102663 * Make-lang.in: Add dummy objc++.install-dvi target. gnattools/ChangeLog: PR other/102663 * Makefile.in: Add dummy install-dvi target. libada/ChangeLog: PR other/102663 * Makefile.in: Add dummy install-dvi target. libcpp/ChangeLog: PR other/102663 * Makefile.in: Add dummy install-dvi target. libdecnumber/ChangeLog: PR other/102663 * Makefile.in: Add dummy install-dvi target. libiberty/ChangeLog: PR other/102663 * Makefile.in: Allow dvi-formatted documentation to be installed.
2021-09-22[Ada] Remove System.Img_Enum_New unitEric Botcazou1-2/+0
gcc/ada/ * libgnat/s-imenne.ads, libgnat/s-imenne.adb: Delete. * gcc-interface/Make-lang.in (GNAT_ADA_OBJS): Remove s-imenne.o. (GNATBIND_OBJS): Likewise.
2021-09-20[Ada] Refactor scan_backend_switch to share logic across backendsGhjuvan Lacambre1-0/+1
gcc/ada/ * adabkend.adb (Scan_Back_End_Switches): Replace switch-scanning logic with call to Backend_Utils.Scan_Common_Back_End_Switches. * back_end.adb (Scan_Back_End_Switches): Replace switch-scanning logic with call to Backend_Utils.Scan_Common_Back_End_Switches. * backend_utils.adb: New file. * backend_utils.ads: New file. * gcc-interface/Make-lang.in: Add ada/backend_utils.o.
2021-08-19Define STAGE1_LIBS to link against libcl.a in stage1 on hpux.John David Anglin1-0/+4
2021-08-19 Arnaud Charlet <charlet@adacore.com> PR ada/101924 gcc/ada/ChangeLog: * gcc-interface/Make-lang.in (STAGE1_LIBS): Define on hpux.
2021-06-17[Ada] Use runtime from base compiler during stage1 (continued)Arnaud Charlet1-1/+2
gcc/ada/ * gcc-interface/Make-lang.in: Use libgnat.so if libgnat.a cannot be found.
2021-06-15[Ada] Use runtime from base compiler during stage1Arnaud Charlet1-159/+219
gcc/ada/ * Make-generated.in: Add rule to copy runtime files needed during stage1. * raise.c: Remove obsolete symbols used during bootstrap. * gcc-interface/Make-lang.in: Do not use libgnat sources during stage1. (GNAT_ADA_OBJS, GNATBIND_OBJS): Split in two parts, the common part and the part only used outside of stage1. (ADA_GENERATED_FILES): Add runtime files needed during bootstrap when recent APIs are needed. (ada/b_gnatb.adb): Remove prerequisite. * gcc-interface/system.ads: Remove obsolete entries.
2021-05-11Fix missing version_string in AdaMartin Liska1-1/+3
gcc/ada/ PR bootstrap/100506 * Make-generated.in: Replace version.c with ada/version.c. * gcc-interface/Make-lang.in: Add version.o to GNAT1_C_OBJS. Add version.o to GNAT_ADA_OBJS and GNATBIND_OBJS. * gcc-interface/Makefile.in: Add version.o to TOOLS_LIBS. * gnatvsn.adb: Start using a new C symbol gnat_version_string. * version.c: New file.
2021-05-07[Ada] Variable-sized node typesBob Duff1-12/+25
gcc/ada/ * atree.ads, atree.adb: Major rewrite to support variable-sized node types. Add pragmas Suppress and Assertion_Policy. We now have an extra level of indirection: Node_Offsets is a table mapping Node_Ids to the offset of the start of each node in Slots. Slots is a table containing one or more contiguous slots for each node. Each slot is a 32-bit unchecked union that can contain any mixture of 1, 2, 4, 8, and 32-bit fields that fits. The old low-level getters and setters (e.g. Flag123) are removed. * gen_il-fields.ads, gen_il-gen-gen_entities.adb, gen_il-gen-gen_nodes.adb, gen_il-gen.adb, gen_il-gen.ads, gen_il-main.adb, gen_il-types.ads, gen_il-utils.adb, gen_il-utils.ads, gen_il.adb, gen_il.ads: New gen_il program that generates various Ada and C++ files. In particular, the following files are generated by gen_il: einfo-entities.adb einfo-entities.ads, gnatvsn.ads, nmake.adb, nmake.ads, seinfo.ads, seinfo_tables.adb, seinfo_tables.ads, sinfo-nodes.adb, sinfo-nodes.ads, einfo.h, and sinfo.h. * sinfo-utils.adb, sinfo-utils.ads, einfo-utils.adb, einfo-utils.ads: New files containing code that needs to refer to Sinfo.Nodes and Einfo.Entities. This code is mostly moved here from Sinfo and Einfo to break cycles. * back_end.adb: Pass node_offsets_ptr and slots_ptr to gigi, instead of nodes_ptr and flags_ptr. The Nodes and Flags tables no longer exist. (Note that gigi never used the Flags table.) * sinfo-cn.ads (Change_Identifier_To_Defining_Identifier, Change_Character_Literal_To_Defining_Character_Literal, Change_Operator_Symbol_To_Defining_Operator_Symbol): Turn N into an IN formal. * sinfo-cn.adb: Update. Add assertions, which can be removed at some point. Rewrite to use higher-level facilities. Make sure vanishing fields are zeroed out. Add with/use for new packages. * sem_util.adb: Remove "Assert(False)" immediately followed by "raise Program_Error". Use higher-level facilities such as Walk_Sinfo_Fields instead of depending on low-level Set_FieldN routines that no longer exist. Use Get_Comes_From_Source_Default instead of Default_Node.Comes_From_Source (Default_Node no longer exists). Use Set_Basic_Convention instead of Basic_Set_Convention. Add with/use for new packages. * sem_util.ads: The Convention field had getter Convention and setter Basic_Set_Convention. Make that more uniform: there is now a field called Basic_Convention, with Basic_Convention and Set_Basic_Convention as getter/setter, and write Convention and Set_Convention here. * nlists.adb: Rewrite to use abstractions, rather then depending on low-level implementation details of Atree. Necessary because those details have changed. Add with/use for new packages. * sem_ch12.adb: Use higher-level facilities such as Walk_Sinfo_Fields instead of depending on low-level Set_FieldN routines that no longer exist. Add with/use for new packages. * exp_cg.adb, sem_ch10.adb, sem_ch4.adb, sem_eval.adb, sem_prag.adb, sem_warn.adb: Change expanded names to refer to the new packages for things that moved. Add with/use for new packages. * sem_ch3.adb: Likewise. Reinitialize vanishing fields. * exp_disp.adb: Likewise. Remove failing assertion. * sinfo.ads, einfo.ads: Remove code that is now generated into Sinfo.Nodes and Einfo.Entities. * sinfo.adb, einfo.adb: Replace bodies with "pragma No_Body;". We should delete these at some point, but No_Body makes make files easier. Some code is moved to Sinfo.Nodes, Einfo.Entities, Sinfo.Utils, and Einfo.Utils. Some is no longer necessary. * treepr.adb: Rewrite to use new tables. We no longer need treeprs.ads. * treepr.ads: Add comment. * types.ads: Move types Component_Alignment_Kind and Float_Rep_Kind here. * atree.h: Major update to match atree.ads changes. Add slot types, for use by getters/setters. * types.h: Move types Component_Alignment_Kind and Float_Rep_Kind here. * fe.h: Rewrite to deal with code that has changed or moved from Atree, Sinfo, Einfo. * nlists.h: Move some code to fe.h. * alloc.ads: Split Nodes_* constants into Node_Offsets and Slots, because Atree has two separate tables. Increase values. Remove Nodes_Release_Threshold. Improve comment. * debug.adb, gnat1drv.adb: Remove obsolete gnatd.A and gnatd.N switches. Add with/use for new packages. * opt.ads: Minor comment fix. * aspects.adb, checks.adb, comperr.adb, contracts.adb, cstand.adb, debug_a.adb, errout.adb, eval_fat.adb, exp_aggr.adb, exp_atag.adb, exp_attr.adb, exp_ch11.adb, exp_ch12.adb, exp_ch13.adb, exp_ch2.adb, exp_ch3.adb, exp_ch4.adb, exp_ch5.adb, exp_ch6.adb, exp_ch7.adb, exp_ch8.adb, exp_ch9.adb, exp_code.adb, exp_dbug.adb, exp_dist.adb, exp_fixd.adb, exp_imgv.adb, exp_intr.adb, exp_pakd.adb, exp_prag.adb, exp_put_image.adb, exp_sel.adb, exp_smem.adb, exp_spark.adb, exp_strm.adb, exp_tss.adb, exp_unst.adb, exp_util.adb, exp_util.ads, expander.adb, freeze.adb, frontend.adb, get_targ.ads, ghost.adb, gnat_cuda.adb, impunit.adb, inline.adb, itypes.adb, itypes.ads, layout.adb, lib.adb, lib-load.adb, lib-writ.adb, lib-xref.adb, lib-xref.ads, lib-xref-spark_specific.adb, live.adb, par.adb, par_sco.adb, pprint.adb, repinfo.adb, restrict.adb, rtsfind.adb, scil_ll.adb, scn.adb, sem.adb, sem.ads, sem_aggr.adb, sem_attr.adb, sem_aux.adb, sem_case.adb, sem_cat.adb, sem_ch11.adb, sem_ch13.adb, sem_ch2.adb, sem_ch5.adb, sem_ch6.adb, sem_ch7.adb, sem_ch8.adb, sem_ch9.adb, sem_dim.adb, sem_disp.adb, sem_dist.adb, sem_elab.adb, sem_elim.adb, sem_intr.adb, sem_mech.adb, sem_res.adb, sem_scil.adb, sem_smem.adb, sem_type.adb, set_targ.ads, sinput.adb, sinput-l.adb, sprint.adb, style.adb, styleg.adb, tbuild.adb, tbuild.ads, uname.adb: Add with/use for new packages. * libgnat/a-stoubu.adb, libgnat/a-stouut.adb: Simplify to ease bootstrap. * libgnat/a-stobfi.adb, libgnat/a-stoufi.adb (Create_File, Create_New_File): Create file in binary format, to avoid introducing unwanted text conversions on Windows. Simplify to ease bootstrap. * libgnat/a-stteou__bootstrap.ads: New. * ceinfo.adb, csinfo.adb, nmake.adt, treeprs.adt, xeinfo.adb, xnmake.adb, xsinfo.adb, xtreeprs.adb: Delete. * Make-generated.in: Build and run the gen_il program to generate files. The files are generated in the ada/gen_il subdirectory, and then moved up to ada. We rely on gnatmake (as opposed to make) to build the gen_il program efficiently (i.e. don't do anything if the sources didn't change). * gcc-interface/Makefile.in (ADAFLAGS): Add -gnatU. (GNATMAKE_OBJS): Add new object files. (GENERATED_FILES_FOR_TOOLS): New variable. (../stamp-tools): Create a link for all GENERATED_FILES_FOR_TOOLS. * gcc-interface/Make-lang.in (GNAT_ADA_OBJS): Add new object files. Remove ada/treeprs.o. (GNATBIND_OBJS): Add new object files. (ada.mostlyclean): Remove ada/sdefault.adb and add ada/stamp-gen_il. (ada.maintainer-clean): Remove ada/treeprs.ads. (update-sources): Remove obsolete target. (ada_generated_files): Rename to... (ADA_GENERATED_FILES): ... this. Add new source files. Add comment. * gcc-interface/trans.c: Remove obsolete Nodes_Ptr and Flags_ptr. Add Node_Offsets_Ptr and Slots_Ptr, which point to the corresponding tables in Atree. * gcc-interface/gigi.h (gigi): New parameters for initializing Node_Offsets_Ptr and Slots_Ptr. * gcc-interface/decl.c: Numeric_Kind, Discrete_Or_Fixed_Point_Kind, and Record_Kind were nonhierarchical, and were therefore removed for simplicity. Replace uses with calls to Is_In_... functions. gnattools/ * Makefile.in (GENERATED_FILES_FOR_TOOLS): New variable. ($(GCC_DIR)/stamp-tools): Walk it for the first copy operation.
2021-05-05[Ada] Speed up enumeration'Value with perfect hash functionPiotr Trojanek1-1/+1
gcc/ada/ * Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add s-imagen, s-imen16, s-imen32, s-imenu8, s-pehage, s-valuen, s-vaen16, s-vaen32 and s-vaenu8. Remove s-imenne, s-imgenu and s-valenu. * debug.adb (d_h): Document new usage. * einfo.ads (Lit_Hash): New attribute for enumeration types. (Set_Lit_Hash): Declare. * einfo.adb (Lit_Hash): New function. (Set_Lit_Hash): New procedure. (Write_Field21_Name): Print Lit_Hash for Enumeration_Kind. * exp_imgv.ads (Build_Enumeration_Image_Tables): Fix description and document the hash function and its tables. * exp_imgv.adb: Add with/use clauses for Debug. Add with clause for System.Perfect_Hash_Generators. (Append_Table_To): New helper routine. (Build_Enumeration_Image_Tables): Call it to build the tables. In the main unit, register the literals with the hash generator. If they are sufficiently many and -gnatd_h is not passed, generate a perfect hash function and its tables; otherwise, generate a dummy hash function. For the other units, generate only the declaration. In all cases, set Lit_Hash to the entity of the function, if any. (Expand_Value_Attribute): Pass the 'Unrestricted_Access of Lit_Hash, if any, as third argument to the Value_Enumeration_NN function. * gnat1drv.adb (Adjust_Global_Switches): force simpler implementation of 'Value in CodePeer_Mode. * lib.ads (Synchronize_Serial_Number): Add SN parameter. * lib.adb (Synchronize_Serial_Number): Assert that it is larger than the serial number of the current unit and set the latter to it only in this case. * rtsfind.ads (RTU_Id): Add System_Img_Enum_8, System_Img_Enum_16, System_Img_Enum_32, System_Val_Enum_8, System_Val_Enum_16 and System_Val_Enum_32. Remove System_Img_Enum, System_Img_Enum_New and System_Val_Enum. * sem_attr.adb (Analyze_Access_Attribute): Do not flag a compiler generated Unrestricted_Access attribute as illegal in a declare expression. (RE_Unit_Table): Adjust to above changes. * libgnat/g-heasor.ads: Add pragma Compiler_Unit_Warning. * libgnat/g-table.ads: Likewise. * libgnat/g-pehage.ads: Add with clause and local renaming for System.Perfect_Hash_Generators. (Optimization): Turn into derived type. (Verbose): Turn into renaming. (Too_Many_Tries): Likewise. (Table_Name): Move to System.Perfect_Hash_Generators. (Define): Likewise. (Value): Likewise. * libgnat/g-pehage.adb: Remove with clause for Ada.Directories, GNAT.Heap_Sort_G and GNAT.Table. Move bulk of implementation to System.Perfect_Hash_Generators, only keep the output part. * libgnat/s-imagen.ads: New generic unit. * libgnat/s-imagen.adb: New body. * libgnat/s-imen16.ads: New unit. * libgnat/s-imen32.ads: Likewise. * libgnat/s-imenu8.ads: Likewise. * libgnat/s-imenne.ads: Adjust description. * libgnat/s-imgenu.ads: Delete. * libgnat/s-imgenu.adb: Likewise. * libgnat/s-pehage.ads: New unit from GNAT.Perfect_Hash_Generators. * libgnat/s-pehage.adb: New body from GNAT.Perfect_Hash_Generators. * libgnat/s-valuen.ads: New generic unit. * libgnat/s-valuen.adb: New body. * libgnat/s-vaen16.ads: New unit. * libgnat/s-vaen32.ads: Likewise. * libgnat/s-vaenu8.ads: Likewise. * libgnat/s-valenu.ads: Delete. * libgnat/s-valenu.adb: Likewise. * gcc-interface/Make-lang.in (GNAT_ADA_OBJS): Add s-pehage.o. (GNATBIND_OBJS): Remove s-imgenu.o.
2021-05-05[Ada] Implement tiered support for floating-point output operationsEric Botcazou1-4/+4
gcc/ada/ * Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add s-dourea, s-imager, s-imgflt, s-imglfl and s-imgllf. (LIBGNAT_TARGET_PAIRS) [PowerPC/VxWorks]: Use s-dorepr__fma.adb. (LIBGNAT_TARGET_PAIRS) [PowerPC/VxWorksAE]: Likewise. (LIBGNAT_TARGET_PAIRS) [Aarch64/VxWorks]: Likewise. (LIBGNAT_TARGET_PAIRS) [Aarch64/QNX]: Likewise. (LIBGNAT_TARGET_PAIRS) [Aarch64/FreeBSD]: Likewise. (LIBGNAT_TARGET_PAIRS) [PowerPC/Linux]: Likewise. (LIBGNAT_TARGET_PAIRS) [Aarch64/Linux]: Likewise. (LIBGNAT_TARGET_PAIRS) [IA-64/Linux]: Likewise. (LIBGNAT_TARGET_PAIRS) [IA-64/HP-UX]: Likewise. (LIBGNAT_TARGET_PAIRS) [RISC-V/Linux]: Likewise. (LIBGNAT_TARGET_PAIRS) [PowerPC/Darwin]: Likewise. * exp_attr.adb (Expand_N_Attribute_Reference) [Attribute_Fore]: Use Fixed suffix and Long_Float type. * exp_imgv.adb (Expand_Image_Attribute): For floating-point types, use the routine of the corresponding root type. For ordinary fixed point types, use Fixed suffix and Long_Float type. (Expand_Value_Attribute): Revert latest change for Long_Long_Float. * gcc-interface/Make-lang.in (GNAT_ADA_OBJS): Remove libgnat units g-hesora.o and s-imgenu.o, add g-heasor.o, g-table.o and s-pehage.o. (GNATBIND_OBJS): Remove libgnat unit s-imgenu.o. * rtsfind.ads (RTU_Id): Add System_Img_Flt, System_Img_LFlt and System_Img_LLF. Remove System_Img_Real. (RE_Id): Rename RE_Fore_Real to RE_Fore_Fixed. Add RE_Image_Float, RE_Image_Long_Float and RE_Image_Long_Long_Float. Rename RE_Image_Ordinary_Fixed_Point to RE_Image_Fixed. (RE_Unit_Table): Adjust to above changes. * libgnat/a-nbnbre.adb (Fixed_Conversions): Use Long_Float instead of Long_Long_Float. * libgnat/a-textio.ads (Field): Remove obsolete comment. * libgnat/a-ticoau.ads (Aux): Adjust ancestor package. * libgnat/a-ticoau.adb: Remove with/use clause for System.Img_Real. (Puts): Call Aux.Set_Image instead of Set_Image_Real. * libgnat/a-ticoio.adb: Add with/use clauses for System.Img_Flt, System.Img_LFlt and System.Img_LLF. (Scalar_Float): Add third actual parameter. (Scalar_Long_Float): Likewise. (Scalar_Long_Long_Float): Likewise. * libgnat/a-tifiio.adb: Add with/use clauses for System.Img_LFlt and System.Val_LFlt. Remove the one for System.Val_LLF. Replace Long_Long_Float with Long_Float throughout. * libgnat/a-tifiio__128.adb: Likewise. * libgnat/a-tiflau.ads: Add Set_Image formal parameter. * libgnat/a-tiflau.adb: Add with/use clause for System.Img_Util, remove the one for System.Img_Real. (Put): Call Set_Image instead of Set_Image_Real. (Puts): Likewise. * libgnat/a-tiflio.adb: Add with/use clause for System.Img_Flt, System.Img_LFlt and System.Img_LLF. (Aux_Float): Add third actual parameter. (Aux_Long_Float): Likewise. (Aux_Long_Long_Float): Likewise. * libgnat/a-witeio.ads (Field): Remove obsolete comment. * libgnat/a-wtcoau.ads (Aux): Adjust ancestor package. * libgnat/a-wtcoau.adb: Remove with/use clause for System.Img_Real. (Puts): Call Aux.Set_Image instead of Set_Image_Real. * libgnat/a-wtcoio.adb: Add with/use clauses for System.Img_Flt, System.Img_LFlt and System.Img_LLF. (Scalar_Float): Add third actual parameter. (Scalar_Long_Float): Likewise. (Scalar_Long_Long_Float): Likewise. * libgnat/a-wtfiio.adb: Add with/use clauses for System.Img_LFlt and System.Val_LFlt. Remove the one for System.Val_LLF. Replace Long_Long_Float with Long_Float throughout. * libgnat/a-wtfiio__128.adb: Likewise. * libgnat/a-wtflau.ads: Add Set_Image formal parameter. * libgnat/a-wtflau.adb: Add with/use clause for System.Img_Util, remove the one for System.Img_Real. (Put): Call Set_Image instead of Set_Image_Real. (Puts): Likewise. * libgnat/a-wtflio.adb: Add with/use clause for System.Img_Flt, System.Img_LFlt and System.Img_LLF. (Aux_Float): Add third actual parameter. (Aux_Long_Float): Likewise. (Aux_Long_Long_Float): Likewise. * libgnat/a-ztexio.ads (Field): Remove obsolete comment. * libgnat/a-ztcoau.ads (Aux): Adjust ancestor package. * libgnat/a-ztcoau.adb: Remove with/use clause for System.Img_Real. (Puts): Call Aux.Set_Image instead of Set_Image_Real. * libgnat/a-ztcoio.adb: Add with/use clauses for System.Img_Flt, System.Img_LFlt and System.Img_LLF. (Scalar_Float): Add third actual parameter. (Scalar_Long_Float): Likewise. (Scalar_Long_Long_Float): Likewise. * libgnat/a-ztfiio.adb: Add with/use clauses for System.Img_LFlt and System.Val_LFlt. Remove the one for System.Val_LLF. Replace Long_Long_Float with Long_Float throughout. * libgnat/a-ztfiio__128.adb: Likewise. * libgnat/a-ztflau.ads: Add Set_Image formal parameter. * libgnat/a-ztflau.adb: Add with/use clause for System.Img_Util, remove the one for System.Img_Real. (Put): Call Set_Image instead of Set_Image_Real. (Puts): Likewise. * libgnat/a-ztflio.adb: Add with/use clause for System.Img_Flt, System.Img_LFlt and System.Img_LLF. (Aux_Float): Add third actual parameter. (Aux_Long_Float): Likewise. (Aux_Long_Long_Float): Likewise. * libgnat/s-dorepr.adb: New file. * libgnat/s-dorepr__fma.adb: Likewise. * libgnat/s-dourea.ads: Likewise. * libgnat/s-dourea.adb: Likewise. * libgnat/s-forrea.ads (Fore_Real): Rename into... (Fore_Fixed): ...this and take Long_Float parameters. * libgnat/s-forrea.adb (Fore_Real): Likewise. (Fore_Fixed): Likewise. * libgnat/s-imgrea.ads: Move to... (Set_Image_Real): Turn into mere renaming. * libgnat/s-imager.ads: ...here. (Image_Ordinary_Fixed_Point): Turn into... (Image_Fixed_Point): ...this. * libgnat/s-imgrea.adb: Add pragma No_Body. Move to... * libgnat/s-imager.adb: ...here. (Image_Ordinary_Fixed_Point): Turn into... (Image_Fixed_Point): ...this. (Is_Negative): Replace Long_Long_Float with Num. (Set_Image_Real): Likewise. Use Double_T instead of single Num throughout the algorithm. * libgnat/s-imgflt.ads: New file. * libgnat/s-imglfl.ads: Likewise. * libgnat/s-imgllf.ads: Likewise. * libgnat/s-imagef.ads: Adjust comment. * libgnat/s-imguti.ads (Max_Real_Image_Length): New named number. * libgnat/s-powflt.ads (Maxpow): Adjust. (Powten): Turn into an exact table of double Float. * libgnat/s-powlfl.ads (Maxpow): Adjust. (Powten): Turn into an exact table of double Long_Float. * libgnat/s-powllf.ads (Maxpow): Adjust. (Powten): Turn into an exact table of double Long_Long_Float. * libgnat/s-valrea.ads: Change order of formal parameters. * libgnat/s-valrea.adb: Add with clause for System.Double_Real. (Double_Real): New instantiation. (Fast2Sum): Delete. (Large_Powten): New function. (Integer_to_Real): Use Quick_Two_Sum instead of Fast2Sum. Convert the value to Double_T. Do the scaling in Double_T for base 10. * libgnat/s-valflt.ads: Remove with/use clasue for Interfaces, add it for System.Unsigned_Types. Use Unsigned. * libgnat/s-vallfl.ads: Remove with/use clasue for Interfaces, add it for System.Unsigned_Types. Use Long_Unsigned. * libgnat/s-valllf.ads: Remove with/use clasue for Interfaces, add it for System.Unsigned_Types. Use Long_Long_Unsigned.
2021-05-04[Ada] Assert_Failure vs Assertion_ErrorArnaud Charlet1-0/+2
gcc/ada/ * libgnat/s-assert.ads (Assert_Failure): Now a renaming of Assertion_Error. * libgnat/a-assert.ads (Assertion_Error): Now a first class citizen. Remove dependency on System.Assertions. * gcc-interface/a-assert.ads, gcc-interface/a-assert.adb: New. * gcc-interface/Make-lang.in (GNAT_ADA_OBJS, GNATBIND_OBJS): Add a-assert.o from gcc-interface.
2020-12-07Housekeeping work in gigiEric Botcazou1-4/+3
gcc/ada/ChangeLog: * gcc-interface/Make-lang.in: Remove ^L characters. * gcc-interface/decl.c (create_concat_name): Add cast.
2020-11-20configury: Fix up --enable-link-serialization supportJakub Jelinek1-3/+3
Eric reported that the --enable-link-serialization changes seemed to cause the binaries to be always relinked, for example from the gcc/ directory of the build tree: make [relink of gnat1, brig1, cc1plus, d21, f951, go1, lto1, ...] make [relink of gnat1, brig1, cc1plus, d21, f951, go1, lto1, ...] Furthermore as reported in PR, it can cause problems during make install where make install rebuilds the binaries again. The problem is that for make .PHONY targets are just "rebuilt" always, so it is very much undesirable for the cc1plus$(exeext) etc. dependencies to include .PHONY targets, but I was using them - cc1plus.prev which would depend on some *.serial and e.g. cc1.serial depending on c and c depending on cc1$(exeext). The following patch rewrites this so that *.serial and *.prev aren't .PHONY targets, but instead just make variables. I was worried that the order in which the language makefile fragments are included (which is quite random, what order we get from the filesystem matching */config-lang.in) would be a problem but it seems to work fine - as it uses make = rather than := variables, later definitions are just fine for earlier uses as long as the uses aren't needed during the makefile parsing, but only in the dependencies of make targets and in their commands. 2020-11-20 Jakub Jelinek <jakub@redhat.com> PR other/97911 gcc/ * configure.ac: In SERIAL_LIST use lang words without .serial suffix. Change $lang.prev from a target to variable and instead of depending on *.serial expand to the *.serial variable if the word is in the SERIAL_LIST at all, otherwise to nothing. * configure: Regenerated. gcc/c/ * Make-lang.in (c.serial): Change from goal to a variable. (.PHONY): Drop c.serial. gcc/ada/ * gcc-interface/Make-lang.in (ada.serial): Change from goal to a variable. (.PHONY): Drop ada.serial and ada.prev. (gnat1$(exeext)): Depend on $(ada.serial) rather than ada.serial. gcc/brig/ * Make-lang.in (brig.serial): Change from goal to a variable. (.PHONY): Drop brig.serial and brig.prev. (brig1$(exeext)): Depend on $(brig.serial) rather than brig.serial. gcc/cp/ * Make-lang.in (c++.serial): Change from goal to a variable. (.PHONY): Drop c++.serial and c++.prev. (cc1plus$(exeext)): Depend on $(c++.serial) rather than c++.serial. gcc/d/ * Make-lang.in (d.serial): Change from goal to a variable. (.PHONY): Drop d.serial and d.prev. (d21$(exeext)): Depend on $(d.serial) rather than d.serial. gcc/fortran/ * Make-lang.in (fortran.serial): Change from goal to a variable. (.PHONY): Drop fortran.serial and fortran.prev. (f951$(exeext)): Depend on $(fortran.serial) rather than fortran.serial. gcc/go/ * Make-lang.in (go.serial): Change from goal to a variable. (.PHONY): Drop go.serial and go.prev. (go1$(exeext)): Depend on $(go.serial) rather than go.serial. gcc/jit/ * Make-lang.in (jit.serial): Change from goal to a variable. (.PHONY): Drop jit.serial and jit.prev. ($(LIBGCCJIT_FILENAME)): Depend on $(jit.serial) rather than jit.serial. gcc/lto/ * Make-lang.in (lto1.serial, lto2.serial): Change from goals to variables. (.PHONY): Drop lto1.serial, lto2.serial, lto1.prev and lto2.prev. ($(LTO_EXE)): Depend on $(lto1.serial) rather than lto1.serial. ($(LTO_DUMP_EXE)): Depend on $(lto2.serial) rather than lto2.serial. gcc/objc/ * Make-lang.in (objc.serial): Change from goal to a variable. (.PHONY): Drop objc.serial and objc.prev. (cc1obj$(exeext)): Depend on $(objc.serial) rather than objc.serial. gcc/objcp/ * Make-lang.in (obj-c++.serial): Change from goal to a variable. (.PHONY): Drop obj-c++.serial and obj-c++.prev. (cc1objplus$(exeext)): Depend on $(obj-c++.serial) rather than obj-c++.serial.
2020-11-18configury: --enable-link-serialization supportJakub Jelinek1-2/+6
When performing LTO bootstraps, especially when using tmpfs for /tmp, one can run a machine to halt when using higher levels of parallelism and a large number of FEs, because there are too many concurrent LTO link commands running at the same time and each one of them puts most of the middle-end/backend objects into /tmp. We have --enable-link-mutex configure option, but --enable-link-mutex has a big problem that it decreases number of available jobs by the number of link commands waiting for the lock, so e.g. when doing make -j32 build with 11 different big programs linked with $(LLINKER) we end up with just 22 effective jobs, and with e.g. make -j8 with those 11 different big programs we actually most likely serialize everything during linking onto a single job. The following patch implements a new configure option, --enable-link-serialization, which implements different serialization and as it doesn't use the mutex, just modifying the old option to be implemented differently would be strange. We can deprecate and later remove the old option. The new option doesn't use any shell mutexes, but uses make dependencies. The option is implemented inside of gcc/ configure and Makefiles, which means that even inside of gcc/ make all (as well as e.g. make lto-dump) will serialize and build all previous large binaries when configured this way. One can always make -j32 cc1 DO_LINK_SERIALIZATION= to avoid that. Furthermore, I've implemented the idea I wrote about, so that --enable-link-serialization is the same as --enable-link-serialization=1 and means the large link commands are serialized, one can (the default) --disable-link-serialization which will cause all links to be parallelizable, but one can also --enable-link-serialization=3 etc. which says that at most 3 of the large link commands can run concurrently. And finally I've implemented (only if the serialization is enabled) simple progress bars for the linking. With --enable-link-serialization and e.g. the 5 large links I have in my current tree (cc1, cc1plus, f951, lto1 and lto-dump), before the linking it prints Linking |==-- | 20% and after it Linking |==== | 40% (each == characters stand for already finished links, each -- characters stand for the link being started). With --enable-link-serialization=3 it will change the way the start is printed, one will get: Linking |-- | 0% at the start of cc1 link, Linking |>>-- | 0% at the start of the second large link and Linking |>>>>-- | 0% at the start of the third large link, where the >> characters stand for already pending links. The printing at the end of link command is the same as with the full serialization, i.e. for the above 3: Linking |== | 20% Linking |==== | 40% Linking |====== | 60% but one could actually get them in any order depending on which of those 3 finishes first - to get it 100% accurate I'd need to add some directory with files representing finished links or similar, doesn't seem worth it. 2020-11-18 Jakub Jelinek <jakub@redhat.com> gcc/ * configure.ac: Add $lang.prev rules, INDEX.$lang and SERIAL_LIST and SERIAL_COUNT variables to Make-hooks. (--enable-link-serialization): New configure option. * Makefile.in (DO_LINK_SERIALIZATION, LINK_PROGRESS): New variables. * doc/install.texi (--enable-link-serialization): Document. * configure: Regenerated. gcc/c/ * Make-lang.in (c.serial): New goal. (.PHONY): Add c.serial c.prev. (cc1$(exeext)): Call LINK_PROGRESS. gcc/cp/ * Make-lang.in (c++.serial): New goal. (.PHONY): Add c++.serial c++.prev. (cc1plus$(exeext)): Depend on c++.prev. Call LINK_PROGRESS. gcc/fortran/ * Make-lang.in (fortran.serial): New goal. (.PHONY): Add fortran.serial fortran.prev. (f951$(exeext)): Depend on fortran.prev. Call LINK_PROGRESS. gcc/lto/ * Make-lang.in (lto, lto1.serial, lto2.serial): New goals. (.PHONY): Add lto lto1.serial lto1.prev lto2.serial lto2.prev. (lto.all.cross, lto.start.encap): Remove dependencies. ($(LTO_EXE)): Depend on lto1.prev. Call LINK_PROGRESS. ($(LTO_DUMP_EXE)): Depend on lto2.prev. Call LINK_PROGRESS. gcc/objc/ * Make-lang.in (objc.serial): New goal. (.PHONY): Add objc.serial objc.prev. (cc1obj$(exeext)): Depend on objc.prev. Call LINK_PROGRESS. gcc/objcp/ * Make-lang.in (obj-c++.serial): New goal. (.PHONY): Add obj-c++.serial obj-c++.prev. (cc1objplus$(exeext)): Depend on obj-c++.prev. Call LINK_PROGRESS. gcc/ada/ * gcc-interface/Make-lang.in (ada.serial): New goal. (.PHONY): Add ada.serial ada.prev. (gnat1$(exeext)): Depend on ada.prev. Call LINK_PROGRESS. gcc/brig/ * Make-lang.in (brig.serial): New goal. (.PHONY): Add brig.serial brig.prev. (brig1$(exeext)): Depend on brig.prev. Call LINK_PROGRESS. gcc/go/ * Make-lang.in (go.serial): New goal. (.PHONY): Add go.serial go.prev. (go1$(exeext)): Depend on go.prev. Call LINK_PROGRESS. gcc/jit/ * Make-lang.in (jit.serial): New goal. (.PHONY): Add jit.serial jit.prev. ($(LIBGCCJIT_FILENAME)): Depend on jit.prev. Call LINK_PROGRESS. gcc/d/ * Make-lang.in (d.serial): New goal. (.PHONY): Add d.serial d.prev. (d21$(exeext)): Depend on d.prev. Call LINK_PROGRESS.
2020-10-19[Ada] Implement initialization of CUDA runtimeGhjuvan Lacambre1-0/+1
gcc/ada/ * debug.adb: Document -gnatd_c flag as being used for CUDA. * gnat_cuda.ads: New file. * gnat_cuda.adb: New file. * rtsfind.ads: Add Interfaces_C_Strings package and RE_Fatbin_Wrapper, RE_Register_Fat_Binary, RE_Register_Fat_Binary_End, RE_Register_Function, RE_Chars_Ptr, RE_New_Char_Array entities. * rtsfind.adb: Create new Interfaces_C_Descendant subtype, handle it. * sem_ch7.adb (Analyze_Package_Body_Helper): Call CUDA init procedure. * sem_prag.adb (Analyze_Pragma): Call Add_Cuda_Kernel procedure. * gcc-interface/Make-lang.in (GNAT_ADA_OBJS): Add gnat_cuda.o.
2020-10-16[Ada] Clean up in system.ads dependencies during compiler buildArnaud Charlet1-5/+6
gcc/ada/ * gcc-interface/Make-lang.in: Update dependencies on system.ads, add gnatbind switch -t to avoid timestamp inconsistencies during build. * libgnat/system.ads: Move... * gcc-interface/system.ads: ... here.
2020-06-04[Ada] Put_Image attributeBob Duff1-0/+1
2020-06-04 Bob Duff <duff@adacore.com> gcc/ada/ * libgnat/a-stobbu.adb, libgnat/a-stobbu.ads, libgnat/a-stobfi.adb, libgnat/a-stobfi.ads, libgnat/a-stoubu.adb, libgnat/a-stoubu.ads, libgnat/a-stoufi.adb, libgnat/a-stoufi.ads, libgnat/a-stoufo.adb, libgnat/a-stoufo.ads, libgnat/a-stouut.adb, libgnat/a-stouut.ads, libgnat/a-stteou.ads, libgnat/s-putaim.adb, libgnat/s-putaim.ads, libgnat/s-putima.adb, libgnat/s-putima.ads (Ada.Strings.Text_Output and children, System.Put_Images): New runtime support for Put_Image. * gcc-interface/Make-lang.in (GNAT_ADA_OBJS): Add exp_put_image.o. * exp_put_image.adb, exp_put_image.ads: New compiler package that generates calls to runtime routines that implement Put_Image. * Makefile.rtl: Add object files for Ada.Strings.Text_Output and children and System.Put_Images. * aspects.adb: Simplify initialization of Canonical_Aspect. * aspects.ads: Improve documentation. Add Aspect_Put_Image. * exp_attr.adb: Add support for Put_Image, by calling routines in Exp_Put_Image. * sem_util.adb (Is_Predefined_Dispatching_Operation): Return True for new TSS_Put_Image operation. * exp_ch3.adb: For tagged types, build a dispatching TSS_Put_Image operation by calling routines in Exp_Put_Image. * exp_disp.adb, exp_disp.ads: Make TSS_Put_Image be number 10, adjusting other operations' numbers after 10. We choose 10 because that's the last number shared by all runtimes. * exp_strm.adb: Use named notation as appropriate. * exp_cg.adb, exp_tss.ads: Add TSS_Put_Image. * libgnat/a-tags.ads: Modify Max_Predef_Prims for the new TSS_Put_Image. * impunit.adb: Add new runtime packages. * rtsfind.adb, rtsfind.ads: Add support for Ada.Strings.Text_Output, Ada.Strings.Text_Output.Utils, and System.Put_Images. * sem_attr.adb: Error checking for Put_Image calls. * sem_ch12.adb (Valid_Default_Attribute): Support for passing Put_Image as a generic formal parameter. * sem_ch13.adb: Analysis of Put_Image aspect. Turn it into a Put_Image attribute definition clause. * sem_ch8.adb (Analyze_Subprogram_Renaming): Support for renaming of the Put_Image attribute. * snames.adb-tmpl: Fix comments. * snames.ads-tmpl (Name_Put_Image): New Name_Id. (Attribute_Put_Image): New Attribute_Id. * tbuild.adb, tbuild.ads (Make_Increment): New utility.
2020-06-03[Ada] Initial infrastructure for adding a tree checkerArnaud Charlet1-0/+1
2020-06-03 Arnaud Charlet <charlet@adacore.com> gcc/ada/ * frontend.adb (Frontend): Call (dummy for now) tree checker. * debug.adb: Reserve -gnatd_V for the tree checker. * vast.ads, vast.adb: New files. * gcc-interface/Make-lang.in: Add vast.o.
2020-06-03[Ada] Remove ASIS tree generationArnaud Charlet1-5/+1
2020-06-03 Arnaud Charlet <charlet@adacore.com> gcc/ada/ * aspects.adb, aspects.ads, atree.adb, atree.ads, elists.adb, elists.ads, fname.adb, fname.ads, gnat1drv.adb, lib.adb, lib.ads, namet.adb, namet.ads, nlists.adb, nlists.ads, opt.adb, opt.ads, osint-c.adb, osint-c.ads, repinfo.adb, repinfo.ads, sem_aux.adb, sem_aux.ads, sinput.adb, sinput.ads, stand.ads, stringt.adb, stringt.ads, switch-c.adb, table.adb, table.ads, uintp.adb, uintp.ads, urealp.adb, urealp.ads (Tree_Read, Tree_Write): Remove generation of ASIS trees. * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Remove -gnatt and -gnatct documentation. * gnat_ugn.texi: Regenerate. * tree_in.ads, tree_in.adb, tree_io.ads, tree_io.adb, tree_gen.ads, tree_gen.adb, stand.adb: Remove. * gcc-interface/Makefile.in, gcc-interface/Make-lang.in: Remove references to tree_gen.o tree_in.o tree_io.o.
2019-10-01libada: Remove racy duplicate gnatlib installationMaciej W. Rozycki1-1/+4
For some reason, presumably historical, the `install-gnatlib' target for the default multilib is invoked twice, once via the `ada.install-common' target in `gcc/ada/gcc-interface/Make-lang.in' invoked from gcc/ and again via the `install-libada' target in libada/. Apart from doing the same twice this is actually harmful in sufficiently parallelized `make' invocation, as the removal of old files performed within the `install-gnatlib' recipe in the former case actually races with the installation of new files done in the latter case, causing the recipe to fail and abort, however non-fatally, having not completed the installation of all the built files needed for the newly-built compiler to work correctly. This can be observed with a native `x86_64-linux-gnu' bootstrap: make[4]: Entering directory '.../gcc/ada' rm -rf .../lib/gcc/x86_64-linux-gnu/10.0.0/adalib rm: cannot remove '.../lib/gcc/x86_64-linux-gnu/10.0.0/adalib': Directory not empty make[4]: *** [gcc-interface/Makefile:512: install-gnatlib] Error 1 make[4]: Leaving directory '.../gcc/ada' make[3]: *** [.../gcc/ada/gcc-interface/Make-lang.in:853: install-gnatlib] Error 2 make[2]: [.../gcc/ada/gcc-interface/Make-lang.in:829: ada.install-common] Error 2 (ignored) which then causes missing files to be reported when an attempt is made to use the newly-installed non-functional compiler to build a `riscv-linux-gnu' cross-compiler: (cd ada/bldtools/sinfo; gnatmake -q xsinfo ; ./xsinfo sinfo.h ) error: "ada.ali" not found, "ada.ads" must be compiled error: "s-memory.ali" not found, "s-memory.adb" must be compiled gnatmake: *** bind failed. /bin/sh: ./xsinfo: No such file or directory make[2]: *** [.../gcc/ada/Make-generated.in:45: ada/sinfo.h] Error 127 make[2]: Leaving directory '.../gcc' make[1]: *** [Makefile:4369: all-gcc] Error 2 make[1]: Leaving directory '...' make: *** [Makefile:965: all] Error 2 Depending on timing `.../lib/gcc/x86_64-linux-gnu/10.0.0/adainclude' may cause an installation failure instead and the resulting compiler may be non-functional in a different way. Only invoke `install-gnatlib' from within gcc/ then if a legacy build process is being used with libada disabled and gnatlib built manually with `make -C gcc gnatlib'. gcc/ * Makefile.in (gnat_install_lib): New variable. * configure.ac: Substitute it. * configure: Regenerate. gcc/ada/ * gcc-interface/Make-lang.in (ada.install-common): Split into... (gnat-install-tools, gnat-install-lib): ... these. From-SVN: r276422
2019-09-19[Ada] Move SPARK borrow-checker to gnat2why codebaseYannick Moy1-1/+0
Unit sem_spark was implementing the borrow-checker for the support of ownership pointers in SPARK. It has been moved to gnat2why codebase to facilitate its evolution and allow the more powerful flow analysis to provide its results for better analysis on pointers. 2019-09-19 Yannick Moy <moy@adacore.com> gcc/ada/ * gcc-interface/Make-lang.in: Remove references to sem_spark. * sem_spark.adb, sem_spark.ads: Remove unit. From-SVN: r275944
2019-08-13[Ada] Systematically pass LN_S to relevant gnatlib targetsArnaud Charlet1-2/+1
2019-08-13 Arnaud Charlet <charlet@adacore.com> gcc/ada/ * gcc-interface/Make-lang.in: Remove unused TRACE variable. Pass LN_S to relevant gnatlib targets. * gcc-interface/Makefile.in: Systematically pass LN_S to relevant gnatlib targets. From-SVN: r274340
2019-07-11[Ada] New Repinfo.Input unit to read back JSON representation info.Eric Botcazou1-0/+1
For some time the Repinfo unit has been able to output the representation information in the JSON data interchange format in addition to the usual text and binary formats. The new Repinfo.Input unit makes it possible to read back this information under this format and make it available to clients, the main one being ASIS. The big advantage of using this approach over manipulating a binary blob is that the writer and the reader of the JSON representation need not be binary compatible, i.e. in practice need not be the same version of the compiler or ASIS for the same target. The patch also adds a -gnatd_j switch to read back the information in the compiler itself, which makes it easy to keep the writer and the reader in sync using only one tool, namely the compiler. The typical usage is: gcc -c p.ads -gnatR4js gcc -c p.ads -gnatd_j to exercise respectively the writer and the reader from the compiler. 2019-07-11 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * alloc.ads (Rep_JSON_Table_Initial): New constant. (Rep_JSON_Table_Increment): Likewise. * debug.adb: Document -gnatd_j switch. * gcc-interface/Make-lang.in (GNAT_ADA_OBJS): Add repinfo-input.o. * gnat1drv.adb: Add with clause for Repinfo.Input. Add with and use clauses for Sinput. (Read_JSON_Files_For_Repinfo): New procedure. (Gnat1drv1): Deal with -gnatd_j switch. * repinfo-input.ad[sb]: New unit. * snames.ads-tmpl (Name_Discriminant): New constant. (Name_Operands): Likewise. From-SVN: r273382
2019-07-03[Ada] ABE checks v3.0, foundations of Elaboration order v4.0Hristian Kirtchev1-2/+15
------------------------ -- Elaboration checks -- ------------------------ The dynamic ABE checks model now emits the same diagnostics as those of the static ABE checks model. The ABE checks mechanism has been redesigned and refactored in the face of increasing requirements. Most of the functionality can now be toggled, thus allowing for various combinations of behavior. The combinations are defined as "initial states" and may be further altered. Scenarios and targets have been distinctly separated at the higher level, instead of directly working with nodes and entitites. Scenarios and targets now carry a representation which removes the need to constantly recompute relevant attributes, and offers a common interface for the various processors. Most processing has now been refactored into "services" which perform a single ABE-related function. ----------------------- -- Elaboration order -- ----------------------- A new elaboration order mechanism based on the use of an invocation graph to provide extra information about the flow of execution at elaboration time has been introduced. The ABE checks mechanism has been altered to encode pieces of the invocation graph in the associated ALI files of units. The new elaboration order mechanism reconstructs the full invocation graph at bind time, and coupled with the library item graph, determines the elaboration order of units. The new elaboration order mechanism is currently inaccessible. ------------ -- Source -- ------------ -- pack.ads package Pack is procedure ABE_Proc; procedure Safe_Proc; end Pack; -- pack.adb with Ada.Text_IO; use Ada.Text_IO; package body Pack is function Call_Proc (ABE : Boolean) return Integer; procedure Safe_Proc is begin Put_Line ("safe"); end Safe_Proc; function Call_Proc (ABE : Boolean) return Integer is begin if ABE then ABE_Proc; else Safe_Proc; end if; return 0; end Call_Proc; Elab_1 : constant Integer := Call_Proc (ABE => False); Elab_2 : constant Integer := Call_Proc (ABE => True); procedure ABE_Proc is begin Put_Line ("ABE"); end ABE_Proc; end Pack; -- main.adb with Pack; procedure Main is begin null; end Main; ---------------------------- -- Compilation and output -- ---------------------------- $ gnatmake -f -q -gnatE main.adb $ ./main $ gnatmake -f -q -gnatE main.adb -gnatDG -gnatwL $ grep -c "safeE" pack.adb.dg pack.adb:14:10: warning: cannot call "ABE_Proc" before body seen pack.adb:14:10: warning: Program_Error may be raised at run time pack.adb:14:10: warning: body of unit "Pack" elaborated pack.adb:14:10: warning: function "Call_Proc" called at line 22 pack.adb:14:10: warning: procedure "ABE_Proc" called at line 14 pack.adb:14:10: warning: cannot call "ABE_Proc" before body seen pack.adb:14:10: warning: Program_Error may be raised at run time pack.adb:14:10: warning: body of unit "Pack" elaborated pack.adb:14:10: warning: function "Call_Proc" called at line 23 pack.adb:14:10: warning: procedure "ABE_Proc" called at line 14 safe raised PROGRAM_ERROR : pack.adb:14 access before elaboration 0 2019-07-03 Hristian Kirtchev <kirtchev@adacore.com> gcc/ada/ * ali.adb: Add with and use clauses for GNAT, GNAT.Dynamic_HTables, and Snames. Add a map from invocation signature records to invocation signature ids. Add various encodings of invocation-related attributes. Sort and update table Known_ALI_Lines. (Add_Invocation_Construct, Add_Invocation_Relation, Body_Placement_Kind_To_Code, Code_To_Body_Placement_Kind, Code_To_Invocation_Construct_Kind, Code_To_Invocation_Kind, Code_To_Invocation_Graph_Line_Kind, Destroy, Hash): New routines. (Initialize_ALI): Sort the initialization sequence. Add initialization for all invocation-related tables. (Invocation_Construct_Kind_To_Code, Invocation_Graph_Line_Kind_To_Code, Invocation_Kind_To_Code, Invocation_Signature_Of, Present): New routines. (Scan_ALI): Add the default values for invocation-related ids. Scan invocation graph lines. (Scan_Invocation_Graph_Line): New routine. * ali.ads: Add with clause for GNAT.Dynamic_Tables. Add types for invocation constructs, relations, and signatures. Add tables for invocation constructs, relations, and signatures. Update Unit_Record to capture invocation-related ids. Relocate table Unit_Id_Tables and subtypes Unit_Id_Table, Unit_Id_Array from Binde. (Add_Invocation_Construct, Add_Invocation_Relation, Body_Placement_Kind_To_Code, Code_To_Body_Placement_Kind, Code_To_Invocation_Construct_Kind, Code_To_Invocation_Kind, Code_To_Invocation_Graph_Line_Kind, Invocation_Construct_Kind_To_Code, Invocation_Graph_Line_Kind_To_Code, Invocation_Kind_To_Code, Invocation_Signature_Of, Present): New routines. * binde.adb: Add with and use clause for Types. Add use clause for ALI.Unit_Id_Tables; * binde.ads: Relocate table Unit_Id_Tables and subtypes Unit_Id_Table, Unit_Id_Array to ALI. * bindgen.adb: Remove with and use clause for ALI. * bindgen.ads: Remove with and use clause for Binde. Add with and use clause for ALI. * bindo.adb, bindo.ads, bindo-augmentors.adb, bindo-augmentors.ads, bindo-builders.adb, bindo-builders.ads, bindo-diagnostics.adb, bindo-diagnostics.ads, bindo-elaborators.adb, bindo-elaborators.ads, bindo-graphs.adb, bindo-graphs.ads, bindo-units.adb, bindo-units.ads, bindo-validators.adb, bindo-validators.ads, bindo-writers.adb, bindo-writers.ads: New units. * debug.adb: Use and describe GNAT debug switches -gnatd_F and -gnatd_G. Add GNATbind debug switches in the ranges dA .. dZ, d.a .. d.z, d.A .. d.Z, d.1 .. d.9, d_a .. d_z, d_A .. d_Z, and d_1 .. d_9. Use and describe GNATbind debug switches -d_A, -d_I, -d_L, -d_N, -d_O, -d_T, and -d_V. * exp_util.adb, exp_util.ads (Exceptions_OK): Relocate to Sem_Util. * gnatbind.adb: Add with and use clause for Bindo. Use the new Bindo elaboration order only when -d_N is in effect. * lib-writ.adb (Column, Extra, Invoker, Kind, Line, Locations, Name, Placement, Scope, Signature, Target): New routines. (Write_ALI): Output all invocation-related data. (Write_Invocation_Graph): New routine. * lib-writ.ads: Document the invocation graph ALI line. * namet.adb, namet.ads (Present): New routines. * sem_ch8.adb (Find_Direct_Name): Capture the status of elaboration checks and warnings of an identifier. (Find_Expanded_Name): Capture the status of elaboration checks and warnings of an expanded name. * sem_ch12.adb (Analyze_Generic_Package_Declaration): Ensure that invocation graph-related data within the body of the main unit is encoded in the ALI file. (Analyze_Generic_Subprogram_Declaration): Ensure that invocation graph-related data within the body of the main unit is encoded in the ALI file. (Analyze_Package_Instantiation): Perform minimal decoration of the instance entity. (Analyze_Subprogram_Instantiation): Perform minimal decoration of the instance entity. * sem_elab.adb: Perform heavy refactoring of all code. The unit is now split into "services" which specialize in one area of ABE checks. Add processing in order to capture invocation-graph related attributes of the main unit, and encode them in the ALI file. The Processing phase can now operate in multiple modes, all described by type Processing_Kind. Scenarios and targets are now distinct at the higher level, and carry their own representations. This eliminates the need to constantly recompute their attributes, and offers the various processors a uniform interface. The various initial states of the Processing phase are now encoded using type Processing_In_State, and xxx_State constants. * sem_elab.ads: Update the literals of type Enclosing_Level_Kind. Add Inline pragmas on several routines. * sem_prag.adb (Process_Inline): Ensure that invocation graph-related data within the body of the main unit is encoded in the ALI file. * sem_util.adb (Enclosing_Generic_Body, Enclosing_Generic_Unit): Code clean up. (Exceptions_OK): Relocated from Sem_Util. (Mark_Save_Invocation_Graph_Of_Body): New routine. * sem_util.ads (Exceptions_OK): Relocated from Sem_Util. (Mark_Save_Invocation_Graph_Of_Body): New routine. * sinfo.adb (Is_Elaboration_Checks_OK_Node): Now applicable to N_Variable_Reference_Marker. (Is_Elaboration_Warnings_OK_Node): Now applicable to N_Expanded_Name, N_Identifier, N_Variable_Reference_Marker. (Is_Read): Use Flag4. (Is_SPARK_Mode_On_Node): New applicable to N_Variable_Reference_Marker. (Is_Write): Use Flag5. (Save_Invocation_Graph_Of_Body): New routine. (Set_Is_Elaboration_Checks_OK_Node): Now applicable to N_Variable_Reference_Marker. (Set_Is_Elaboration_Warnings_OK_Node): Now applicable to N_Expanded_Name, N_Identifier, N_Variable_Reference_Marker. (Set_Is_SPARK_Mode_On_Node): New applicable to N_Variable_Reference_Marker. (Set_Save_Invocation_Graph_Of_Body): New routine. * sinfo.ads: Update the documentation of attributes Is_Elaboration_Checks_OK_Node, Is_Elaboration_Warnings_OK_Node, Is_SPARK_Mode_On_Node. Update the flag usage of attributes Is_Read, Is_Write. Add attribute Save_Invocation_Graph_Of_Body and update its occurrence in nodes. (Save_Invocation_Graph_Of_Body): New routine along with pragma Inline. (Set_Save_Invocation_Graph_Of_Body): New routine along with pragma Inline. * switch-b.adb (Scan_Binder_Switches): Refactor the scanning of debug switches. (Scan_Debug_Switches): New routine. * libgnat/g-dynhta.adb, libgnat/g-dynhta.ads (Contains): New routine. * libgnat/g-graphs.adb (Associate_Vertices): Update the use of Component_Vertex_Iterator. (Contains_Component, Contains_Edge, Contains_Vertex, Has_Next): Reimplemented. (Iterate_Component_Vertices): New routine. (Iterate_Vertices): Removed. (Next): Update the parameter profile. (Number_Of_Component_Vertices, Number_Of_Outgoing_Edges): New routines. * libgnat/g-graphs.ads: Update the initialization of No_Component. Add type Component_Vertex_Iterator. Remove type Vertex_Iterator. (Has_Next): Add new versions and remove old ones. (Iterate_Component_Vertices): New routine. (Iterate_Vertices): Removed. (Next): Add new versions and remove old ones. (Number_Of_Component_Vertices, Number_Of_Outgoing_Edges): New routines. * libgnat/g-sets.adb (Contains): Reimplemented. * gcc-interface/Make-lang.in (GNATBIND_OBJS): Add GNAT.Dynamic_HTables, GNAT.Graphs and Bindo units. * rtsfind.ads: Remove extra space. From-SVN: r272976
2019-07-01[Ada] Implement GNAT.GraphsHristian Kirtchev1-0/+1
This patch introduces new unit GNAT.Graphs which currently provides a directed graph abstraction. ------------ -- Source -- ------------ -- operations.adb with Ada.Text_IO; use Ada.Text_IO; with GNAT; use GNAT; with GNAT.Graphs; use GNAT.Graphs; with GNAT.Sets; use GNAT.Sets; procedure Operations is type Vertex_Id is (No_V, VA, VB, VC, VD, VE, VF, VG, VH, VX, VY, VZ); No_Vertex_Id : constant Vertex_Id := No_V; function Hash_Vertex (V : Vertex_Id) return Bucket_Range_Type; type Edge_Id is (No_E, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E97, E98, E99); No_Edge_Id : constant Edge_Id := No_E; function Hash_Edge (E : Edge_Id) return Bucket_Range_Type; package ES is new Membership_Set (Element_Type => Edge_Id, "=" => "=", Hash => Hash_Edge); package DG is new Directed_Graph (Vertex_Id => Vertex_Id, No_Vertex => No_Vertex_Id, Hash_Vertex => Hash_Vertex, Same_Vertex => "=", Edge_Id => Edge_Id, No_Edge => No_Edge_Id, Hash_Edge => Hash_Edge, Same_Edge => "="); use DG; package VS is new Membership_Set (Element_Type => Vertex_Id, "=" => "=", Hash => Hash_Vertex); ----------------------- -- Local subprograms -- ----------------------- procedure Check_Belongs_To_Component (R : String; G : Instance; V : Vertex_Id; Exp_Comp : Component_Id); -- Verify that vertex V of graph G belongs to component Exp_Comp. R is the -- calling routine. procedure Check_Belongs_To_Some_Component (R : String; G : Instance; V : Vertex_Id); -- Verify that vertex V of graph G belongs to some component. R is the -- calling routine. procedure Check_Destination_Vertex (R : String; G : Instance; E : Edge_Id; Exp_V : Vertex_Id); -- Vertify that the destination vertex of edge E of grah G is Exp_V. R is -- the calling routine. procedure Check_Distinct_Components (R : String; Comp_1 : Component_Id; Comp_2 : Component_Id); -- Verify that components Comp_1 and Comp_2 are distinct (not the same) procedure Check_Has_Component (R : String; G : Instance; G_Name : String; Comp : Component_Id); -- Verify that graph G with name G_Name contains component Comp. R is the -- calling routine. procedure Check_Has_Edge (R : String; G : Instance; E : Edge_Id); -- Verify that graph G contains edge E. R is the calling routine. procedure Check_Has_Vertex (R : String; G : Instance; V : Vertex_Id); -- Verify that graph G contains vertex V. R is the calling routine. procedure Check_No_Component (R : String; G : Instance; V : Vertex_Id); -- Verify that vertex V does not belong to some component. R is the calling -- routine. procedure Check_No_Component (R : String; G : Instance; G_Name : String; Comp : Component_Id); -- Verify that graph G with name G_Name does not contain component Comp. R -- is the calling routine. procedure Check_No_Edge (R : String; G : Instance; E : Edge_Id); -- Verify that graph G does not contain edge E. R is the calling routine. procedure Check_No_Vertex (R : String; G : Instance; V : Vertex_Id); -- Verify that graph G does not contain vertex V. R is the calling routine. procedure Check_Number_Of_Components (R : String; G : Instance; Exp_Num : Natural); -- Verify that graph G has exactly Exp_Num components. R is the calling -- routine. procedure Check_Number_Of_Edges (R : String; G : Instance; Exp_Num : Natural); -- Verify that graph G has exactly Exp_Num edges. R is the calling routine. procedure Check_Number_Of_Vertices (R : String; G : Instance; Exp_Num : Natural); -- Verify that graph G has exactly Exp_Num vertices. R is the calling -- routine. procedure Check_Outgoing_Edge_Iterator (R : String; G : Instance; V : Vertex_Id; Set : ES.Instance); -- Verify that all outgoing edges of vertex V of graph G can be iterated -- and appear in set Set. R is the calling routine. procedure Check_Source_Vertex (R : String; G : Instance; E : Edge_Id; Exp_V : Vertex_Id); -- Vertify that the source vertex of edge E of grah G is Exp_V. R is the -- calling routine. procedure Check_Vertex_Iterator (R : String; G : Instance; Comp : Component_Id; Set : VS.Instance); -- Verify that all vertices of component Comp of graph G can be iterated -- and appear in set Set. R is the calling routine. function Create_And_Populate return Instance; -- Create a brand new graph (see body for the shape of the graph) procedure Error (R : String; Msg : String); -- Output an error message with text Msg within the context of routine R procedure Test_Add_Edge; -- Verify the semantics of routine Add_Edge procedure Test_Add_Vertex; -- Verify the semantics of routine Add_Vertex procedure Test_All_Edge_Iterator; -- Verify the semantics of All_Edge_Iterator procedure Test_All_Vertex_Iterator; -- Verify the semantics of All_Vertex_Iterator procedure Test_Component; -- Verify the semantics of routine Component procedure Test_Component_Iterator; -- Verify the semantics of Component_Iterator procedure Test_Contains_Component; -- Verify the semantics of routine Contains_Component procedure Test_Contains_Edge; -- Verify the semantics of routine Contains_Edge procedure Test_Contains_Vertex; -- Verify the semantics of routine Contains_Vertex procedure Test_Delete_Edge; -- Verify the semantics of routine Delete_Edge procedure Test_Destination_Vertex; -- Verify the semantics of routine Destination_Vertex procedure Test_Find_Components; -- Verify the semantics of routine Find_Components procedure Test_Is_Empty; -- Verify the semantics of routine Is_Empty procedure Test_Number_Of_Components; -- Verify the semantics of routine Number_Of_Components procedure Test_Number_Of_Edges; -- Verify the semantics of routine Number_Of_Edges procedure Test_Number_Of_Vertices; -- Verify the semantics of routine Number_Of_Vertices procedure Test_Outgoing_Edge_Iterator; -- Verify the semantics of Outgoing_Edge_Iterator procedure Test_Present; -- Verify the semantics of routine Present procedure Test_Source_Vertex; -- Verify the semantics of routine Source_Vertex procedure Test_Vertex_Iterator; -- Verify the semantics of Vertex_Iterator; procedure Unexpected_Exception (R : String); -- Output an error message concerning an unexpected exception within -- routine R. -------------------------------- -- Check_Belongs_To_Component -- -------------------------------- procedure Check_Belongs_To_Component (R : String; G : Instance; V : Vertex_Id; Exp_Comp : Component_Id) is Act_Comp : constant Component_Id := Component (G, V); begin if Act_Comp /= Exp_Comp then Error (R, "inconsistent component for vertex " & V'Img); Error (R, " expected: " & Exp_Comp'Img); Error (R, " got : " & Act_Comp'Img); end if; end Check_Belongs_To_Component; ------------------------------------- -- Check_Belongs_To_Some_Component -- ------------------------------------- procedure Check_Belongs_To_Some_Component (R : String; G : Instance; V : Vertex_Id) is begin if not Present (Component (G, V)) then Error (R, "vertex " & V'Img & " does not belong to a component"); end if; end Check_Belongs_To_Some_Component; ------------------------------ -- Check_Destination_Vertex -- ------------------------------ procedure Check_Destination_Vertex (R : String; G : Instance; E : Edge_Id; Exp_V : Vertex_Id) is Act_V : constant Vertex_Id := Destination_Vertex (G, E); begin if Act_V /= Exp_V then Error (R, "inconsistent destination vertex for edge " & E'Img); Error (R, " expected: " & Exp_V'Img); Error (R, " got : " & Act_V'Img); end if; end Check_Destination_Vertex; ------------------------------- -- Check_Distinct_Components -- ------------------------------- procedure Check_Distinct_Components (R : String; Comp_1 : Component_Id; Comp_2 : Component_Id) is begin if Comp_1 = Comp_2 then Error (R, "components are not distinct"); end if; end Check_Distinct_Components; ------------------------- -- Check_Has_Component -- ------------------------- procedure Check_Has_Component (R : String; G : Instance; G_Name : String; Comp : Component_Id) is begin if not Contains_Component (G, Comp) then Error (R, "graph " & G_Name & " lacks component"); end if; end Check_Has_Component; -------------------- -- Check_Has_Edge -- -------------------- procedure Check_Has_Edge (R : String; G : Instance; E : Edge_Id) is begin if not Contains_Edge (G, E) then Error (R, "graph lacks edge " & E'Img); end if; end Check_Has_Edge; ---------------------- -- Check_Has_Vertex -- ---------------------- procedure Check_Has_Vertex (R : String; G : Instance; V : Vertex_Id) is begin if not Contains_Vertex (G, V) then Error (R, "graph lacks vertex " & V'Img); end if; end Check_Has_Vertex; ------------------------ -- Check_No_Component -- ------------------------ procedure Check_No_Component (R : String; G : Instance; V : Vertex_Id) is begin if Present (Component (G, V)) then Error (R, "vertex " & V'Img & " belongs to a component"); end if; end Check_No_Component; procedure Check_No_Component (R : String; G : Instance; G_Name : String; Comp : Component_Id) is begin if Contains_Component (G, Comp) then Error (R, "graph " & G_Name & " contains component"); end if; end Check_No_Component; ------------------- -- Check_No_Edge -- ------------------- procedure Check_No_Edge (R : String; G : Instance; E : Edge_Id) is begin if Contains_Edge (G, E) then Error (R, "graph contains edge " & E'Img); end if; end Check_No_Edge; --------------------- -- Check_No_Vertex -- --------------------- procedure Check_No_Vertex (R : String; G : Instance; V : Vertex_Id) is begin if Contains_Vertex (G, V) then Error (R, "graph contains vertex " & V'Img); end if; end Check_No_Vertex; -------------------------------- -- Check_Number_Of_Components -- -------------------------------- procedure Check_Number_Of_Components (R : String; G : Instance; Exp_Num : Natural) is Act_Num : constant Natural := Number_Of_Components (G); begin if Act_Num /= Exp_Num then Error (R, "inconsistent number of components"); Error (R, " expected: " & Exp_Num'Img); Error (R, " got : " & Act_Num'Img); end if; end Check_Number_Of_Components; --------------------------- -- Check_Number_Of_Edges -- --------------------------- procedure Check_Number_Of_Edges (R : String; G : Instance; Exp_Num : Natural) is Act_Num : constant Natural := Number_Of_Edges (G); begin if Act_Num /= Exp_Num then Error (R, "inconsistent number of edges"); Error (R, " expected: " & Exp_Num'Img); Error (R, " got : " & Act_Num'Img); end if; end Check_Number_Of_Edges; ------------------------------ -- Check_Number_Of_Vertices -- ------------------------------ procedure Check_Number_Of_Vertices (R : String; G : Instance; Exp_Num : Natural) is Act_Num : constant Natural := Number_Of_Vertices (G); begin if Act_Num /= Exp_Num then Error (R, "inconsistent number of vertices"); Error (R, " expected: " & Exp_Num'Img); Error (R, " got : " & Act_Num'Img); end if; end Check_Number_Of_Vertices; ---------------------------------- -- Check_Outgoing_Edge_Iterator -- ---------------------------------- procedure Check_Outgoing_Edge_Iterator (R : String; G : Instance; V : Vertex_Id; Set : ES.Instance) is E : Edge_Id; Out_E_Iter : Outgoing_Edge_Iterator; begin -- Iterate over all outgoing edges of vertex V while removing edges seen -- from the set. Out_E_Iter := Iterate_Outgoing_Edges (G, V); while Has_Next (Out_E_Iter) loop Next (Out_E_Iter, E); if ES.Contains (Set, E) then ES.Delete (Set, E); else Error (R, "outgoing edge " & E'Img & " is not iterated"); end if; end loop; -- At this point the set of edges should be empty if not ES.Is_Empty (Set) then Error (R, "not all outgoing edges were iterated"); end if; end Check_Outgoing_Edge_Iterator; ------------------------- -- Check_Source_Vertex -- ------------------------- procedure Check_Source_Vertex (R : String; G : Instance; E : Edge_Id; Exp_V : Vertex_Id) is Act_V : constant Vertex_Id := Source_Vertex (G, E); begin if Act_V /= Exp_V then Error (R, "inconsistent source vertex"); Error (R, " expected: " & Exp_V'Img); Error (R, " got : " & Act_V'Img); end if; end Check_Source_Vertex; --------------------------- -- Check_Vertex_Iterator -- --------------------------- procedure Check_Vertex_Iterator (R : String; G : Instance; Comp : Component_Id; Set : VS.Instance) is V : Vertex_Id; V_Iter : Vertex_Iterator; begin -- Iterate over all vertices of component Comp while removing vertices -- seen from the set. V_Iter := Iterate_Vertices (G, Comp); while Has_Next (V_Iter) loop Next (V_Iter, V); if VS.Contains (Set, V) then VS.Delete (Set, V); else Error (R, "vertex " & V'Img & " is not iterated"); end if; end loop; -- At this point the set of vertices should be empty if not VS.Is_Empty (Set) then Error (R, "not all vertices were iterated"); end if; end Check_Vertex_Iterator; ------------------------- -- Create_And_Populate -- ------------------------- function Create_And_Populate return Instance is G : constant Instance := Create (Initial_Vertices => Vertex_Id'Size, Initial_Edges => Edge_Id'Size); begin -- 9 8 1 2 -- G <------ F <------ A ------> B -------> C -- | ^ | | ^ ^ -- +------------------+ | +-------------------+ -- 10 | | 3 -- 4 | 5 | -- v | -- H D ---------+ -- | ^ -- | | -- 6 | | 7 -- | | -- v | -- E -- -- Components: -- -- [A, F, G] -- [B] -- [C] -- [D, E] -- [H] Add_Vertex (G, VA); Add_Vertex (G, VB); Add_Vertex (G, VC); Add_Vertex (G, VD); Add_Vertex (G, VE); Add_Vertex (G, VF); Add_Vertex (G, VG); Add_Vertex (G, VH); Add_Edge (G, E1, Source => VA, Destination => VB); Add_Edge (G, E2, Source => VB, Destination => VC); Add_Edge (G, E3, Source => VA, Destination => VC); Add_Edge (G, E4, Source => VA, Destination => VD); Add_Edge (G, E5, Source => VD, Destination => VB); Add_Edge (G, E6, Source => VD, Destination => VE); Add_Edge (G, E7, Source => VE, Destination => VD); Add_Edge (G, E8, Source => VA, Destination => VF); Add_Edge (G, E9, Source => VF, Destination => VG); Add_Edge (G, E10, Source => VG, Destination => VA); return G; end Create_And_Populate; ----------- -- Error -- ----------- procedure Error (R : String; Msg : String) is begin Put_Line ("ERROR: " & R & ": " & Msg); end Error; --------------- -- Hash_Edge -- --------------- function Hash_Edge (E : Edge_Id) return Bucket_Range_Type is begin return Bucket_Range_Type (Edge_Id'Pos (E)); end Hash_Edge; ----------------- -- Hash_Vertex -- ----------------- function Hash_Vertex (V : Vertex_Id) return Bucket_Range_Type is begin return Bucket_Range_Type (Vertex_Id'Pos (V)); end Hash_Vertex; ------------------- -- Test_Add_Edge -- ------------------- procedure Test_Add_Edge is R : constant String := "Test_Add_Edge"; E : Edge_Id; G : Instance := Create_And_Populate; All_E_Iter : All_Edge_Iterator; Out_E_Iter : Outgoing_Edge_Iterator; begin -- Try to add the same edge twice begin Add_Edge (G, E1, VB, VH); Error (R, "duplicate edge not detected"); exception when Duplicate_Edge => null; when others => Unexpected_Exception (R); end; -- Try to add an edge with a bogus source begin Add_Edge (G, E97, Source => VX, Destination => VC); Error (R, "missing vertex not detected"); exception when Missing_Vertex => null; when others => Unexpected_Exception (R); end; -- Try to add an edge with a bogus destination begin Add_Edge (G, E97, Source => VF, Destination => VY); Error (R, "missing vertex not detected"); exception when Missing_Vertex => null; when others => Unexpected_Exception (R); end; -- Delete edge E1 between vertices VA and VB begin Delete_Edge (G, E1); exception when others => Unexpected_Exception (R); end; -- Try to re-add edge E1 begin Add_Edge (G, E1, Source => VA, Destination => VB); exception when others => Unexpected_Exception (R); end; -- Lock all edges in the graph All_E_Iter := Iterate_All_Edges (G); -- Try to add an edge given that all edges are locked begin Add_Edge (G, E97, Source => VG, Destination => VH); Error (R, "all edges not locked"); exception when Iterated => null; when others => Unexpected_Exception (R); end; -- Unlock all edges by iterating over them while Has_Next (All_E_Iter) loop Next (All_E_Iter, E); end loop; -- Lock all outgoing edges of vertex VD Out_E_Iter := Iterate_Outgoing_Edges (G, VD); -- Try to add an edge with source VD given that all edges of VD are -- locked. begin Add_Edge (G, E97, Source => VD, Destination => VG); Error (R, "outgoing edges of VD not locked"); exception when Iterated => null; when others => Unexpected_Exception (R); end; -- Unlock the edges of vertex VD by iterating over them while Has_Next (Out_E_Iter) loop Next (Out_E_Iter, E); end loop; Destroy (G); end Test_Add_Edge; --------------------- -- Test_Add_Vertex -- --------------------- procedure Test_Add_Vertex is R : constant String := "Test_Add_Vertex"; G : Instance := Create_And_Populate; V : Vertex_Id; All_V_Iter : All_Vertex_Iterator; begin -- Try to add the same vertex twice begin Add_Vertex (G, VD); Error (R, "duplicate vertex not detected"); exception when Duplicate_Vertex => null; when others => Unexpected_Exception (R); end; -- Lock all vertices in the graph All_V_Iter := Iterate_All_Vertices (G); -- Try to add a vertex given that all vertices are locked begin Add_Vertex (G, VZ); Error (R, "all vertices not locked"); exception when Iterated => null; when others => Unexpected_Exception (R); end; -- Unlock all vertices by iterating over them while Has_Next (All_V_Iter) loop Next (All_V_Iter, V); end loop; Destroy (G); end Test_Add_Vertex; ---------------------------- -- Test_All_Edge_Iterator -- ---------------------------- procedure Test_All_Edge_Iterator is R : constant String := "Test_All_Edge_Iterator"; E : Edge_Id; G : Instance := Create_And_Populate; All_E_Iter : All_Edge_Iterator; All_Edges : ES.Instance; begin -- Collect all expected edges in a set All_Edges := ES.Create (Number_Of_Edges (G)); for Curr_E in E1 .. E10 loop ES.Insert (All_Edges, Curr_E); end loop; -- Iterate over all edges while removing encountered edges from the set All_E_Iter := Iterate_All_Edges (G); while Has_Next (All_E_Iter) loop Next (All_E_Iter, E); if ES.Contains (All_Edges, E) then ES.Delete (All_Edges, E); else Error (R, "edge " & E'Img & " is not iterated"); end if; end loop; -- At this point the set of edges should be empty if not ES.Is_Empty (All_Edges) then Error (R, "not all edges were iterated"); end if; ES.Destroy (All_Edges); Destroy (G); end Test_All_Edge_Iterator; ------------------------------ -- Test_All_Vertex_Iterator -- ------------------------------ procedure Test_All_Vertex_Iterator is R : constant String := "Test_All_Vertex_Iterator"; G : Instance := Create_And_Populate; V : Vertex_Id; All_V_Iter : All_Vertex_Iterator; All_Vertices : VS.Instance; begin -- Collect all expected vertices in a set All_Vertices := VS.Create (Number_Of_Vertices (G)); for Curr_V in VA .. VH loop VS.Insert (All_Vertices, Curr_V); end loop; -- Iterate over all vertices while removing encountered vertices from -- the set. All_V_Iter := Iterate_All_Vertices (G); while Has_Next (All_V_Iter) loop Next (All_V_Iter, V); if VS.Contains (All_Vertices, V) then VS.Delete (All_Vertices, V); else Error (R, "vertex " & V'Img & " is not iterated"); end if; end loop; -- At this point the set of vertices should be empty if not VS.Is_Empty (All_Vertices) then Error (R, "not all vertices were iterated"); end if; VS.Destroy (All_Vertices); Destroy (G); end Test_All_Vertex_Iterator; -------------------- -- Test_Component -- -------------------- procedure Test_Component is R : constant String := "Test_Component"; G : Instance := Create (Initial_Vertices => 3, Initial_Edges => 2); begin -- E1 -- -----> -- VA VB VC -- <----- -- E2 -- -- Components: -- -- [VA, VB] -- [VC] Add_Vertex (G, VA); Add_Vertex (G, VB); Add_Vertex (G, VC); Add_Edge (G, E1, Source => VA, Destination => VB); Add_Edge (G, E2, Source => VB, Destination => VA); -- None of the vertices should belong to a component Check_No_Component (R, G, VA); Check_No_Component (R, G, VB); Check_No_Component (R, G, VC); -- Find the strongly connected components in the graph Find_Components (G); -- Vertices should belong to a component Check_Belongs_To_Some_Component (R, G, VA); Check_Belongs_To_Some_Component (R, G, VB); Check_Belongs_To_Some_Component (R, G, VC); Destroy (G); end Test_Component; ----------------------------- -- Test_Component_Iterator -- ----------------------------- procedure Test_Component_Iterator is R : constant String := "Test_Component_Iterator"; G : Instance := Create_And_Populate; Comp : Component_Id; Comp_Count : Natural; Comp_Iter : Component_Iterator; begin Find_Components (G); Check_Number_Of_Components (R, G, 5); Comp_Count := Number_Of_Components (G); -- Iterate over all components while decrementing their number Comp_Iter := Iterate_Components (G); while Has_Next (Comp_Iter) loop Next (Comp_Iter, Comp); Comp_Count := Comp_Count - 1; end loop; -- At this point all components should have been accounted for if Comp_Count /= 0 then Error (R, "not all components were iterated"); end if; Destroy (G); end Test_Component_Iterator; ----------------------------- -- Test_Contains_Component -- ----------------------------- procedure Test_Contains_Component is R : constant String := "Test_Contains_Component"; G1 : Instance := Create (Initial_Vertices => 2, Initial_Edges => 2); G2 : Instance := Create (Initial_Vertices => 2, Initial_Edges => 2); begin -- E1 -- -----> -- VA VB -- <----- -- E2 -- -- Components: -- -- [VA, VB] Add_Vertex (G1, VA); Add_Vertex (G1, VB); Add_Edge (G1, E1, Source => VA, Destination => VB); Add_Edge (G1, E2, Source => VB, Destination => VA); -- E97 -- -----> -- VX VY -- <----- -- E98 -- -- Components: -- -- [VX, VY] Add_Vertex (G2, VX); Add_Vertex (G2, VY); Add_Edge (G2, E97, Source => VX, Destination => VY); Add_Edge (G2, E98, Source => VY, Destination => VX); -- Find the strongly connected components in both graphs Find_Components (G1); Find_Components (G2); -- Vertices should belong to a component Check_Belongs_To_Some_Component (R, G1, VA); Check_Belongs_To_Some_Component (R, G1, VB); Check_Belongs_To_Some_Component (R, G2, VX); Check_Belongs_To_Some_Component (R, G2, VY); -- Verify that each graph contains the correct component Check_Has_Component (R, G1, "G1", Component (G1, VA)); Check_Has_Component (R, G1, "G1", Component (G1, VB)); Check_Has_Component (R, G2, "G2", Component (G2, VX)); Check_Has_Component (R, G2, "G2", Component (G2, VY)); -- Verify that each graph does not contain components from the other -- graph. Check_No_Component (R, G1, "G1", Component (G2, VX)); Check_No_Component (R, G1, "G1", Component (G2, VY)); Check_No_Component (R, G2, "G2", Component (G1, VA)); Check_No_Component (R, G2, "G2", Component (G1, VB)); Destroy (G1); Destroy (G2); end Test_Contains_Component; ------------------------ -- Test_Contains_Edge -- ------------------------ procedure Test_Contains_Edge is R : constant String := "Test_Contains_Edge"; G : Instance := Create_And_Populate; begin -- Verify that all edges in the range E1 .. E10 exist for Curr_E in E1 .. E10 loop Check_Has_Edge (R, G, Curr_E); end loop; -- Verify that no extra edges are present for Curr_E in E97 .. E99 loop Check_No_Edge (R, G, Curr_E); end loop; -- Add new edges E97, E98, and E99 Add_Edge (G, E97, Source => VG, Destination => VF); Add_Edge (G, E98, Source => VH, Destination => VE); Add_Edge (G, E99, Source => VD, Destination => VC); -- Verify that all edges in the range E1 .. E99 exist for Curr_E in E1 .. E99 loop Check_Has_Edge (R, G, Curr_E); end loop; -- Delete each edge that corresponds to an even position in Edge_Id for Curr_E in E1 .. E99 loop if Edge_Id'Pos (Curr_E) mod 2 = 0 then Delete_Edge (G, Curr_E); end if; end loop; -- Verify that all "even" edges are missing, and all "odd" edges are -- present. for Curr_E in E1 .. E99 loop if Edge_Id'Pos (Curr_E) mod 2 = 0 then Check_No_Edge (R, G, Curr_E); else Check_Has_Edge (R, G, Curr_E); end if; end loop; Destroy (G); end Test_Contains_Edge; -------------------------- -- Test_Contains_Vertex -- -------------------------- procedure Test_Contains_Vertex is R : constant String := "Test_Contains_Vertex"; G : Instance := Create_And_Populate; begin -- Verify that all vertices in the range VA .. VH exist for Curr_V in VA .. VH loop Check_Has_Vertex (R, G, Curr_V); end loop; -- Verify that no extra vertices are present for Curr_V in VX .. VZ loop Check_No_Vertex (R, G, Curr_V); end loop; -- Add new vertices VX, VY, and VZ Add_Vertex (G, VX); Add_Vertex (G, VY); Add_Vertex (G, VZ); -- Verify that all vertices in the range VA .. VZ exist for Curr_V in VA .. VZ loop Check_Has_Vertex (R, G, Curr_V); end loop; Destroy (G); end Test_Contains_Vertex; ---------------------- -- Test_Delete_Edge -- ---------------------- procedure Test_Delete_Edge is R : constant String := "Test_Delete_Edge"; E : Edge_Id; G : Instance := Create_And_Populate; V : Vertex_Id; All_E_Iter : All_Edge_Iterator; All_V_Iter : All_Vertex_Iterator; Out_E_Iter : Outgoing_Edge_Iterator; begin -- Try to delete a bogus edge begin Delete_Edge (G, E97); Error (R, "missing vertex deleted"); exception when Missing_Edge => null; when others => Unexpected_Exception (R); end; -- Delete edge E1 between vertices VA and VB begin Delete_Edge (G, E1); exception when others => Unexpected_Exception (R); end; -- Verify that edge E1 is gone from all edges in the graph All_E_Iter := Iterate_All_Edges (G); while Has_Next (All_E_Iter) loop Next (All_E_Iter, E); if E = E1 then Error (R, "edge " & E'Img & " not removed from all edges"); end if; end loop; -- Verify that edge E1 is gone from the outgoing edges of vertex VA Out_E_Iter := Iterate_Outgoing_Edges (G, VA); while Has_Next (Out_E_Iter) loop Next (Out_E_Iter, E); if E = E1 then Error (R, "edge " & E'Img & "not removed from outgoing edges of VA"); end if; end loop; -- Delete all edges in the range E2 .. E10 for Curr_E in E2 .. E10 loop Delete_Edge (G, Curr_E); end loop; -- Verify that all edges are gone from the graph All_E_Iter := Iterate_All_Edges (G); while Has_Next (All_E_Iter) loop Next (All_E_Iter, E); Error (R, "edge " & E'Img & " not removed from all edges"); end loop; -- Verify that all edges are gone from the respective source vertices All_V_Iter := Iterate_All_Vertices (G); while Has_Next (All_V_Iter) loop Next (All_V_Iter, V); Out_E_Iter := Iterate_Outgoing_Edges (G, V); while Has_Next (Out_E_Iter) loop Next (Out_E_Iter, E); Error (R, "edge " & E'Img & " not removed from vertex " & V'Img); end loop; end loop; Destroy (G); end Test_Delete_Edge; ----------------------------- -- Test_Destination_Vertex -- ----------------------------- procedure Test_Destination_Vertex is R : constant String := "Test_Destination_Vertex"; G : Instance := Create_And_Populate; begin -- Verify the destination vertices of all edges in the graph Check_Destination_Vertex (R, G, E1, VB); Check_Destination_Vertex (R, G, E2, VC); Check_Destination_Vertex (R, G, E3, VC); Check_Destination_Vertex (R, G, E4, VD); Check_Destination_Vertex (R, G, E5, VB); Check_Destination_Vertex (R, G, E6, VE); Check_Destination_Vertex (R, G, E7, VD); Check_Destination_Vertex (R, G, E8, VF); Check_Destination_Vertex (R, G, E9, VG); Check_Destination_Vertex (R, G, E10, VA); Destroy (G); end Test_Destination_Vertex; -------------------------- -- Test_Find_Components -- -------------------------- procedure Test_Find_Components is R : constant String := "Test_Find_Components"; G : Instance := Create_And_Populate; Comp_1 : Component_Id; -- [A, F, G] Comp_2 : Component_Id; -- [B] Comp_3 : Component_Id; -- [C] Comp_4 : Component_Id; -- [D, E] Comp_5 : Component_Id; -- [H] begin Find_Components (G); -- Vertices should belong to a component Check_Belongs_To_Some_Component (R, G, VA); Check_Belongs_To_Some_Component (R, G, VB); Check_Belongs_To_Some_Component (R, G, VC); Check_Belongs_To_Some_Component (R, G, VD); Check_Belongs_To_Some_Component (R, G, VH); -- Extract the ids of the components from the first vertices in each -- component. Comp_1 := Component (G, VA); Comp_2 := Component (G, VB); Comp_3 := Component (G, VC); Comp_4 := Component (G, VD); Comp_5 := Component (G, VH); -- Verify that the components are distinct Check_Distinct_Components (R, Comp_1, Comp_2); Check_Distinct_Components (R, Comp_1, Comp_3); Check_Distinct_Components (R, Comp_1, Comp_4); Check_Distinct_Components (R, Comp_1, Comp_5); Check_Distinct_Components (R, Comp_2, Comp_3); Check_Distinct_Components (R, Comp_2, Comp_4); Check_Distinct_Components (R, Comp_2, Comp_5); Check_Distinct_Components (R, Comp_3, Comp_4); Check_Distinct_Components (R, Comp_3, Comp_5); Check_Distinct_Components (R, Comp_4, Comp_5); -- Verify that the remaining nodes belong to the proper component Check_Belongs_To_Component (R, G, VF, Comp_1); Check_Belongs_To_Component (R, G, VG, Comp_1); Check_Belongs_To_Component (R, G, VE, Comp_4); Destroy (G); end Test_Find_Components; ------------------- -- Test_Is_Empty -- ------------------- procedure Test_Is_Empty is R : constant String := "Test_Is_Empty"; G : Instance := Create (Initial_Vertices => 3, Initial_Edges => 2); begin -- Verify that a graph without vertices and edges is empty if not Is_Empty (G) then Error (R, "graph is empty"); end if; -- Add vertices Add_Vertex (G, VA); Add_Vertex (G, VB); -- Verify that a graph with vertices and no edges is not empty if Is_Empty (G) then Error (R, "graph is not empty"); end if; -- Add edges Add_Edge (G, E1, Source => VA, Destination => VB); -- Verify that a graph with vertices and edges is not empty if Is_Empty (G) then Error (R, "graph is not empty"); end if; Destroy (G); end Test_Is_Empty; ------------------------------- -- Test_Number_Of_Components -- ------------------------------- procedure Test_Number_Of_Components is R : constant String := "Test_Number_Of_Components"; G : Instance := Create (Initial_Vertices => 3, Initial_Edges => 2); begin -- Verify that an empty graph has exactly 0 components Check_Number_Of_Components (R, G, 0); -- E1 -- -----> -- VA VB VC -- <----- -- E2 -- -- Components: -- -- [VA, VB] -- [VC] Add_Vertex (G, VA); Add_Vertex (G, VB); Add_Vertex (G, VC); Add_Edge (G, E1, Source => VA, Destination => VB); Add_Edge (G, E2, Source => VB, Destination => VA); -- Verify that the graph has exact 0 components even though it contains -- vertices and edges. Check_Number_Of_Components (R, G, 0); Find_Components (G); -- Verify that the graph has exactly 2 components Check_Number_Of_Components (R, G, 2); Destroy (G); end Test_Number_Of_Components; -------------------------- -- Test_Number_Of_Edges -- -------------------------- procedure Test_Number_Of_Edges is R : constant String := "Test_Number_Of_Edges"; G : Instance := Create_And_Populate; begin -- Verify that the graph has exactly 10 edges Check_Number_Of_Edges (R, G, 10); -- Delete two edges Delete_Edge (G, E1); Delete_Edge (G, E2); -- Verify that the graph has exactly 8 edges Check_Number_Of_Edges (R, G, 8); -- Delete the remaining edge for Curr_E in E3 .. E10 loop Delete_Edge (G, Curr_E); end loop; -- Verify that the graph has exactly 0 edges Check_Number_Of_Edges (R, G, 0); -- Add two edges Add_Edge (G, E1, Source => VF, Destination => VA); Add_Edge (G, E2, Source => VC, Destination => VH); -- Verify that the graph has exactly 2 edges Check_Number_Of_Edges (R, G, 2); Destroy (G); end Test_Number_Of_Edges; ----------------------------- -- Test_Number_Of_Vertices -- ----------------------------- procedure Test_Number_Of_Vertices is R : constant String := "Test_Number_Of_Vertices"; G : Instance := Create (Initial_Vertices => 4, Initial_Edges => 12); begin -- Verify that an empty graph has exactly 0 vertices Check_Number_Of_Vertices (R, G, 0); -- Add three vertices Add_Vertex (G, VC); Add_Vertex (G, VG); Add_Vertex (G, VX); -- Verify that the graph has exactly 3 vertices Check_Number_Of_Vertices (R, G, 3); -- Add one edge Add_Edge (G, E8, Source => VX, Destination => VG); -- Verify that the graph has exactly 3 vertices Check_Number_Of_Vertices (R, G, 3); Destroy (G); end Test_Number_Of_Vertices; --------------------------------- -- Test_Outgoing_Edge_Iterator -- --------------------------------- procedure Test_Outgoing_Edge_Iterator is R : constant String := "Test_Outgoing_Edge_Iterator"; G : Instance := Create_And_Populate; Set : ES.Instance; begin Set := ES.Create (4); ES.Insert (Set, E1); ES.Insert (Set, E3); ES.Insert (Set, E4); ES.Insert (Set, E8); Check_Outgoing_Edge_Iterator (R, G, VA, Set); ES.Insert (Set, E2); Check_Outgoing_Edge_Iterator (R, G, VB, Set); Check_Outgoing_Edge_Iterator (R, G, VC, Set); ES.Insert (Set, E5); ES.Insert (Set, E6); Check_Outgoing_Edge_Iterator (R, G, VD, Set); ES.Insert (Set, E7); Check_Outgoing_Edge_Iterator (R, G, VE, Set); ES.Insert (Set, E9); Check_Outgoing_Edge_Iterator (R, G, VF, Set); ES.Insert (Set, E10); Check_Outgoing_Edge_Iterator (R, G, VG, Set); Check_Outgoing_Edge_Iterator (R, G, VH, Set); ES.Destroy (Set); Destroy (G); end Test_Outgoing_Edge_Iterator; ------------------ -- Test_Present -- ------------------ procedure Test_Present is R : constant String := "Test_Present"; G : Instance := Nil; begin -- Verify that a non-existent graph is not present if Present (G) then Error (R, "graph is not present"); end if; G := Create_And_Populate; -- Verify that an existing graph is present if not Present (G) then Error (R, "graph is present"); end if; Destroy (G); -- Verify that a destroyed graph is not present if Present (G) then Error (R, "graph is not present"); end if; end Test_Present; ------------------------ -- Test_Source_Vertex -- ------------------------ procedure Test_Source_Vertex is R : constant String := "Test_Source_Vertex"; G : Instance := Create_And_Populate; begin -- Verify the source vertices of all edges in the graph Check_Source_Vertex (R, G, E1, VA); Check_Source_Vertex (R, G, E2, VB); Check_Source_Vertex (R, G, E3, VA); Check_Source_Vertex (R, G, E4, VA); Check_Source_Vertex (R, G, E5, VD); Check_Source_Vertex (R, G, E6, VD); Check_Source_Vertex (R, G, E7, VE); Check_Source_Vertex (R, G, E8, VA); Check_Source_Vertex (R, G, E9, VF); Check_Source_Vertex (R, G, E10, VG); Destroy (G); end Test_Source_Vertex; -------------------------- -- Test_Vertex_Iterator -- -------------------------- procedure Test_Vertex_Iterator is R : constant String := "Test_Vertex_Iterator"; G : Instance := Create_And_Populate; Set : VS.Instance; begin Find_Components (G); Set := VS.Create (3); VS.Insert (Set, VA); VS.Insert (Set, VF); VS.Insert (Set, VG); Check_Vertex_Iterator (R, G, Component (G, VA), Set); VS.Insert (Set, VB); Check_Vertex_Iterator (R, G, Component (G, VB), Set); VS.Insert (Set, VC); Check_Vertex_Iterator (R, G, Component (G, VC), Set); VS.Insert (Set, VD); VS.Insert (Set, VE); Check_Vertex_Iterator (R, G, Component (G, VD), Set); VS.Insert (Set, VH); Check_Vertex_Iterator (R, G, Component (G, VH), Set); VS.Destroy (Set); Destroy (G); end Test_Vertex_Iterator; -------------------------- -- Unexpected_Exception -- -------------------------- procedure Unexpected_Exception (R : String) is begin Error (R, "unexpected exception"); end Unexpected_Exception; -- Start of processing for Operations begin Test_Add_Edge; Test_Add_Vertex; Test_All_Edge_Iterator; Test_All_Vertex_Iterator; Test_Component; Test_Component_Iterator; Test_Contains_Component; Test_Contains_Edge; Test_Contains_Vertex; Test_Delete_Edge; Test_Destination_Vertex; Test_Find_Components; Test_Is_Empty; Test_Number_Of_Components; Test_Number_Of_Edges; Test_Number_Of_Vertices; Test_Outgoing_Edge_Iterator; Test_Present; Test_Source_Vertex; Test_Vertex_Iterator; end Operations; ---------------------------- -- Compilation and output -- ---------------------------- $ gnatmake -q operations.adb -largs -lgmem $ ./operations $ gnatmem operations > leaks.txt $ grep -c "non freed allocations" leaks.txt 0 2019-07-01 Hristian Kirtchev <kirtchev@adacore.com> gcc/ada/ * impunit.adb: Add GNAT.Graphs to list Non_Imp_File_Names_95. * Makefile.rtl, gcc-interface/Make-lang.in: Register unit GNAT.Graphs. * libgnat/g-dynhta.adb: Various minor cleanups (use Present rather than direct comparisons). (Delete): Reimplement to use Delete_Node. (Delete_Node): New routine. (Destroy_Bucket): Invoke the provided destructor. (Present): New routines. * libgnat/g-dynhta.ads: Add new generic formal Destroy_Value. Use better names for the components of iterators. * libgnat/g-graphs.adb, libgnat/g-graphs.ads: New unit. * libgnat/g-lists.adb: Various minor cleanups (use Present rather than direct comparisons). (Delete_Node): Invoke the provided destructor. (Present): New routine. * libgnat/g-lists.ads: Add new generic formal Destroy_Element. Use better names for the components of iterators. (Present): New routine. * libgnat/g-sets.adb, libgnat/g-sets.ads (Destroy, Preset, Reset): New routines. From-SVN: r272857
2018-12-11[Ada] Remove vxlink and vxaddr2line from this repositoryJerome Lambourg1-10/+0
Those tools need a dedicated repository as they're VxWorks specific and not related with the Ada front-end. 2018-12-11 Jerome Lambourg <lambourg@adacore.com> gcc/ada/ * vxaddr2line.adb, vxlink-bind.adb, vxlink-bind.ads, vxlink-link.adb, vxlink-link.ads, vxlink-main.adb, vxlink.adb, vxlink.ads: Remove. * gcc-interface/Make-lang.in, gcc-interface/Makefile.in: Remove bits for vxaddr2line. From-SVN: r266995
2018-10-17Run selftests for C++ as well as CDavid Malcolm1-0/+3
gcc/ChangeLog: * Makefile.in (SELFTEST_TARGETS): New. (selftest) Change from s-selftest-c to $(SELFTEST_TARGETS). (C_SELFTEST_FLAGS, C_SELFTEST_DEPS, s-selftest-c, selftest-c-gdb) (selftest-gdb, selftest-c-valgrind, selftest-valgrind): Move to c/Make-lang.in. (CPP_SELFTEST_FLAGS, CPP_SELFTEST_DEPS, s-selftest-c++) (selftest-c++-gdb, selftest-c++-valgrind): Move to cp/Make-lang.in. * configure: Regenerate. * configure.ac (selftest_languages): New. gcc/brig/ChangeLog: * Make-lang.in (selftest-brig): New. gcc/c/ChangeLog: * Make-lang.in (selftest-c): New. (C_SELFTEST_FLAGS, C_SELFTEST_DEPS, s-selftest-c, selftest-c-gdb) (selftest-gdb, selftest-c-valgrind, selftest-valgrind): Move here from gcc/Makefile.in. gcc/cp/ChangeLog: * Make-lang.in (selftest-c++): New. (CPP_SELFTEST_FLAGS, CPP_SELFTEST_DEPS, s-selftest-c++) (selftest-c++-gdb, selftest-c++-valgrind): Move here from gcc/Makefile.in. gcc/fortran/ChangeLog: * Make-lang.in (selftest-fortran): New. gcc/go/ChangeLog: * Make-lang.in (selftest-go): New. gcc/jit/ChangeLog: * Make-lang.in (selftest-jit): New. gcc/lto/ChangeLog: * Make-lang.in (selftest-lto): New. gcc/objc/ChangeLog: * Make-lang.in (selftest-objc): New. gcc/objcp/ChangeLog: * Make-lang.in (selftest-obj-c++): New. From-SVN: r265240