https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97283
Bug ID: 97283 Summary: GNAT rejects valid formal type definition with -gnat2020 Product: gcc Version: 10.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ada Assignee: unassigned at gcc dot gnu.org Reporter: colton.w.lewis at protonmail dot com Target Milestone: --- 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.