]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Improve message for misused implicitly-defined preprocessor symbol.
authorSteve Baird <baird@adacore.com>
Tue, 22 Oct 2024 23:20:27 +0000 (16:20 -0700)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 12 Nov 2024 13:00:50 +0000 (14:00 +0100)
If the -u option is specified, then otherwise-undefined preprocessor
symbols are implicitly defined to be False. If such an implicitly-defined
symbol is then incorrectly used in a context that requires an integer value,
the resulting error message should not incorrectly state that the symbol is
undefined.

gcc/ada/ChangeLog:

* prep.adb (Expression): Improve error message text when an
implicitly-defined Boolean-valued symbol is used in a context that
requires an integer value.

gcc/ada/prep.adb

index b9502fc7782c801d49456e72427b7496eb040b32..73fa8687afa70fedef3a46c59cf061a93cb11402 100644 (file)
@@ -489,7 +489,14 @@ package body Prep is
 
                            if Symbol1 = No_Symbol then
                               Error_Msg_Name_1 := Symbol_Name1;
-                              Error_Msg ("unknown symbol %", Symbol_Pos1);
+                              if Undefined_Symbols_Are_False then
+                                 Error_Msg
+                                   ("symbol % value is implicitly False"
+                                     & " and so not an integer",
+                                    Symbol_Pos1);
+                              else
+                                 Error_Msg ("unknown symbol %", Symbol_Pos1);
+                              end if;
                               Symbol_Value1 := No_String;
 
                            else
@@ -498,7 +505,7 @@ package body Prep is
                               if Data.Is_A_String then
                                  Error_Msg_Name_1 := Symbol_Name1;
                                  Error_Msg
-                                   ("symbol % value is not integer",
+                                   ("symbol % value is not an integer",
                                     Symbol_Pos1);
 
                               else