The current error message is:
abstract1.ads:7:13: error: "abstract" not allowed here, ignored
but "abstract" is indeed allowed there if you complete the declaration.
The patch changes it to:
abstract1.ads:7:13: error: "abstract" allowed only for record extension, ...
Tested on x86-64/Linux, applied on the mainline.
2025-11-03 Eric Botcazou <[email protected]>
PR ada/55324
* par-ch3.adb (P_Type_Declaration): Give a better error message
for illegal "abstract" in a type derivation.
2025-11-03 Eric Botcazou <[email protected]>
* gnat.dg/specs/abstract1.ads: New test.
--
Eric Botcazou-- { dg-do compile }
package Abstract1 is
type T is abstract tagged null record;
type S is abstract new T; -- { dg-error "allowed only for record extension" }
end Abstract1;
diff --git a/gcc/ada/par-ch3.adb b/gcc/ada/par-ch3.adb
index 56c1b894c0d..ee0958d051f 100644
--- a/gcc/ada/par-ch3.adb
+++ b/gcc/ada/par-ch3.adb
@@ -757,8 +757,7 @@ package body Ch3 is
Typedef_Node := P_Derived_Type_Def_Or_Private_Ext_Decl;
if Saved_Token = Tok_Synchronized then
- if Nkind (Typedef_Node) =
- N_Derived_Type_Definition
+ if Nkind (Typedef_Node) = N_Derived_Type_Definition
then
Error_Msg_N
("SYNCHRONIZED not allowed for record extension",
@@ -864,7 +863,13 @@ package body Ch3 is
Set_Abstract_Present (Typedef_Node, Abstract_Present);
elsif Abstract_Present then
- Error_Msg ("ABSTRACT not allowed here, ignored", Abstract_Loc);
+ if Nkind (Typedef_Node) = N_Derived_Type_Definition then
+ Error_Msg
+ ("ABSTRACT allowed only for record extension, ignored",
+ Abstract_Loc);
+ else
+ Error_Msg ("ABSTRACT not allowed here, ignored", Abstract_Loc);
+ end if;
end if;
Decl_Node := New_Node (N_Full_Type_Declaration, Type_Loc);