summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2004-08-02 18:49:07 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2004-08-02 18:49:07 +0000
commit2b21700552148b607caf7dfdb3bb6f1dc7f61c1c (patch)
tree7c30c43cf161e0e414cbadd2120475d775c23854
parentebd00ad724f07a4ce1d102847bba8f59188d108e (diff)
downloadppe42-gcc-2b21700552148b607caf7dfdb3bb6f1dc7f61c1c.tar.gz
ppe42-gcc-2b21700552148b607caf7dfdb3bb6f1dc7f61c1c.zip
PR c++/16707
* name-lookup.c (validate_nonmember_using_decl): Robustify. PR c++/16707 * g++.dg/lookup/using12.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@85446 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/name-lookup.c20
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/lookup/using12.C4
4 files changed, 23 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 81a819a7931..d87b4827aee 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2004-08-02 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/16707
+ * name-lookup.c (validate_nonmember_using_decl): Robustify.
+
2004-08-01 Mark Mitchell <mark@codesourcery.com>
PR c++/16224
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index c44541285fb..2859d8035b9 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -2115,6 +2115,17 @@ push_overloaded_decl (tree decl, int flags)
static tree
validate_nonmember_using_decl (tree decl, tree scope, tree name)
{
+ /* [namespace.udecl]
+ A using-declaration for a class member shall be a
+ member-declaration. */
+ if (TYPE_P (scope))
+ {
+ error ("`%T' is not a namespace", scope);
+ return NULL_TREE;
+ }
+ else if (scope == error_mark_node)
+ return NULL_TREE;
+
if (TREE_CODE (decl) == TEMPLATE_ID_EXPR)
{
/* 7.3.3/5
@@ -2142,15 +2153,6 @@ validate_nonmember_using_decl (tree decl, tree scope, tree name)
my_friendly_assert (DECL_P (decl), 20020908);
- /* [namespace.udecl]
- A using-declaration for a class member shall be a
- member-declaration. */
- if (TYPE_P (scope))
- {
- error ("`%T' is not a namespace", scope);
- return NULL_TREE;
- }
-
/* Make a USING_DECL. */
return push_using_decl (scope, name);
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6a1dbc6d147..4ae35e2c75d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2004-08-02 Mark Mitchell <mark@codesourcery.com>
+ PR c++/16707
+ * g++.dg/lookup/using12.C: New test.
+
* g++.dg/init/null1.C: Fix PR number.
* g++.dg/parse/namespace10.C: Likewise.
diff --git a/gcc/testsuite/g++.dg/lookup/using12.C b/gcc/testsuite/g++.dg/lookup/using12.C
new file mode 100644
index 00000000000..030385581a5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lookup/using12.C
@@ -0,0 +1,4 @@
+// PR c++/16707
+
+int i;
+using N::i; // { dg-error "declared|expected" }
OpenPOWER on IntegriCloud