Previously we gave a warning and ignored all such aspects, including language-defined ones, which must be diagnosed as illegal. This patch considers all aspects illegal in this context. Why not? They are our aspects, and if we are not going to implement them in this context, they should not be allowed. The following test should give two errors as shown:
1. procedure TaskBAspect is 2. task T; 3. task body T with Pre => True is | >>> aspects on task bodies are not allowed 4. begin 5. null; 6. end; 7. protected T1 is end T1; 8. protected body T1 with Warnings => True is | >>> aspects on protected bodies are not allowed 9. end; 10. begin 11. null; 12. end; Tested on x86_64-pc-linux-gnu, committed on trunk 2013-10-10 Robert Dewar <de...@adacore.com> * sem_ch9.adb (Analyze_Task_Body): Aspects are illegal (Analyze_Protected_Body): Aspects are illegal.
Index: sem_ch9.adb =================================================================== --- sem_ch9.adb (revision 203342) +++ sem_ch9.adb (working copy) @@ -1736,16 +1736,16 @@ -- Protected bodies are currently removed by the expander. Since there -- are no language-defined aspects that apply to a protected body, it is - -- not worth changing the whole expansion to accomodate user-defined - -- aspects. Plus we cannot possibly known the semantics of user-defined - -- aspects in order to plan ahead. + -- not worth changing the whole expansion to accomodate implementation- + -- defined aspects. Plus we cannot possibly known the semantics of such + -- future implementation defined aspects in order to plan ahead. if Has_Aspects (N) then Error_Msg_N - ("?user-defined aspects on protected bodies are not supported", N); + ("aspects on protected bodies are not allowed", + First (Aspect_Specifications (N))); - -- The aspects are removed for now to prevent cascading errors down - -- stream. + -- Remove illegal aspects to prevent cascaded errors later on Remove_Aspects (N); end if; @@ -2726,15 +2726,15 @@ -- Task bodies are transformed into a subprogram spec and body pair by -- the expander. Since there are no language-defined aspects that apply -- to a task body, it is not worth changing the whole expansion to - -- accomodate user-defined aspects. Plus we cannot possibly known the - -- semantics of user-defined aspects in order to plan ahead. + -- accomodate implementation-defined aspects. Plus we cannot possibly + -- know semantics of such aspects in order to plan ahead. if Has_Aspects (N) then Error_Msg_N - ("?user-defined aspects on task bodies are not supported", N); + ("aspects on task bodies are not allowed", + First (Aspect_Specifications (N))); - -- The aspects are removed for now to prevent cascading errors down - -- stream. + -- Remove illegal aspects to prevent cascaded errors later on Remove_Aspects (N); end if; @@ -2763,7 +2763,6 @@ then if Nkind (Parent (Spec_Id)) = N_Task_Type_Declaration then Error_Msg_NE ("duplicate body for task type&", N, Spec_Id); - else Error_Msg_NE ("duplicate body for task&", N, Spec_Id); end if;