[Ada] Syntax error on improperly indented imported subprogram

Pierre-Marie de Rodat derodat@adacore.com
Mon Dec 16 10:38:00 GMT 2019


This patch fixes an incorrect syntax error. In particular, in an example
like the following:

    procedure Main is
    procedure Imported with Import;
    begin
       null;
    end;

where there is a subprogram declaration with an Import aspect
specification, and the declaration is indented the same as a following
"begin", the compiler was giving incorrect syntax errors:

    main.adb:2:31: ";" should be "is"
    main.adb:5:01: "end Imported;" expected
    main.adb:5:01: missing "begin" for procedure "Main" at line 1

The problem was that the mechanisms described under "Handling Semicolon
Used in Place of IS" in par.adb were not updated to handle Import
aspect.

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

2019-12-16  Bob Duff  <duff@adacore.com>

gcc/ada/

	* par.adb: Add Scopes function to do range checking on the scope
	stack.  Call Scopes all over the parser.  Add
	SIS_Aspect_Import_Seen flag.
	* par-ch6.adb (P_Subprogram): Initialize SIS_Aspect_Import_Seen
	to False at the start, and check it at the end.
	* par-ch13.adb (Get_Aspect_Specifications): Set
	SIS_Aspect_Import_Seen to True when appropriate.
	* par-ch10.adb, par-ch12.adb, par-ch2.adb, par-ch3.adb,
	par-ch5.adb, par-ch7.adb, par-ch9.adb, par-endh.adb,
	par-util.adb: Call Scopes.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff.gz
Type: application/gzip
Size: 7819 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20191216/e80a4869/attachment.gz>


More information about the Gcc-patches mailing list