]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Improve error message when named number passed as global item
authorpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 11 Dec 2018 11:12:03 +0000 (11:12 +0000)
committerpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 11 Dec 2018 11:12:03 +0000 (11:12 +0000)
When a named number is used in Global/Depends contracts as global item,
the error message could be confusing to users new to Ada. Now the
message explains that named numbers are not objects.

For instance on the following illegal code snippet:

     $ gcc -c bad_global.ads

     1. package Bad_Global is
     2.
     3.    X : constant := 1;
     4.    Y : constant := 1.0;
     5.
     6.    procedure P with
     7.      Global => (Input => X,
                                 |
        >>> global item must denote object, state or current instance
            of concurrent type
        >>> named number "X" is not an object

     8.                 In_Out => Y);
                                  |
        >>> global item must denote object, state or current instance
            of concurrent type
        >>> named number "Y" is not an object

     9.
    10. end Bad_Global;

2018-12-11  Yannick Moy  <moy@adacore.com>

gcc/ada/

* sem_prag.adb (Analyze_Global_Item): Refine error message.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@267011 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/sem_prag.adb

index 0e317811171b2a65bb9c6894c60074b5d748724c..d38e966d08b2569732dc14955eef069e308f0485 100644 (file)
@@ -1,3 +1,7 @@
+2018-12-11  Yannick Moy  <moy@adacore.com>
+
+       * sem_prag.adb (Analyze_Global_Item): Refine error message.
+
 2018-12-11  Ed Schonberg  <schonberg@adacore.com>
 
        * exp_ch7.adb (Check_Unnesting_In_Declarations): Extend
index cda8629de68c6b04d4ee99f6d811b2011d6d5715..4d4b665ffc90cd12971f62b99a4c1070f858a088 100644 (file)
@@ -2282,6 +2282,12 @@ package body Sem_Prag is
                   SPARK_Msg_N
                     ("global item must denote object, state or current "
                      & "instance of concurrent type", Item);
+
+                  if Ekind (Item_Id) in Named_Kind then
+                     SPARK_Msg_NE
+                       ("\named number & is not an object", Item, Item);
+                  end if;
+
                   return;
                end if;