This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH,committed] Fix PR 1787, 4498
- To: gcc-patches at gcc dot gnu dot org
- Subject: [C++ PATCH,committed] Fix PR 1787, 4498
- From: Kriang Lerdsuwanakij <lerdsuwa at users dot sourceforge dot net>
- Date: Sat, 27 Oct 2001 21:10:19 +0700
- Reply-To: lerdsuwa at users dot sourceforge dot net
Hi,
The following patch fixes an ICE when a namespace is used in using
declaration, for example:
namespace std {}
using ::std;
This has been reported several times in the GNATS. The patch adds
NAMESPACE_DECL handling code to validate_nonmember_using_decl.
Tested with no regressions on i686-pc-linux-gnu.
Patch commit by obvious rule.
--Kriang
2001-10-27 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
* decl2.c (validate_nonmember_using_decl): Handle NAMESPACE_DECL.
diff -cprN gcc-main-save/gcc/cp/decl2.c gcc-main-new/gcc/cp/decl2.c
*** gcc-main-save/gcc/cp/decl2.c Sat Oct 27 20:14:17 2001
--- gcc-main-new/gcc/cp/decl2.c Sat Oct 27 19:42:13 2001
*************** validate_nonmember_using_decl (decl, sco
*** 4877,4882 ****
--- 4877,4887 ----
*scope = global_namespace;
*name = decl;
}
+ else if (TREE_CODE (decl) == NAMESPACE_DECL)
+ {
+ cp_error ("namespace `%D' not allowed in using-declaration", decl);
+ return NULL_TREE;
+ }
else
my_friendly_abort (382);
if (DECL_P (*name))
diff -cprN gcc-main-save/gcc/testsuite/g++.dg/lookup/using2.C gcc-main-new/gcc/testsuite/g++.dg/lookup/using2.C
*** gcc-main-save/gcc/testsuite/g++.dg/lookup/using2.C Tue Oct 9 22:44:25 2001
--- gcc-main-new/gcc/testsuite/g++.dg/lookup/using2.C Sat Oct 27 20:33:14 2001
*************** namespace N
*** 25,30 ****
--- 25,32 ----
template<int> void f() {}
}
+ using N; // { dg-error "parse error" "" }
+ using ::N; // { dg-error "using-declaration" "" }
using N::f< 0 >; // { dg-error "using-declaration" "" }
struct A {