This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Fixes to handling of pragma argument identifiers


This patch has two parts, first it fixes the failure to diagnose some
cases of pragma arguments without an identifier occurring after a
pragma argument with an identifier, as shown in this example:

     1. package pragnoid is
     2.    procedure k;
     3.    pragma Import (Convention => C, Entity => K, "kkk");
                                                        |
        >>> pragma argument identifier required here (RM 2.8(4))

     4. end pragnoid;

(this was previously not diagnosed)

Second, it fixes two pragmas whose definition in the RM was flawed
because a name was provided for the first argument but not for
subsequent arguments. The following example matches the syntax
in the GNAT RM, but is illegal because of the RM 2.8(4) rule:

     1. package badpragma is
     2.     procedure Initialize;
     3.     procedure Initialize (Process_Blocking_IO : Boolean);
     4.     pragma Obsolescent
     5.       (Entity => Initialize,
     6.        "passing a parameter to Initialize is not supported anymore");
               |
        >>> pragma argument identifier required here (RM 2.8(4))

     7.     type R is new integer;
     8.     pragma Obsolescent
     9.       (Entity => R, "use RR in Ada 2005", Ada_05);
                            |
        >>> pragma argument identifier required here (RM 2.8(4))

    10.     pragma Obsolescent
    11.       ("use RR in Ada 2005", Ada_05);
    12. end badpragma;

To fix this a Message and Version parameter has been added to
pragma Obsolescent so that the following compiles without error
if -gnatc is used:

package okpragma is
    procedure Initialize;
    procedure Initialize (Process_Blocking_IO : Boolean);
    pragma Obsolescent
      (Entity  => Initialize,
       Message =>"passing a parameter to Initialize is not supported anymore");
    type R is new integer;
    pragma Obsolescent
     (Entity  => R,
      Message => "use RR in Ada 2005",
      Version => Ada_05);
    pragma Obsolescent
     ("use RR in Ada 2005", Ada_05);
end okpragma;

The patch also fixes pragma Check_Policy, which has the same problem
and for this pragma, the identifier Policy can now be used.

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

2009-04-08  Robert Dewar  <dewar@adacore.com>

	* g-socket.ads: Fix bad syntax in pragma Obsolescent

	* par-ch2.adb (Scan_Pragma_Argument_Association): Check for error of
	argument with no identifier following one that has an identifier. Was
	missed in some cases.

	* sem_prag.adb (Analyze_Pragma, case Check_Policy): Allow Policy
	identifier.
	(Analyze_Pragma, case Obsolescent): Allow Message, Version identifiers

	* snames.adb: Add Name_Policy

	* snames.ads: Add Name_Policy

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]