From 23e6615e0fb38cfb3b3480e2adfbf4b49cb9a7c0 Mon Sep 17 00:00:00 2001 From: Robert Dewar Date: Tue, 20 May 2008 14:47:49 +0200 Subject: [PATCH] opt.ads (Treat_Restrictions_As_Warnings): New switch 2008-05-20 Robert Dewar * opt.ads (Treat_Restrictions_As_Warnings): New switch * sem_prag.adb, par-prag.adb, restrict.ads: Implement flag Treat_Restrictions_As_Warnings. * switch-c.adb: Recognize new switch -gnatr * usage.adb: Add line for -gnatr From-SVN: r135632 --- gcc/ada/opt.ads | 5 +++++ gcc/ada/par-prag.adb | 3 ++- gcc/ada/restrict.ads | 17 ++++++++++------- gcc/ada/sem_prag.adb | 16 +++++++++++----- gcc/ada/switch-c.adb | 10 ++++++++-- gcc/ada/usage.adb | 5 +++++ 6 files changed, 41 insertions(+), 15 deletions(-) diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads index 65a9bb4bd8d..600231c737a 100644 --- a/gcc/ada/opt.ads +++ b/gcc/ada/opt.ads @@ -1108,6 +1108,11 @@ package Opt is -- Tolerate time stamp and other consistency errors. If this flag is set to -- True (-t), then inconsistencies result in warnings rather than errors. + Treat_Restrictions_As_Warnings : Boolean := False; + -- GNAT + -- Set True to treat pragma Restrictions as Restriction_Warnings. Set by + -- -gnatr switch. + Tree_Output : Boolean := False; -- GNAT -- Set to True (-gnatt) to generate output tree file diff --git a/gcc/ada/par-prag.adb b/gcc/ada/par-prag.adb index 5067f029c92..c8b84ab189e 100644 --- a/gcc/ada/par-prag.adb +++ b/gcc/ada/par-prag.adb @@ -234,7 +234,8 @@ function Prag (Pragma_Node : Node_Id; Semi : Source_Ptr) return Node_Id is elsif Id = Name_No_Dependence then Set_Restriction_No_Dependence (Unit => Expr, - Warn => Prag_Id = Pragma_Restriction_Warnings); + Warn => Prag_Id = Pragma_Restriction_Warnings + or else Treat_Restrictions_As_Warnings); end if; Next (Arg); diff --git a/gcc/ada/restrict.ads b/gcc/ada/restrict.ads index 9dacefb3005..fbc8a8a54f8 100644 --- a/gcc/ada/restrict.ads +++ b/gcc/ada/restrict.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2007, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2008, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -277,11 +277,12 @@ package Restrict is (P : Profile_Name; N : Node_Id; Warn : Boolean); - -- Sets the set of restrictions associated with the given profile - -- name. N is the node of the construct to which error messages - -- are to be attached as required. Warn is set True for the case - -- of Profile_Warnings where the restrictions are set as warnings - -- rather than legality requirements. + -- Sets the set of restrictions associated with the given profile name. N + -- is the node of the construct to which error messages are to be attached + -- as required. Warn is set True for the case of Profile_Warnings where the + -- restrictions are set as warnings rather than legality requirements, and + -- is also True for Profile if the Treat_Restrictions_As_Warnings flag is + -- set. It is false for Profile if this flag is not set. procedure Set_Restriction (R : All_Boolean_Restrictions; @@ -301,7 +302,9 @@ package Restrict is (Unit : Node_Id; Warn : Boolean); -- Sets given No_Dependence restriction in table if not there already. - -- Warn is True if from Restriction_Warnings, False if from Restrictions. + -- Warn is True if from Restriction_Warnings, or for Restrictions if flag + -- Treat_Restrictions_As_Warnings is set. False if from Restrictions and + -- this flag is not set. function Tasking_Allowed return Boolean; pragma Inline (Tasking_Allowed); diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 6b819803705..15f4e181f7a 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -671,7 +671,9 @@ package body Sem_Prag is procedure Process_Restrictions_Or_Restriction_Warnings (Warn : Boolean); -- Common processing for Restrictions and Restriction_Warnings pragmas. - -- Warn is False for Restrictions, True for Restriction_Warnings. + -- Warn is True for Restriction_Warnings, or for Restrictions if the + -- flag Treat_Restrictions_As_Warnings is set, and False if this flag + -- is not set in the Restrictions case. procedure Process_Suppress_Unsuppress (Suppress_Case : Boolean); -- Common processing for Suppress and Unsuppress. The boolean parameter @@ -4770,7 +4772,8 @@ package body Sem_Prag is -- Set the corresponding restrictions - Set_Profile_Restrictions (Ravenscar, N, Warn => False); + Set_Profile_Restrictions + (Ravenscar, N, Warn => Treat_Restrictions_As_Warnings); end Set_Ravenscar_Profile; -- Start of processing for Analyze_Pragma @@ -9790,7 +9793,8 @@ package body Sem_Prag is if Chars (Argx) = Name_Ravenscar then Set_Ravenscar_Profile (N); elsif Chars (Argx) = Name_Restricted then - Set_Profile_Restrictions (Restricted, N, Warn => False); + Set_Profile_Restrictions + (Restricted, N, Warn => Treat_Restrictions_As_Warnings); else Error_Pragma_Arg ("& is not a valid profile", Argx); end if; @@ -10285,7 +10289,8 @@ package body Sem_Prag is GNAT_Pragma; Check_Arg_Count (0); Check_Valid_Configuration_Pragma; - Set_Profile_Restrictions (Restricted, N, Warn => False); + Set_Profile_Restrictions + (Restricted, N, Warn => Treat_Restrictions_As_Warnings); if Warn_On_Obsolescent_Feature then Error_Msg_N @@ -10305,7 +10310,8 @@ package body Sem_Prag is -- | restriction_parameter_IDENTIFIER => EXPRESSION when Pragma_Restrictions => - Process_Restrictions_Or_Restriction_Warnings (Warn => False); + Process_Restrictions_Or_Restriction_Warnings + (Warn => Treat_Restrictions_As_Warnings); -------------------------- -- Restriction_Warnings -- diff --git a/gcc/ada/switch-c.adb b/gcc/ada/switch-c.adb index bd63fae88f8..cf59c8198cd 100644 --- a/gcc/ada/switch-c.adb +++ b/gcc/ada/switch-c.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2001-2007, Free Software Foundation, Inc. -- +-- Copyright (C) 2001-2008, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -660,13 +660,19 @@ package body Switch.C is Ptr := Ptr + 1; Try_Semantics := True; - -- Processing for q switch + -- Processing for Q switch when 'Q' => Ptr := Ptr + 1; Force_ALI_Tree_File := True; Try_Semantics := True; + -- Processing for r switch + + when 'r' => + Ptr := Ptr + 1; + Treat_Restrictions_As_Warnings := True; + -- Processing for R switch when 'R' => diff --git a/gcc/ada/usage.adb b/gcc/ada/usage.adb index 0d131e1f2e5..5a1f4827eab 100644 --- a/gcc/ada/usage.adb +++ b/gcc/ada/usage.adb @@ -289,6 +289,11 @@ begin Write_Switch_Char ("Q"); Write_Line ("Don't quit, write ali/tree file even if compile errors"); + -- Line for -gnatr switch + + Write_Switch_Char ("r"); + Write_Line ("Treat pragma Restrictions as Restriction_Warnings"); + -- Lines for -gnatR switch Write_Switch_Char ("R?"); -- 2.30.2