diff options
author | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-06-11 04:08:31 +0000 |
---|---|---|
committer | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-06-11 04:08:31 +0000 |
commit | 072c61d7c300ac6348982272bcce135a4339d119 (patch) | |
tree | d579da5ed7ad17ce3c2ad1166251ac0169d21727 | |
parent | e75e76eaef38650f77120070b5a848743b316406 (diff) | |
download | gcc-072c61d7c300ac6348982272bcce135a4339d119.tar.gz |
* decl.c (add_binding): Handle duplicate declarations of external
variables.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34489 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/decl.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.other/decl8.C | 10 |
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; +} |