diff options
author | Mark Mitchell <mark@codesourcery.com> | 2000-06-11 04:08:31 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2000-06-11 04:08:31 +0000 |
commit | 7b176381ecd654fb32ab47a22a896087141ed843 (patch) | |
tree | d579da5ed7ad17ce3c2ad1166251ac0169d21727 /gcc | |
parent | 82a362d0a47042ab86a7bcd966ec9820f4f3bb8a (diff) | |
download | gcc-7b176381ecd654fb32ab47a22a896087141ed843.zip gcc-7b176381ecd654fb32ab47a22a896087141ed843.tar.gz gcc-7b176381ecd654fb32ab47a22a896087141ed843.tar.bz2 |
decl.c (add_binding): Handle duplicate declarations of external variables.
* decl.c (add_binding): Handle duplicate declarations of external
variables.
From-SVN: r34489
Diffstat (limited to 'gcc')
-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 f26e03d..bc584e2 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 ad53c09..d14b824 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 0000000..875be3e --- /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; +} |