g++ 2.96 bug handling 'extern'.
Mark Mitchell
mark@codesourcery.com
Sat Jun 10 21:08:00 GMT 2000
Sergei --
Thanks for your bug report. Fixed with this patch.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2000-06-10 Mark Mitchell <mark@codesourcery.com>
* decl.c (add_binding): Handle duplicate declarations of external
variables.
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.634
diff -c -p -r1.634 decl.c
*** decl.c 2000/06/09 21:47:40 1.634
--- decl.c 2000/06/11 04:06:46
*************** add_binding (id, decl)
*** 1032,1037 ****
--- 1032,1047 ----
the name of any type declared in that scope to refer to the
type to which it already refers. */
ok = 0;
+ /* There can be two block-scope declarations of the same variable,
+ so long as they are `extern' declarations. */
+ else if (TREE_CODE (decl) == VAR_DECL
+ && TREE_CODE (BINDING_VALUE (binding)) == VAR_DECL
+ && DECL_EXTERNAL (decl)
+ && DECL_EXTERNAL (BINDING_VALUE (binding)))
+ {
+ duplicate_decls (decl, BINDING_VALUE (binding));
+ ok = 0;
+ }
else
{
cp_error ("declaration of `%#D'", decl);
Index: testsuite/g++.old-deja/g++.other/decl8.C
===================================================================
RCS file: decl8.C
diff -N decl8.C
*** /dev/null Tue May 5 13:32:27 1998
--- decl8.C Sat Jun 10 21:06:49 2000
***************
*** 0 ****
--- 1,10 ----
+ // Build don't link:
+ // Origin: Sergei Organov <osv@javad.ru>
+
+ void foo(void)
+ {
+ extern int i; // ERROR - previous declaration
+ extern double i; // ERROR - conflicting type
+ extern int j;
+ extern int j;
+ }
More information about the Gcc-bugs
mailing list