diff options
-rw-r--r-- | gcc/ada/aspects.adb | 1 | ||||
-rw-r--r-- | gcc/ada/doc/gnat_rm/implementation_defined_aspects.rst | 8 | ||||
-rw-r--r-- | gcc/ada/gnat_rm.texi | 8 | ||||
-rw-r--r-- | gcc/ada/par-ch13.adb | 5 | ||||
-rw-r--r-- | gcc/ada/par-ch6.adb | 19 | ||||
-rw-r--r-- | gcc/ada/par.adb | 8 | ||||
-rw-r--r-- | gcc/ada/sem_ch6.adb | 27 | ||||
-rw-r--r-- | gcc/ada/sinfo.ads | 4 |
8 files changed, 63 insertions, 17 deletions
diff --git a/gcc/ada/aspects.adb b/gcc/ada/aspects.adb index c222c33..0c5a3cf 100644 --- a/gcc/ada/aspects.adb +++ b/gcc/ada/aspects.adb @@ -455,6 +455,7 @@ package body Aspects is N_Package_Instantiation => True, N_Package_Specification => True, N_Package_Renaming_Declaration => True, + N_Parameter_Specification => True, N_Private_Extension_Declaration => True, N_Private_Type_Declaration => True, N_Procedure_Instantiation => True, diff --git a/gcc/ada/doc/gnat_rm/implementation_defined_aspects.rst b/gcc/ada/doc/gnat_rm/implementation_defined_aspects.rst index 736710d..de5efea 100644 --- a/gcc/ada/doc/gnat_rm/implementation_defined_aspects.rst +++ b/gcc/ada/doc/gnat_rm/implementation_defined_aspects.rst @@ -564,9 +564,11 @@ Aspect Unreferenced =================== .. index:: Unreferenced -This boolean aspect is equivalent to :ref:`pragma Unreferenced<Pragma-Unreferenced>`. Note that -in the case of formal parameters, it is not permitted to have aspects for -a formal parameter, so in this case the pragma form must be used. +This boolean aspect is equivalent to :ref:`pragma Unreferenced<Pragma-Unreferenced>`. + +When using the ``-gnatX`` switch, this aspect is also supported on formal +parameters, which is in particular the only form possible for expression +functions. Aspect Unreferenced_Objects =========================== diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index 33a696a..da262f1 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -9923,9 +9923,11 @@ This boolean aspect is equivalent to @ref{10b,,pragma Unmodified}. @geindex Unreferenced -This boolean aspect is equivalent to @ref{10c,,pragma Unreferenced}. Note that -in the case of formal parameters, it is not permitted to have aspects for -a formal parameter, so in this case the pragma form must be used. +This boolean aspect is equivalent to @ref{10c,,pragma Unreferenced}. + +When using the @code{-gnatX} switch, this aspect is also supported on formal +parameters, which is in particular the only form possible for expression +functions. @node Aspect Unreferenced_Objects,Aspect Value_Size,Aspect Unreferenced,Implementation Defined Aspects @anchor{gnat_rm/implementation_defined_aspects aspect-unreferenced-objects}@anchor{15e} diff --git a/gcc/ada/par-ch13.adb b/gcc/ada/par-ch13.adb index 459d7fe..95223a1 100644 --- a/gcc/ada/par-ch13.adb +++ b/gcc/ada/par-ch13.adb @@ -153,7 +153,8 @@ package body Ch13 is Result := True; else Scan; -- past identifier - Result := Token in Tok_Arrow | Tok_Comma | Tok_Is | Tok_Semicolon; + Result := Token in + Tok_Arrow | Tok_Comma | Tok_Is | Tok_Semicolon | Tok_Right_Paren; end if; -- If earlier than Ada 2012, check for valid aspect identifier (possibly @@ -956,7 +957,7 @@ package body Ch13 is -- If Decl is Error, we ignore the aspects, and issue a message elsif Decl = Error - or else not Permits_Aspect_Specifications (Decl) + or else not Permits_Aspect_Specifications (Decl) then Error_Msg ("aspect specifications not allowed here", Ptr); diff --git a/gcc/ada/par-ch6.adb b/gcc/ada/par-ch6.adb index 1ff7950..622a508 100644 --- a/gcc/ada/par-ch6.adb +++ b/gcc/ada/par-ch6.adb @@ -1627,6 +1627,25 @@ package body Ch6 is Scan; -- past right paren exit Specification_Loop; + -- Support for aspects on formal parameters is a GNAT extension for + -- the time being. + + elsif Token = Tok_With then + if not Extensions_Allowed then + Error_Msg_SP ("aspect on formal parameter requires -gnatX"); + end if; + + P_Aspect_Specifications (Specification_Node, False); + + if Token = Tok_Right_Paren then + Scan; -- past right paren + exit Specification_Loop; + + elsif Token = Tok_Semicolon then + Save_Scan_State (Scan_State); + Scan; -- past semicolon + end if; + -- Special check for common error of using comma instead of semicolon elsif Token = Tok_Comma then diff --git a/gcc/ada/par.adb b/gcc/ada/par.adb index 69da69d..4c3a154 100644 --- a/gcc/ada/par.adb +++ b/gcc/ada/par.adb @@ -995,10 +995,10 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is procedure P_Aspect_Specifications (Decl : Node_Id; Semicolon : Boolean := True); - -- This procedure scans out a series of aspect spefications. If argument - -- Semicolon is True, a terminating semicolon is also scanned. If this - -- argument is False, the scan pointer is left pointing past the aspects - -- and the caller must check for a proper terminator. + -- This procedure scans out a series of aspect specifications. If + -- argument Semicolon is True, a terminating semicolon is also scanned. + -- If this argument is False, the scan pointer is left pointing past the + -- aspects and the caller must check for a proper terminator. -- -- P_Aspect_Specifications is called with the current token pointing -- to either a WITH keyword starting an aspect specification, or an diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 215c4ad..8bf5889 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -672,9 +672,9 @@ package body Sem_Ch6 is end if; end Analyze_Expression_Function; - ---------------------------------------- - -- Analyze_Extended_Return_Statement -- - ---------------------------------------- + --------------------------------------- + -- Analyze_Extended_Return_Statement -- + --------------------------------------- procedure Analyze_Extended_Return_Statement (N : Node_Id) is begin @@ -12282,6 +12282,27 @@ package body Sem_Ch6 is end if; end if; + -- Deal with aspects on formal parameters. Only Unreferenced is + -- supported for the time being. + + if Has_Aspects (Param_Spec) then + declare + Aspect : Node_Id := First (Aspect_Specifications (Param_Spec)); + begin + while Present (Aspect) loop + if Chars (Identifier (Aspect)) = Name_Unreferenced then + Set_Has_Pragma_Unreferenced (Formal); + else + Error_Msg_NE + ("unsupported aspect& on parameter", + Aspect, Identifier (Aspect)); + end if; + + Next (Aspect); + end loop; + end; + end if; + <<Continue>> Next (Param_Spec); end loop; diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads index 231ebb5..4f0a41f 100644 --- a/gcc/ada/sinfo.ads +++ b/gcc/ada/sinfo.ads @@ -5414,9 +5414,9 @@ package Sinfo is -- PARAMETER_SPECIFICATION ::= -- DEFINING_IDENTIFIER_LIST : [ALIASED] MODE [NULL_EXCLUSION] - -- SUBTYPE_MARK [:= DEFAULT_EXPRESSION] + -- SUBTYPE_MARK [:= DEFAULT_EXPRESSION] [ASPECT_SPECIFICATIONS] -- | DEFINING_IDENTIFIER_LIST : ACCESS_DEFINITION - -- [:= DEFAULT_EXPRESSION] + -- [:= DEFAULT_EXPRESSION] [ASPECT_SPECIFICATIONS] -- Although the syntax allows multiple identifiers in the list, the -- semantics is as though successive specifications were given with |