https://gcc.gnu.org/g:ba2aec16a2509dad4dae27c462944c4a8e487029

commit r17-1970-gba2aec16a2509dad4dae27c462944c4a8e487029
Author: Viljar Indus <[email protected]>
Date:   Wed Jun 10 11:30:07 2026 +0300

    ada: Improve error message for -gnatw.q
    
    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.

Diff:
---
 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 3a14f226f0eb..e569eb1bddf1 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.  */

Reply via email to