This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] ada/35886: Switch location of incomplete and full declarations
On 9/04, Samuel Tardieu wrote:
| On 9/04, Arnaud Charlet wrote:
|
| | Your submission contains no explanation and no comments, so we cannot
| | review it in this form.
|
| Did you look at the bug report?
| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35886
Here is a more complete view.
Without this patch, GNAT locates the error onto the incomplete type
declaration node (while calling it the "full declaration" in the
error message), and refers to the incomplete declaration by pointing
out the full declaration.
This patch switches the location of the error (full declaration) and
the reference to the incomplete type.
Tested on Linux/x86.
Ok for trunk?
gcc/ada/
PR ada/35886
* sem_ch3.adb (Find_Type_Name): Switch Id and Prev in error
messages.
gcc/testsuite/
PR ada/35886
* gnat.dg/specs/tag3.ads: New.
---
gcc/ada/sem_ch3.adb | 6 +++---
gcc/testsuite/gnat.dg/specs/tag3.ads | 6 ++++++
2 files changed, 9 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/gnat.dg/specs/tag3.ads
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 00e471a..2bd3a4c 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -13055,7 +13055,7 @@ package body Sem_Ch3 is
if Nkind (Type_Definition (N)) = N_Record_Definition then
if not Tagged_Present (Type_Definition (N)) then
Error_Msg_NE
- ("full declaration of } must be tagged", Prev, Id);
+ ("full declaration of } must be tagged", Id, Prev);
Set_Is_Tagged_Type (Id);
Set_Primitive_Operations (Id, New_Elmt_List);
end if;
@@ -13064,14 +13064,14 @@ package body Sem_Ch3 is
if No (Record_Extension_Part (Type_Definition (N))) then
Error_Msg_NE (
"full declaration of } must be a record extension",
- Prev, Id);
+ Id, Prev);
Set_Is_Tagged_Type (Id);
Set_Primitive_Operations (Id, New_Elmt_List);
end if;
else
Error_Msg_NE
- ("full declaration of } must be a tagged type", Prev, Id);
+ ("full declaration of } must be a tagged type", Id, Prev);
end if;
end if;
diff --git a/gcc/testsuite/gnat.dg/specs/tag3.ads b/gcc/testsuite/gnat.dg/specs/tag3.ads
new file mode 100644
index 0000000..8e167e0
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/tag3.ads
@@ -0,0 +1,6 @@
+-- { dg-do compile }
+
+package tag3 is
+ type T is tagged;
+ type T is null record; -- { dg-error "must be tagged" }
+end tag3;