This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PATCH: g++ Frontend bug (or not?) introduced by your 1998/08/20 change.


Hi Jason,
consider the following test case:

extern "C" 
{
typedef struct {int dummy[10];} *GDBM_FILE;
extern GDBM_FILE gdbm_open();
}

You have three guesses where I distilled this from :-)

Anyways, egcs complains:
achibm5:~/difccd/tests/compiler >> /work/egcs/bin/g++ -c unnamed.C unnamed.C:4: warning: non-local function `struct {anonymous} * gdbm_open(...)' uses anonymous type
	
I have read [basic.link], but it is not clear to me what to The Right
Thing is when an unnamed struct is specifically declared with extern
"C" linkage. IMHO an extern "C" should tell the compiler just that:
the objects and functions declared have extern "C" linkage.

The error message is in grokfndecl in decl.c, and the check in
no_linkage_helper() in tree.c.

I have verified that the attached patch cures the problem, and there's
no regression in the testsuite.

-- kga
-------------------------------------------------------------------------
Klaus-Georg Adams        Email: Klaus-Georg.Adams@chemie.uni-karlsruhe.de
Institut f. Anorg. Chemie, Lehrstuhl II            Tel: 49(0)721 608 3485
Universität Karlsruhe, D-76128 Karlsruhe
-------------------------------------------------------------------------
Index: tree.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/tree.c,v
retrieving revision 1.70
diff -u -p -u -r1.70 tree.c
--- tree.c	1998/10/06 14:20:20	1.70
+++ tree.c	1998/10/07 16:09:31
@@ -1755,6 +1755,8 @@ tree
 no_linkage_check (t)
      tree t;
 {
+  if (current_lang_name != lang_name_cplusplus)
+    return NULL_TREE;
   t = search_tree (t, no_linkage_helper);
   if (t != error_mark_node)
     return t;
Index: ChangeLog
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/ChangeLog,v
retrieving revision 1.717
diff -u -p -u -r1.717 ChangeLog
--- ChangeLog	1998/10/06 14:19:44	1.717
+++ ChangeLog	1998/10/07 16:13:57
@@ -1,3 +1,8 @@
+Wed Oct  7 18:11:31 1998  Klaus-Georg Adams  <Klaus-Georg.Adams@chemie.uni-karlsruhe.de>
+
+	* tree.c (no_linkage_check): Don't bother to check if the linkage
+	is not C++.
+
 1998-10-06  Mark Mitchell  <mark@markmitchell.com>
 
 	* cp-tree.def (PTRMEM_CST): New tree node.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]