public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran] PR 87172: [9 Regression] Spurious "Derived type 'c_funptr' at (1) has not been declared" error after r263782
@ 2018-09-03 19:19 Janus Weil
  2018-09-11 11:14 ` Janus Weil
  0 siblings, 1 reply; 2+ messages in thread
From: Janus Weil @ 2018-09-03 19:19 UTC (permalink / raw)
  To: gfortran, gcc-patches

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

Hi all,

attached is a simple patch that fixes a regression which was
introduced by one of my recent commits (spotted by Dominique).

My first impulse to fix the spurious error was to check for the
'intrinsic' attribute, however it is actually not set (yet?) in
resolve_fl_derived, so the next-best thing is to check for
'use_assoc'. That is probably even better, since it's more general.
Obviously, if a type has the 'use_assoc' attribute, then it has been
declared in another module, so there is no need to complain that it
was not declared.

The patch regtests cleanly on x86_64-linux-gnu. Ok for trunk?

Cheers,
Janus

[-- Attachment #2: pr87172.diff --]
[-- Type: text/x-patch, Size: 1948 bytes --]

diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index c386a649583..8dad9d35eaf 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,10 @@
+2018-09-03  Janus Weil  <janus@gcc.gnu.org>
+
+	PR fortran/87172
+	* resolve.c (resolve_fl_derived): If a type has the 'use_assoc'
+	attribute, then it was declared in another module, so there should be
+	no error that it has not been declared.
+
 2018-08-31  Paul Thomas  <pault@gcc.gnu.org>
 
 	PR fortran/86328
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index ded27624283..ea0ce800743 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -14245,7 +14245,7 @@ resolve_fl_derived (gfc_symbol *sym)
 			  &sym->declared_at))
     return false;
 
-  if (sym->components == NULL && !sym->attr.zero_comp)
+  if (sym->components == NULL && !sym->attr.zero_comp && !sym->attr.use_assoc)
     {
       gfc_error ("Derived type %qs at %L has not been declared",
 		  sym->name, &sym->declared_at);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b44c714d7d2..da267de64ef 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-09-03  Janus Weil  <janus@gcc.gnu.org>
+
+	PR fortran/87172
+	* gfortran.dg/iso_c_binding_only_2.f90: New test case.
+
 2018-09-03  Richard Biener  <rguenther@suse.de>
 
 	PR tree-optimization/87200
diff --git a/gcc/testsuite/gfortran.dg/iso_c_binding_only_2.f90 b/gcc/testsuite/gfortran.dg/iso_c_binding_only_2.f90
new file mode 100644
index 00000000000..03fafe3f5cb
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/iso_c_binding_only_2.f90
@@ -0,0 +1,14 @@
+! { dg-do compile }
+!
+! PR 87172: [9 Regression] Spurious "Derived type 'c_funptr' at (1) has not been declared" error after r263782
+!
+! Contributed by Dominique d'Humieres <dominiq@lps.ens.fr>
+
+module m1
+   use iso_c_binding, only: c_funptr
+end module
+
+module m2
+  use m1
+  use iso_c_binding
+end module

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Patch, Fortran] PR 87172: [9 Regression] Spurious "Derived type 'c_funptr' at (1) has not been declared" error after r263782
  2018-09-03 19:19 [Patch, Fortran] PR 87172: [9 Regression] Spurious "Derived type 'c_funptr' at (1) has not been declared" error after r263782 Janus Weil
@ 2018-09-11 11:14 ` Janus Weil
  0 siblings, 0 replies; 2+ messages in thread
From: Janus Weil @ 2018-09-11 11:14 UTC (permalink / raw)
  To: gfortran, gcc-patches

ping!
Am Mo., 3. Sep. 2018 um 21:19 Uhr schrieb Janus Weil <janus@gcc.gnu.org>:
>
> Hi all,
>
> attached is a simple patch that fixes a regression which was
> introduced by one of my recent commits (spotted by Dominique).
>
> My first impulse to fix the spurious error was to check for the
> 'intrinsic' attribute, however it is actually not set (yet?) in
> resolve_fl_derived, so the next-best thing is to check for
> 'use_assoc'. That is probably even better, since it's more general.
> Obviously, if a type has the 'use_assoc' attribute, then it has been
> declared in another module, so there is no need to complain that it
> was not declared.
>
> The patch regtests cleanly on x86_64-linux-gnu. Ok for trunk?
>
> Cheers,
> Janus

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-11 11:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-03 19:19 [Patch, Fortran] PR 87172: [9 Regression] Spurious "Derived type 'c_funptr' at (1) has not been declared" error after r263782 Janus Weil
2018-09-11 11:14 ` Janus Weil

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).