aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-11-20 17:19:40 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2007-11-20 17:19:40 +0100
commit542f8eb9890fbd94f1ce22b0b1291669ec91ce8c (patch)
tree84b8939a4ce1abb5342a7e68a27b7537396b9bd8 /gcc/cp/parser.c
parent8ef62eeb746043239772dd99ad2cff5176735713 (diff)
downloadgcc-542f8eb9890fbd94f1ce22b0b1291669ec91ce8c.zip
gcc-542f8eb9890fbd94f1ce22b0b1291669ec91ce8c.tar.gz
gcc-542f8eb9890fbd94f1ce22b0b1291669ec91ce8c.tar.bz2
re PR c++/34089 (Segfault on specialization using struct instead of template function.)
PR c++/34089 * parser.c (cp_parser_class_head): Reject function template ids. * g++.dg/template/crash74.C: New test. From-SVN: r130316
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 41cb26e..8e16d22 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -14536,8 +14536,18 @@ cp_parser_class_head (cp_parser* parser,
/* Look up the type. */
if (template_id_p)
{
- type = TREE_TYPE (id);
- type = maybe_process_partial_specialization (type);
+ if (TREE_CODE (id) == TEMPLATE_ID_EXPR
+ && (DECL_FUNCTION_TEMPLATE_P (TREE_OPERAND (id, 0))
+ || TREE_CODE (TREE_OPERAND (id, 0)) == OVERLOAD))
+ {
+ error ("function template %qD redeclared as a class template", id);
+ type = error_mark_node;
+ }
+ else
+ {
+ type = TREE_TYPE (id);
+ type = maybe_process_partial_specialization (type);
+ }
if (nested_name_specifier)
pushed_scope = push_scope (nested_name_specifier);
}