aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorGabriel Dos Reis <gdr@merlin.codesourcery.com>2001-08-06 16:04:08 +0000
committerGabriel Dos Reis <gdr@gcc.gnu.org>2001-08-06 16:04:08 +0000
commiteac69b8a008bd5426d3410d624aa9d88577fd69f (patch)
tree1993644e70dfb92ec05b33c858202615ffdf6f75 /gcc/cp
parent4f2b1139461bb4ac0a310807cdf07358f20a4b0e (diff)
downloadgcc-eac69b8a008bd5426d3410d624aa9d88577fd69f.zip
gcc-eac69b8a008bd5426d3410d624aa9d88577fd69f.tar.gz
gcc-eac69b8a008bd5426d3410d624aa9d88577fd69f.tar.bz2
Don't allow template-id in using-declaration.
cp/ Don't allow template-id in using-declaration. * decl2.c (validate_nonmember_using_decl): Handle template-ids. (do_class_using_decl): Likewise. testsuite/ * g++.dg/other/using-declaration.C: New test. From-SVN: r44663
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl2.c44
2 files changed, 36 insertions, 14 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 2911f99..470fd82 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2001-08-05 Gabriel Dos Reis <gdr@merlin.codesourcery.com>
+
+ Don't allow template-id in using-declaration.
+ * decl2.c (validate_nonmember_using_decl): Handle template-ids.
+ (do_class_using_decl): Likewise.
+
2001-08-04 Neil Booth <neil@cat.daikokuya.demon.co.uk>
* cp/spew.c (read_token): No need to pop buffers.
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 666c31b..d35ab71 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -4913,19 +4913,29 @@ validate_nonmember_using_decl (decl, scope, name)
*scope = TREE_OPERAND (decl, 0);
*name = TREE_OPERAND (decl, 1);
- /* [namespace.udecl]
-
- A using-declaration for a class member shall be a
- member-declaration. */
- if (!processing_template_decl
- && TREE_CODE (*scope) != NAMESPACE_DECL)
- {
- if (TYPE_P (*scope))
- cp_error ("`%T' is not a namespace", *scope);
- else
- cp_error ("`%D' is not a namespace", *scope);
- return NULL_TREE;
- }
+ if (!processing_template_decl)
+ {
+ /* [namespace.udecl]
+ A using-declaration for a class member shall be a
+ member-declaration. */
+ if(TREE_CODE (*scope) != NAMESPACE_DECL)
+ {
+ if (TYPE_P (*scope))
+ cp_error ("`%T' is not a namespace", *scope);
+ else
+ cp_error ("`%D' is not a namespace", *scope);
+ return NULL_TREE;
+ }
+
+ /* 7.3.3/5
+ A using-declaration shall not name a template-id. */
+ if (TREE_CODE (*name) == TEMPLATE_ID_EXPR)
+ {
+ *name = TREE_OPERAND (*name, 0);
+ cp_error ("a using-declaration cannot specify a template-id. Try `using %D'", *name);
+ return NULL_TREE;
+ }
+ }
}
else if (TREE_CODE (decl) == IDENTIFIER_NODE
|| TREE_CODE (decl) == TYPE_DECL
@@ -5129,7 +5139,13 @@ do_class_using_decl (decl)
cp_error ("using-declaration for destructor");
return NULL_TREE;
}
- if (TREE_CODE (name) == TYPE_DECL)
+ else if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
+ {
+ name = TREE_OPERAND (name, 0);
+ cp_error ("a using-declaration cannot specify a template-id. Try `using %T::%D'", TREE_OPERAND (decl, 0), name);
+ return NULL_TREE;
+ }
+ if (TREE_CODE (name) == TYPE_DECL || TREE_CODE (name) == TEMPLATE_DECL)
name = DECL_NAME (name);
my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 980716);