From: Viljar Indus <[email protected]>

Use continuations to group the messages so that they will be
handled as a set.

Post the error on the type instead of the component to avoid
ambiguities with derived types.

Have the second continuation message explicitly point to the
component that is causing the problem.

gcc/ada/ChangeLog:

        * gcc-interface/decl.cc (warn_on_field_placement): Improve error 
message.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/gcc-interface/decl.cc | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index 3a14f226f0e..e569eb1bddf 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -8432,20 +8432,21 @@ warn_on_field_placement (tree gnu_field, Node_Id 
gnat_component_list,
       : "?.q?record layout may cause performance issues";
   const char *msg2
     = Ekind (gnat_field) == E_Discriminant
-      ? "?.q?discriminant & whose length is not multiple of a byte"
+      ? "\\?.q?discriminant &# whose length is not multiple of a byte"
       : field_has_self_size (gnu_field)
-       ? "?.q?component & whose length depends on a discriminant"
+       ? "\\?.q?component &# whose length depends on a discriminant"
        : field_has_variable_size (gnu_field)
-         ? "?.q?component & whose length is not fixed"
-         : "?.q?component & whose length is not multiple of a byte";
+         ? "\\?.q?component &# whose length is not fixed"
+         : "\\?.q?component &# whose length is not multiple of a byte";
   const char *msg3
     = do_reorder
-      ? "?.q?comes too early and was moved down"
-      : "?.q?comes too early and ought to be moved down";
+      ? "\\?.q?comes too early and was moved down"
+      : "\\?.q?comes too early and ought to be moved down";
 
-  post_error (msg1, gnat_field);
-  post_error_ne (msg2, gnat_field, gnat_field);
-  post_error (msg3, gnat_field);
+  post_error (msg1, gnat_record_type);
+  Error_Msg_Sloc = Sloc(gnat_field);
+  post_error_ne (msg2, gnat_record_type, gnat_field);
+  post_error (msg3, gnat_record_type);
 }
 
 /* Likewise but for every field present on GNU_FIELD_LIST.  */
-- 
2.53.0

Reply via email to