]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Initialize Compiler_State to avoid Constraint_Error
authorEtienne Servais <servais@adacore.com>
Tue, 26 Oct 2021 15:00:24 +0000 (17:00 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 17 May 2022 08:25:43 +0000 (08:25 +0000)
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`.

gcc/ada/

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

gcc/ada/lib.ads

index 4a799130a4bbb4978e9731971c6e02bf8a189d0b..e29d42af5705d1b4abd4b8b9d6ca60608bbfdcbc 100644 (file)
@@ -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.