Commit 7b176381 by Mark Mitchell Committed by Mark Mitchell

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

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

From-SVN: r34489
parent 82a362d0
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> 2000-06-09 Chip Salzenberg <chip@valinux.com>
Mark Mitchell <mark@codesourcery.com> Mark Mitchell <mark@codesourcery.com>
......
...@@ -1032,6 +1032,16 @@ add_binding (id, decl) ...@@ -1032,6 +1032,16 @@ add_binding (id, decl)
the name of any type declared in that scope to refer to the the name of any type declared in that scope to refer to the
type to which it already refers. */ type to which it already refers. */
ok = 0; 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 else
{ {
cp_error ("declaration of `%#D'", decl); cp_error ("declaration of `%#D'", decl);
......
// 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment