aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2020-04-16 11:19:48 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-06-17 04:14:17 -0400
commitda901811dc478d45e7dc1028dce0bda8abbbee65 (patch)
tree0cd732316e96ad5c35f111fd3c6f36d9bceea5a7 /gcc
parent831aff1d8be79fda3ec3172fdbcbbec3c8be319d (diff)
downloadgcc-da901811dc478d45e7dc1028dce0bda8abbbee65.zip
gcc-da901811dc478d45e7dc1028dce0bda8abbbee65.tar.gz
gcc-da901811dc478d45e7dc1028dce0bda8abbbee65.tar.bz2
[Ada] Do not give "bad indentation" error inside a declare_expression
2020-06-17 Bob Duff <duff@adacore.com> gcc/ada/ * par.adb (P_Basic_Declarative_Items): Update comment about Declare_Expression. * par-ch3.adb (P_Declarative_Items): Pass in Declare_Expression flag, and if True, skip the call to Style.Check_Indentation. * par-ch4.adb (P_Declare_Expression): Fix incorrect comment.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/par-ch3.adb39
-rw-r--r--gcc/ada/par-ch4.adb2
-rw-r--r--gcc/ada/par.adb3
3 files changed, 29 insertions, 15 deletions
diff --git a/gcc/ada/par-ch3.adb b/gcc/ada/par-ch3.adb
index 1fadf36..d224cc5 100644
--- a/gcc/ada/par-ch3.adb
+++ b/gcc/ada/par-ch3.adb
@@ -78,18 +78,24 @@ package body Ch3 is
-- it very unlikely that this will ever arise in practice.
procedure P_Declarative_Items
- (Decls : List_Id;
- Done : out Boolean;
- In_Spec : Boolean);
+ (Decls : List_Id;
+ Done : out Boolean;
+ Declare_Expression : Boolean;
+ In_Spec : Boolean);
-- Scans out a single declarative item, or, in the case of a declaration
-- with a list of identifiers, a list of declarations, one for each of the
-- identifiers in the list. The declaration or declarations scanned are
-- appended to the given list. Done indicates whether or not there may be
-- additional declarative items to scan. If Done is True, then a decision
-- has been made that there are no more items to scan. If Done is False,
- -- then there may be additional declarations to scan. In_Spec is true if
- -- we are scanning a package declaration, and is used to generate an
- -- appropriate message if a statement is encountered in such a context.
+ -- then there may be additional declarations to scan.
+ --
+ -- Declare_Expression is true if we are parsing a declare_expression, in
+ -- which case we want to suppress certain style checking.
+ --
+ -- In_Spec is true if we are scanning a package declaration, and is used to
+ -- generate an appropriate message if a statement is encountered in such a
+ -- context.
procedure P_Identifier_Declarations
(Decls : List_Id;
@@ -4310,7 +4316,8 @@ package body Ch3 is
-- Loop to scan out the declarations
loop
- P_Declarative_Items (Decls, Done, In_Spec => False);
+ P_Declarative_Items
+ (Decls, Done, Declare_Expression => False, In_Spec => False);
exit when Done;
end loop;
@@ -4337,16 +4344,20 @@ package body Ch3 is
-- then the scan is set past the next semicolon and Error is returned.
procedure P_Declarative_Items
- (Decls : List_Id;
- Done : out Boolean;
- In_Spec : Boolean)
+ (Decls : List_Id;
+ Done : out Boolean;
+ Declare_Expression : Boolean;
+ In_Spec : Boolean)
is
Scan_State : Saved_Scan_State;
begin
Done := False;
- if Style_Check then
+ -- In -gnatg mode, we don't want a "bad indentation" error inside a
+ -- declare_expression.
+
+ if Style_Check and not Declare_Expression then
Style.Check_Indentation;
end if;
@@ -4727,7 +4738,8 @@ package body Ch3 is
Decls := New_List;
loop
- P_Declarative_Items (Decls, Done, In_Spec => True);
+ P_Declarative_Items
+ (Decls, Done, Declare_Expression, In_Spec => True);
exit when Done;
end loop;
@@ -4827,7 +4839,8 @@ package body Ch3 is
Dummy_Done : Boolean;
pragma Warnings (Off, Dummy_Done);
begin
- P_Declarative_Items (S, Dummy_Done, False);
+ P_Declarative_Items
+ (S, Dummy_Done, Declare_Expression => False, In_Spec => False);
end Skip_Declaration;
-----------------------------------------
diff --git a/gcc/ada/par-ch4.adb b/gcc/ada/par-ch4.adb
index e3f3f06..0360212 100644
--- a/gcc/ada/par-ch4.adb
+++ b/gcc/ada/par-ch4.adb
@@ -3587,7 +3587,7 @@ package body Ch4 is
function P_Declare_Expression return Node_Id is
Loc : constant Source_Ptr := Token_Ptr;
begin
- Scan; -- past IF
+ Scan; -- past DECLARE
declare
Actions : constant List_Id := P_Basic_Declarative_Items
diff --git a/gcc/ada/par.adb b/gcc/ada/par.adb
index 7879080..4978dc5 100644
--- a/gcc/ada/par.adb
+++ b/gcc/ada/par.adb
@@ -699,7 +699,8 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is
-- private part (in which case Declare_Expression is False), and
-- the declare_items of a declare_expression (in which case
-- Declare_Expression is True). Declare_Expression is used to
- -- affect the wording of error messages.
+ -- affect the wording of error messages, and to control style
+ -- checking.
function P_Access_Definition
(Null_Exclusion_Present : Boolean) return Node_Id;