public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Initialize Compiler_State to avoid Constraint_Error
@ 2022-05-17  8:27 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-17  8:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: Etienne Servais

[-- Attachment #1: Type: text/plain, Size: 541 bytes --]

When building gnat1 with `-gnatVa` as we do locally, rules like: `gcc -c
-gnatyM79 <any adb file with lines longer than 79>` will throw a
constraint error as `lib.compiler_state` is initialized by par.adb, ie
after scanning. Therefore any error_msg thrown during scanning will
perform this uninitialized read (which raises a Constraint_Error when
the compiler was compiled with `-gnatVa`).

Initialize this flag to `Parsing`.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* lib.ads: initialize `Compiler_State` to `Parsing`.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 474 bytes --]

diff --git a/gcc/ada/lib.ads b/gcc/ada/lib.ads
--- a/gcc/ada/lib.ads
+++ b/gcc/ada/lib.ads
@@ -39,7 +39,7 @@ package Lib is
    --  Type to hold list of indirect references to unit number table
 
    type Compiler_State_Type is (Parsing, Analyzing);
-   Compiler_State : Compiler_State_Type;
+   Compiler_State : Compiler_State_Type := Parsing;
    --  Indicates current state of compilation. This is used to implement the
    --  function In_Extended_Main_Source_Unit.
 



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-17  8:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-17  8:27 [Ada] Initialize Compiler_State to avoid Constraint_Error Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).