Bug 97283 - GNAT rejects valid formal type definition with -gnat2020
Summary: GNAT rejects valid formal type definition with -gnat2020
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 10.2.1
: P3 normal
Target Milestone: 11.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-04 05:08 UTC by colton.w.lewis
Modified: 2020-10-04 08:01 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description colton.w.lewis 2020-10-04 05:08:48 UTC
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.1 20200723 (Red Hat 10.2.1-1) (GCC) 


I noticed this problem compiling wisi and ada-mode for Emacs. See the mailing list here: https://lists.nongnu.org/archive/html/ada-mode-users/2020-10/msg00002.html

This is the file with the error referenced in the mailing list: https://git.savannah.nongnu.org/cgit/ada-mode.git/tree/gen_run_wisi_lr_parse.ads?h=org.emacs.ada-mode

Other files in that project produce the same error. The exact gcc arguments are:

/usr/bin/gcc -c -x ada -gnatA -fstack-check -g -gnat2012 -gnatfqQ -gnatw.d -gnatwaBCeJL -gnatyO -gnaty3abcefhiklnOprtx -gnatyM120 -fstack-check -g -gnat2012 -gnatfqQ -gnatw.d -gnatwaBCeJL -gnatyO -O3 -fno-var-tracking-assignments -gnatyO -gnatn -gnat2020 -gnatec=/tmp/GNAT-TEMP-000003.TMP -gnatem=/tmp/GNAT-TEMP-000004.TMP /home/clewis/.emacs.d/elpa/ada-mode-7.1.4/ada_mode_wisi_lalr_parse.ads

I have not been able to create a smaller example to reproduce the error outside that project. However, at gcc/ada/par-ch12.adb:793, I found an obvious logic error that must be the culprit.

     if Token = Tok_With then

         if Ada_Version >= Ada_2020 and Token /= Tok_Private then
            --  Formal type has aspect specifications, parsed later.
            return Def_Node;

Token /= Tok_Private will always be true because Token = Tok_With and was not updated in between. This explains why the problem only happens with -gnat2020.
Comment 1 colton.w.lewis 2020-10-04 05:27:16 UTC
Never mind.

I just updated master and see the logic bug is fixed. Feel free to close this.
Comment 2 Arnaud Charlet 2020-10-04 08:01:36 UTC
Right, closing accordingly.