summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl.c10
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/decl8.C10
3 files changed, 25 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f26e03d4c5d..bc584e2f809 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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>
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index ad53c09a07f..d14b824f2ec 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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);
diff --git a/gcc/testsuite/g++.old-deja/g++.other/decl8.C b/gcc/testsuite/g++.old-deja/g++.other/decl8.C
new file mode 100644
index 00000000000..875be3edc8e
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/decl8.C
@@ -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;
+}