diff mbox

[Ada] Better error message for illegal Invariant'class aspect

Message ID 20150220114904.GA16474@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Feb. 20, 2015, 11:49 a.m. UTC
Within the compiler class-wide aspects use a leading-underscore internal
identifier. If the placement of the aspect is illegal, the error message
must mention the original form of the aspect.

Compiling class_a.ads must yield:

   class_a.ads:5:10:
         aspect "Type_Invariant_Class" only allowed
             for private type declared in visible part

---
package Class_A is
    type A_T is tagged private;
private
    type A_T is tagged null record
    with Type_Invariant'Class => True;
end Class_A;

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

2015-02-20  Ed Schonberg  <schonberg@adacore.com>

	* sem_prag.adb (Fix_Error): For an illegal Type_Invariant'Class
	aspect, use name that mentions Class explicitly, rather than
	compiler-internal name.
diff mbox

Patch

Index: sem_prag.adb
===================================================================
--- sem_prag.adb	(revision 220850)
+++ sem_prag.adb	(working copy)
@@ -5918,6 +5918,17 @@ 
             --  Get name from corresponding aspect
 
             Error_Msg_Name_1 := Original_Aspect_Name (N);
+
+            if Class_Present (N) then
+
+               --  Replace the name with a leading underscore used
+               --  internally, with a name that is more user-friendly.
+
+               if Error_Msg_Name_1 = Name_uType_Invariant then
+                  Error_Msg_Name_1 := Name_Type_Invariant_Class;
+               end if;
+            end if;
+
          end if;
 
          --  Return possibly modified message