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] Better error recovery for statement used in place of declaration


If a statement appears where a declaration is expected, then an
appropriate error message is given, but the tree is malformed
leading to a later crash if -gnatQ is used.

The following should compile with  -gnatQ without giving a
"compilation abandoned" message:

     1. procedure AssignInD is
     2.    X : Integer;
     3.    X := 2;
           |
        >>> statement not allowed in declarative part

     4.    Y : Integer;
     5. begin
     6.    null;
     7. end;

In addition, this patch implements the -gnatd.2 debug flag which
suppresses error messages of this kind (if the above is compiled
with -gnatd.2, no error message is given).

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

2015-02-20  Robert Dewar  <dewar@adacore.com>

	* debug.adb: Add documentation for -gnatd.2 (allow statements
	in decl sequences).
	* par-ch3.adb (P_Identifier_Declarations): Handle
	statement appearing where declaration expected more cleanly.
	(Statement_When_Declaration_Expected): Implement debug flag
	-gnatd.2.

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]