decl.c (add_binding): Handle duplicate declarations of external variables.

* decl.c (add_binding): Handle duplicate declarations of external
	variables.

From-SVN: r34489
This commit is contained in:
Mark Mitchell 2000-06-11 04:08:31 +00:00 committed by Mark Mitchell
parent 82a362d0a4
commit 7b176381ec
3 changed files with 25 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2000-06-10 Mark Mitchell <mark@codesourcery.com>
* decl.c (add_binding): Handle duplicate declarations of external
variables.
2000-06-09 Chip Salzenberg <chip@valinux.com>
Mark Mitchell <mark@codesourcery.com>

View File

@ -1032,6 +1032,16 @@ add_binding (id, decl)
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);

View File

@ -0,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;
}