From 42510d7546a4163eb86d327f02192330d3509d50 Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 14 Feb 2005 13:45:42 +0000 Subject: [PATCH] cp: PR c++/19884 * pt.c (check_explicit_specialization): Make sure namespace binding lookup found an overloaded function. (lookup_template_function): Just assert FNS is an overloaded function. PR c++/19895 * decl.c (grokdeclarator): Check for error mark node in ptrmem construction. testsuite: PR c++/19895 * g++.dg/parse/ptrmem3.C: New. PR c++/19884 * g++.old-deja/g++.oliva/template6.C: Add another case. * g++.dg/template/explicit6.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@95009 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 14 +++++++++++++- gcc/cp/decl.c | 3 +++ gcc/cp/pt.c | 18 +++++++----------- gcc/testsuite/ChangeLog | 9 +++++++++ gcc/testsuite/g++.dg/parse/ptrmem3.C | 11 +++++++++++ gcc/testsuite/g++.dg/template/explicit6.C | 8 ++++++++ gcc/testsuite/g++.old-deja/g++.oliva/template6.C | 5 ++++- 7 files changed, 55 insertions(+), 13 deletions(-) create mode 100644 gcc/testsuite/g++.dg/parse/ptrmem3.C create mode 100644 gcc/testsuite/g++.dg/template/explicit6.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 777f520..add1476 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,10 +1,22 @@ +2005-02-14 Nathan Sidwell + + PR c++/19884 + * pt.c (check_explicit_specialization): Make sure namespace + binding lookup found an overloaded function. + (lookup_template_function): Just assert FNS is an overloaded + function. + + PR c++/19895 + * decl.c (grokdeclarator): Check for error mark node in ptrmem + construction. + 2005-02-14 Alexandre Oliva PR c++/17816 * decl.c (redeclaration_error_message): Report redefinition of pure virtual function. -2005-02-11 Nathan Sidwell +2005-02-14 Nathan Sidwell PR c++/19891 * class.c (build_simple_base_path): Build the component_ref diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 47732cb..48f8d8c 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7348,6 +7348,9 @@ grokdeclarator (const cp_declarator *declarator, declarator->u.pointer.class_type); type = build_pointer_type (type); } + else if (declarator->u.pointer.class_type == error_mark_node) + /* We will already have complained. */ + type = error_mark_node; else type = build_ptrmem_type (declarator->u.pointer.class_type, type); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index b131213..7025def 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1883,6 +1883,11 @@ check_explicit_specialization (tree declarator, /* Find the namespace binding, using the declaration context. */ fns = namespace_binding (dname, CP_DECL_CONTEXT (decl)); + if (!fns || !is_overloaded_fn (fns)) + { + error ("%qD is not a template function", dname); + fns = error_mark_node; + } } declarator = lookup_template_function (fns, NULL_TREE); @@ -4196,17 +4201,8 @@ lookup_template_function (tree fns, tree arglist) return error_mark_node; gcc_assert (!arglist || TREE_CODE (arglist) == TREE_VEC); - if (fns == NULL_TREE - || TREE_CODE (fns) == FUNCTION_DECL) - { - error ("non-template used as template"); - return error_mark_node; - } - - gcc_assert (TREE_CODE (fns) == TEMPLATE_DECL - || TREE_CODE (fns) == OVERLOAD - || BASELINK_P (fns) - || TREE_CODE (fns) == IDENTIFIER_NODE); + gcc_assert (fns && (is_overloaded_fn (fns) + || TREE_CODE (fns) == IDENTIFIER_NODE)); if (BASELINK_P (fns)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e185aad..61fef17 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2005-02-14 Nathan Sidwell + + PR c++/19895 + * g++.dg/parse/ptrmem3.C: New. + + PR c++/19884 + * g++.old-deja/g++.oliva/template6.C: Add another case. + * g++.dg/template/explicit6.C: New. + 2005-02-14 Alexandre Oliva PR c++/17816 diff --git a/gcc/testsuite/g++.dg/parse/ptrmem3.C b/gcc/testsuite/g++.dg/parse/ptrmem3.C new file mode 100644 index 0000000..444f25c --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/ptrmem3.C @@ -0,0 +1,11 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 14 Feb 2005 + +// Origin: Volker Reichelt +// Bug 19895: ICE on invalid + + +template struct A +{ + int A<0>::* p; // { dg-error "(type/value mismatch)|(expected)" "" } +}; diff --git a/gcc/testsuite/g++.dg/template/explicit6.C b/gcc/testsuite/g++.dg/template/explicit6.C new file mode 100644 index 0000000..f740269 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/explicit6.C @@ -0,0 +1,8 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 14 Feb 2005 + +// Origin: Volker Reichelt +// Bug 19895: ICE on invalid + +struct A; +template A<>::A(); // { dg-error "(not a template)|(explicit qualification)" "" } diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/template6.C b/gcc/testsuite/g++.old-deja/g++.oliva/template6.C index f31d677..270d676 100644 --- a/gcc/testsuite/g++.old-deja/g++.oliva/template6.C +++ b/gcc/testsuite/g++.old-deja/g++.oliva/template6.C @@ -6,4 +6,7 @@ // simplified from bug report by Meenaradchagan Vishnu template struct foo {}; -template <> void foo(); // { dg-error "" } bad specialization +template <> void foo(); // { dg-error "not a template function" } bad specialization + +struct baz {}; +template <> void baz (); // { dg-error "not a template function" } bad specialization -- 2.7.4