diff options
author | Yannick Moy <moy@adacore.com> | 2015-02-05 13:55:03 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2015-02-05 14:55:03 +0100 |
commit | b21d8148ff0bed1e92ace175384ba4371999082d (patch) | |
tree | f860db127600c062aa47a78a8ed9c64b4abc4bac /gcc | |
parent | 6d13d38e28cf50b9ad29ab2cae058e18afbc457e (diff) | |
download | gcc-b21d8148ff0bed1e92ace175384ba4371999082d.zip gcc-b21d8148ff0bed1e92ace175384ba4371999082d.tar.gz gcc-b21d8148ff0bed1e92ace175384ba4371999082d.tar.bz2 |
sem_prag.adb, [...]: Minor code clean up.
2015-02-05 Yannick Moy <moy@adacore.com>
* sem_prag.adb, par-prag.adb: Minor code clean up.
From-SVN: r220448
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/ada/par-prag.adb | 29 | ||||
-rw-r--r-- | gcc/ada/sem_prag.adb | 32 |
3 files changed, 40 insertions, 25 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 1282072..69fa5f6 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,9 @@ 2015-02-05 Yannick Moy <moy@adacore.com> + * sem_prag.adb, par-prag.adb: Minor code clean up. + +2015-02-05 Yannick Moy <moy@adacore.com> + * par-prag.adb (Pragma_Warnings): Update for extended form of pragma Warnings. The "one" argument case may now have 2 or 3 arguments. diff --git a/gcc/ada/par-prag.adb b/gcc/ada/par-prag.adb index 1b72a29..8456177 100644 --- a/gcc/ada/par-prag.adb +++ b/gcc/ada/par-prag.adb @@ -1047,14 +1047,21 @@ begin -- Warnings (GNAT) -- --------------------- - -- pragma Warnings ([TOOL_NAME,] On | Off [,REASON]); - -- pragma Warnings ([TOOL_NAME,] On | Off, LOCAL_NAME [,REASON]); - -- pragma Warnings ([TOOL_NAME,] static_string_EXPRESSION [,REASON]); - -- pragma Warnings ([TOOL_NAME,] On | Off, - -- static_string_EXPRESSION [,REASON]); + -- pragma Warnings ([TOOL_NAME,] DETAILS [, REASON]); + + -- DETAILS ::= On | Off + -- DETAILS ::= On | Off, local_NAME + -- DETAILS ::= static_string_EXPRESSION + -- DETAILS ::= On | Off, static_string_EXPRESSION + + -- TOOL_NAME ::= GNAT | GNATProve -- REASON ::= Reason => STRING_LITERAL {& STRING_LITERAL} + -- Note: If the first argument matches an allowed tool name, it is + -- always considered to be a tool name, even if there is a string + -- variable of that name. + -- The one argument ON/OFF case is processed by the parser, since it may -- control parser warnings as well as semantic warnings, and in any case -- we want to be absolutely sure that the range in the warnings table is @@ -1065,8 +1072,6 @@ begin -- arguments if the first one is a tool name, and/or the last one is a -- reason argument. - -- Need documentation and syntax for TOOL_NAME ??? - when Pragma_Warnings => Warnings : declare function First_Arg_Is_Matching_Tool_Name return Boolean; -- Returns True if the first argument is a tool name matching the @@ -1087,14 +1092,20 @@ begin -- First_Arg_Is_Matching_Tool_Name -- ------------------------------------- - -- Comments needed for these complex conditionals ??? - function First_Arg_Is_Matching_Tool_Name return Boolean is begin return Nkind (Arg1) = N_Identifier + + -- Return True if the tool name is GNAT, and we're not in + -- GNATprove or CodePeer or ASIS mode... + and then ((Chars (Arg1) = Name_Gnat and then not (CodePeer_Mode or GNATprove_Mode or ASIS_Mode)) + + -- or if the tool name is GNATprove, and we're in GNATprove + -- mode. + or else (Chars (Arg1) = Name_Gnatprove and then GNATprove_Mode)); diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index ab72e0d..232d53d 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -3109,7 +3109,9 @@ package body Sem_Prag is -- Analyzes the argument, and determines if it is a static string -- expression, returns True if so, False if non-static or not String. -- A special case is that a string literal returns True in Ada 83 mode - -- (which has no such thing as static string expressions). + -- (which has no such thing as static string expressions). Note that + -- the call analyzes its argument, so this cannot be used for the case + -- where an identifier might not be declared. procedure Pragma_Misplaced; pragma No_Return (Pragma_Misplaced); @@ -21323,18 +21325,20 @@ package body Sem_Prag is -- Warnings -- -------------- - -- pragma Warnings ([TOOL_NAME,] On | Off [,REASON]); - -- pragma Warnings ([TOOL_NAME,] On | Off, LOCAL_NAME [,REASON]); - -- pragma Warnings ([TOOL_NAME,] static_string_EXPRESSION [,REASON]); - -- pragma Warnings ([TOOL_NAME,] On | Off, - -- static_string_EXPRESSION [,REASON]); + -- pragma Warnings ([TOOL_NAME,] DETAILS [, REASON]); + + -- DETAILS ::= On | Off + -- DETAILS ::= On | Off, local_NAME + -- DETAILS ::= static_string_EXPRESSION + -- DETAILS ::= On | Off, static_string_EXPRESSION + + -- TOOL_NAME ::= GNAT | GNATProve -- REASON ::= Reason => STRING_LITERAL {& STRING_LITERAL} - -- If present, TOOL_NAME refers to a tool, currently either GNAT - -- or GNATprove. If an identifier is a static string expression, - -- the form of pragma Warnings that starts with a static string - -- expression is used. + -- Note: If the first argument matches an allowed tool name, it is + -- always considered to be a tool name, even if there is a string + -- variable of that name. when Pragma_Warnings => Warnings : declare Reason : String_Id; @@ -21396,9 +21400,7 @@ package body Sem_Prag is -- was given otherwise, by shifting the arguments. if Nkind (Argx) = N_Identifier - and then not Nam_In (Chars (Argx), Name_On, Name_Off) - and then not Is_Static_String_Expression (Arg1) - -- How can this possibly work e.g. for GNATprove??? + and then Nam_In (Chars (Argx), Name_Gnat, Name_Gnatprove) then if Chars (Argx) = Name_Gnat then if CodePeer_Mode or GNATprove_Mode or ASIS_Mode then @@ -21415,9 +21417,7 @@ package body Sem_Prag is end if; else - Error_Pragma_Arg - ("argument of pragma% must be On/Off or tool name " - & "or static string expression", Arg1); + raise Program_Error; end if; -- At this point, the pragma Warnings applies to the tool, |