public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Fwd: Re: Bug in g2c.h for calling Fortran vom C++ (not C)]
@ 2002-11-18 14:51 Toon Moene
  2002-11-18 23:58 ` Mark Mitchell
  0 siblings, 1 reply; 2+ messages in thread
From: Toon Moene @ 2002-11-18 14:51 UTC (permalink / raw)
  To: mark; +Cc: gcc-patches

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

Mark,

This is a regression w.r.t. 2.95.x.  I'm getting bug reports about it, 
so it seems to be relevant, now.

Could this go in when the 3.2.1 is released (so that it will show up in 
3.2.2.) ?

Thanks in advance,

-- 
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)

[-- Attachment #2: Re: Bug in g2c.h for calling Fortran vom C++ (not C) --]
[-- Type: message/rfc822, Size: 7768 bytes --]

[-- Attachment #2.1.1: Type: text/plain, Size: 2226 bytes --]

Toon Moene wrote:

> Peter Englmaier wrote:

> > I used C++ to call FORTRAN and it worked fine until I upgraded to
> > Redhat 7.2 from Redhat 6.2. As explained in the g77 manual, I used the
> > g2c.h header to call the fortran subroutines from C and C++:
> >
> > #ifdef __cplusplus
> > extern "C" {
> > #endif
> >
> > #include <g2c.h>
> > void f77open_dmp(int *,int *,char *,float *, ftnlen);
> >
> > #ifdef __cplusplus
> > }
> > #endif
> >
> > This worked fine with older Versions of both C and C++, but with the
> > new version gcc 2.96 (included in Redhat 7.2) as well as gcc 3.0.1 (also
> > included in Redhat 7.2) it stopped working with C++. Apparently, some
> > internal variables are no longer pre-defined, namely:
> > __g77_integer, __g77_uinteger, __g77_longint, __g77_ulongint.
> > As a workaround I now define those types myself and it compiles OK.
> >
> > Please let me know, if this is (i) a gcc bug which will is/will be
> > fixed with more recent versions), or (ii) a bug from Redhat. In the
> > later case I will report the bug to Redhat as well.

> Well, let's call it an oversight.  __g77_integer and friends became
> internalised into the C compiler shortly before Red Hat forked its 2.96
> release.
> 
> I approved that internalisation without realising that it would break
> compiling interfaces with C++ (you are the first one to complain about
> it, actually).
> 
> The solution is to move these internal declarations from c-decl.c to
> c-common.c.  I'll try to come up with a patch for that (the C-like
> frontends are not my area of expertise).  It's uncertain whether it will
> be in time for the 3.1 release (which is imminent).

I tested the following patch on the trunk; it solves the problem (make
bootstrap, make check, make install for all languages on
i686-pc-linux-gnu - no regressions).

Could someone approve this for mainline ?

Mark, would this be OK for the 3.1 branch ?  It is a regression with
respect to 2.95.

-- 
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)

[-- Attachment #2.1.2: g77-int.patch --]
[-- Type: text/plain, Size: 4412 bytes --]

2002-04-10  Toon Moene  <toon@moene.indiv.nluug.nl>

	* c-decl.c (c_init_decl_processing): Move generation of
	decls for g77_integer_type_node and friends from here ...
	* c-common.c (c_common_nodes_and_builtins): ... to here.

*** c-decl.c.orig	Sat Apr  6 20:23:05 2002
--- c-decl.c	Tue Apr  9 22:26:17 2002
*************** c_init_decl_processing ()
*** 2932,2984 ****
  			   tree_cons (NULL_TREE, ptr_type_node, endlink));
  
-   /* Types which are common to the fortran compiler and libf2c.  When
-      changing these, you also need to be concerned with f/com.h.  */
- 
-   if (TYPE_PRECISION (float_type_node)
-       == TYPE_PRECISION (long_integer_type_node))
-     {
-       g77_integer_type_node = long_integer_type_node;
-       g77_uinteger_type_node = long_unsigned_type_node;
-     }
-   else if (TYPE_PRECISION (float_type_node)
- 	   == TYPE_PRECISION (integer_type_node))
-     {
-       g77_integer_type_node = integer_type_node;
-       g77_uinteger_type_node = unsigned_type_node;
-     }
-   else
-     g77_integer_type_node = g77_uinteger_type_node = NULL_TREE;
- 
-   if (g77_integer_type_node != NULL_TREE)
-     {
-       pushdecl (build_decl (TYPE_DECL, get_identifier ("__g77_integer"),
- 			    g77_integer_type_node));
-       pushdecl (build_decl (TYPE_DECL, get_identifier ("__g77_uinteger"),
- 			    g77_uinteger_type_node));
-     }
- 
-   if (TYPE_PRECISION (float_type_node) * 2
-       == TYPE_PRECISION (long_integer_type_node))
-     {
-       g77_longint_type_node = long_integer_type_node;
-       g77_ulongint_type_node = long_unsigned_type_node;
-     }
-   else if (TYPE_PRECISION (float_type_node) * 2
- 	   == TYPE_PRECISION (long_long_integer_type_node))
-     {
-       g77_longint_type_node = long_long_integer_type_node;
-       g77_ulongint_type_node = long_long_unsigned_type_node;
-     }
-   else
-     g77_longint_type_node = g77_ulongint_type_node = NULL_TREE;
- 
-   if (g77_longint_type_node != NULL_TREE)
-     {
-       pushdecl (build_decl (TYPE_DECL, get_identifier ("__g77_longint"),
- 			    g77_longint_type_node));
-       pushdecl (build_decl (TYPE_DECL, get_identifier ("__g77_ulongint"),
- 			    g77_ulongint_type_node));
-     }
- 
    pedantic_lvalues = pedantic;
  
--- 2932,2935 ----
*** c-common.c.orig	Sat Apr  6 20:23:05 2002
--- c-common.c	Tue Apr  9 22:22:06 2002
*************** c_common_nodes_and_builtins ()
*** 2653,2656 ****
--- 2653,2709 ----
  		 complex_long_double_type_node));
  
+   /* Types which are common to the fortran compiler and libf2c.  When
+      changing these, you also need to be concerned with f/com.h.  */
+ 
+   if (TYPE_PRECISION (float_type_node)
+       == TYPE_PRECISION (long_integer_type_node))
+     {
+       g77_integer_type_node = long_integer_type_node;
+       g77_uinteger_type_node = long_unsigned_type_node;
+     }
+   else if (TYPE_PRECISION (float_type_node)
+ 	   == TYPE_PRECISION (integer_type_node))
+     {
+       g77_integer_type_node = integer_type_node;
+       g77_uinteger_type_node = unsigned_type_node;
+     }
+   else
+     g77_integer_type_node = g77_uinteger_type_node = NULL_TREE;
+ 
+   if (g77_integer_type_node != NULL_TREE)
+     {
+       (*lang_hooks.decls.pushdecl) (build_decl (TYPE_DECL,
+ 						get_identifier ("__g77_integer"),
+ 						g77_integer_type_node));
+       (*lang_hooks.decls.pushdecl) (build_decl (TYPE_DECL,
+ 						get_identifier ("__g77_uinteger"),
+ 						g77_uinteger_type_node));
+     }
+ 
+   if (TYPE_PRECISION (float_type_node) * 2
+       == TYPE_PRECISION (long_integer_type_node))
+     {
+       g77_longint_type_node = long_integer_type_node;
+       g77_ulongint_type_node = long_unsigned_type_node;
+     }
+   else if (TYPE_PRECISION (float_type_node) * 2
+ 	   == TYPE_PRECISION (long_long_integer_type_node))
+     {
+       g77_longint_type_node = long_long_integer_type_node;
+       g77_ulongint_type_node = long_long_unsigned_type_node;
+     }
+   else
+     g77_longint_type_node = g77_ulongint_type_node = NULL_TREE;
+ 
+   if (g77_longint_type_node != NULL_TREE)
+     {
+       (*lang_hooks.decls.pushdecl) (build_decl (TYPE_DECL,
+ 						get_identifier ("__g77_longint"),
+ 						g77_longint_type_node));
+       (*lang_hooks.decls.pushdecl) (build_decl (TYPE_DECL,
+ 						get_identifier ("__g77_ulongint"),
+ 						g77_ulongint_type_node));
+     }
+ 
    record_builtin_type (RID_VOID, NULL, void_type_node);
  

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

* Re: [Fwd: Re: Bug in g2c.h for calling Fortran vom C++ (not C)]
  2002-11-18 14:51 [Fwd: Re: Bug in g2c.h for calling Fortran vom C++ (not C)] Toon Moene
@ 2002-11-18 23:58 ` Mark Mitchell
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Mitchell @ 2002-11-18 23:58 UTC (permalink / raw)
  To: Toon Moene; +Cc: gcc-patches



--On Monday, November 18, 2002 11:54 PM +0100 Toon Moene 
<toon@moene.indiv.nluug.nl> wrote:

> Mark,
>
> This is a regression w.r.t. 2.95.x.  I'm getting bug reports about it, so
> it seems to be relevant, now.
>
> Could this go in when the 3.2.1 is released (so that it will show up in
> 3.2.2.) ?

Sure -- but you don't need my approval for that.  The branch will reopen and
you can do the usual thing. :-)

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

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

end of thread, other threads:[~2002-11-19  7:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-18 14:51 [Fwd: Re: Bug in g2c.h for calling Fortran vom C++ (not C)] Toon Moene
2002-11-18 23:58 ` Mark Mitchell

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