public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: "José Rui Faustino de Sousa" <jrfsousa@gmail.com>
To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: PING: [Patch, fortran] PR fortran/96870 - Class name on error message
Date: Wed, 16 Jun 2021 15:31:22 +0000	[thread overview]
Message-ID: <db69e782-a029-cb10-13d6-9de50a90097a@gmail.com> (raw)
In-Reply-To: <7433359f-fa07-c881-009a-8722c2c5924d@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 759 bytes --]

*PING*


-------- Forwarded Message --------
Subject: [Patch, fortran] PR fortran/96870 - Class name on error message
Date: Mon, 31 Aug 2020 16:09:32 +0000
From: José Rui Faustino de Sousa <jrfsousa@gmail.com>
To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org

Hi all!

Proposed patch to PR96870 - Class name on error message.

Patch tested only on x86_64-pc-linux-gnu.

Make the error message more intelligible for the average user.

Thank you very much.

Best regards,
José Rui


	2020-8-21  José Rui Faustino de Sousa  <jrfsousa@gmail.com>

gcc/fortran/ChangeLog:

	PR fortran/96870
	* misc.c (gfc_typename): use class name instead of internal name
	on error message.

gcc/testsuite/ChangeLog:

	PR fortran/96870
	* gfortran.dg/PR96870.f90: New test.




[-- Attachment #2: PR96870.patch --]
[-- Type: text/x-patch, Size: 1795 bytes --]

diff --git a/gcc/fortran/misc.c b/gcc/fortran/misc.c
index 65bcfa6..43edfd8 100644
--- a/gcc/fortran/misc.c
+++ b/gcc/fortran/misc.c
@@ -184,8 +184,11 @@ gfc_typename (gfc_typespec *ts, bool for_hash)
 	  break;
 	}
       ts1 = ts->u.derived->components ? &ts->u.derived->components->ts : NULL;
-      if (ts1 && ts1->u.derived && ts1->u.derived->attr.unlimited_polymorphic)
-	sprintf (buffer, "CLASS(*)");
+      if (ts1 && ts1->u.derived)
+	if (ts1->u.derived->attr.unlimited_polymorphic)
+	  sprintf (buffer, "CLASS(*)");
+	else
+	  sprintf (buffer, "CLASS(%s)", ts1->u.derived->name);
       else
 	sprintf (buffer, "CLASS(%s)", ts->u.derived->name);
       break;
diff --git a/gcc/testsuite/gfortran.dg/PR96870.f90 b/gcc/testsuite/gfortran.dg/PR96870.f90
new file mode 100644
index 0000000..c1b321e
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/PR96870.f90
@@ -0,0 +1,41 @@
+! { dg-do compile }
+!
+! Test fix for PR96870
+!
+
+Program main_p
+
+  implicit none
+  
+  Type :: t0
+  End Type t0
+  
+  Type, extends(t0) :: t1
+  End Type t1
+  
+  type(t0),   target :: x
+  class(t0), pointer :: p
+
+  p => x
+  Call sub_1(x) ! { dg-error "Type mismatch in argument .p. at .1.; passed TYPE\\(t0\\) to CLASS\\(t1\\)" }
+  Call sub_1(p) ! { dg-error "Type mismatch in argument .p. at .1.; passed CLASS\\(t0\\) to CLASS\\(t1\\)" }
+  Call sub_2(x) ! { dg-error "Type mismatch in argument .p. at .1.; passed TYPE\\(t0\\) to TYPE\\(t1\\)" }
+  Call sub_2(p) ! { dg-error "Type mismatch in argument .p. at .1.; passed CLASS\\(t0\\) to TYPE\\(t1\\)" }
+  stop
+  
+Contains
+  
+  Subroutine sub_1(p)
+    class(t1), Intent(In) :: p
+
+    return
+  End Subroutine sub_1
+  
+  Subroutine sub_2(p)
+    type(t1), Intent(In) :: p
+
+    return
+  End Subroutine sub_2
+  
+End Program main_p
+


      reply	other threads:[~2021-06-16 15:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-31 16:09 José Rui Faustino de Sousa
2021-06-16 15:31 ` José Rui Faustino de Sousa [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=db69e782-a029-cb10-13d6-9de50a90097a@gmail.com \
    --to=jrfsousa@gmail.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).