This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH,committed] Fix PR12932 (ICE tsubst address of staticfunction)
- From: Kriang Lerdsuwanakij <lerdsuwa at users dot sourceforge dot net>
- To: <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 18 Nov 2003 22:54:57 +0700 (ICT)
- Subject: [C++ PATCH,committed] Fix PR12932 (ICE tsubst address of staticfunction)
- Reply-to: <lerdsuwa at users dot sourceforge dot net>
Hi
This patch fixes a couple small issues that triggers the ICE reported
as PR12932:
- The function 'currently_open_derived_class' works on 'current_class_type'
but wasn't make sure it is not NULL_TREE.
- 'finish_call_expr' forgets to check if the 'currently_open_derived_class'
function call fails.
- The last change in DERIVED_FROM_P is there to avoid future trouble just
in case. The nearby macros already has parenthesis around macro
parameters.
Tested on i686-pc-linux-gnu. Committed to trunk as obvious.
--Kriang
2003-10-18 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/12932
* class.c (currently_open_derived_class): Check if
current_class_type is NULL_TREE.
* semantics.c (finish_call_expr): Check if
currently_open_derived_class returns NULL_TREE.
* cp-tree.h (DERIVED_FROM_P): Add parenthesis around PARENT
parameter.
2003-10-18 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/12932
* g++.dg/template/static5.C: New test.
diff -cprN gcc-main-save/gcc/cp/class.c gcc-main-new/gcc/cp/class.c
*** gcc-main-save/gcc/cp/class.c Sat Nov 1 19:02:58 2003
--- gcc-main-new/gcc/cp/class.c Mon Nov 17 21:50:52 2003
*************** currently_open_derived_class (tree t)
*** 5585,5590 ****
--- 5585,5593 ----
if (dependent_type_p (t))
return NULL_TREE;
+ if (!current_class_type)
+ return NULL_TREE;
+
if (DERIVED_FROM_P (t, current_class_type))
return current_class_type;
diff -cprN gcc-main-save/gcc/cp/cp-tree.h gcc-main-new/gcc/cp/cp-tree.h
*** gcc-main-save/gcc/cp/cp-tree.h Sun Nov 16 21:09:26 2003
--- gcc-main-new/gcc/cp/cp-tree.h Mon Nov 17 21:48:48 2003
*************** enum languages { lang_c, lang_cplusplus,
*** 1000,1006 ****
/* Nonzero iff TYPE is derived from PARENT. Ignores accessibility and
ambiguity issues. */
#define DERIVED_FROM_P(PARENT, TYPE) \
! (lookup_base ((TYPE), PARENT, ba_any, NULL) != NULL_TREE)
/* Nonzero iff TYPE is uniquely derived from PARENT. Ignores
accessibility. */
#define UNIQUELY_DERIVED_FROM_P(PARENT, TYPE) \
--- 1000,1006 ----
/* Nonzero iff TYPE is derived from PARENT. Ignores accessibility and
ambiguity issues. */
#define DERIVED_FROM_P(PARENT, TYPE) \
! (lookup_base ((TYPE), (PARENT), ba_any, NULL) != NULL_TREE)
/* Nonzero iff TYPE is uniquely derived from PARENT. Ignores
accessibility. */
#define UNIQUELY_DERIVED_FROM_P(PARENT, TYPE) \
diff -cprN gcc-main-save/gcc/cp/semantics.c gcc-main-new/gcc/cp/semantics.c
*** gcc-main-save/gcc/cp/semantics.c Sun Oct 26 18:01:18 2003
--- gcc-main-new/gcc/cp/semantics.c Mon Nov 17 22:03:39 2003
*************** finish_call_expr (tree fn, tree args, bo
*** 1638,1643 ****
--- 1638,1645 ----
if (DECL_FUNCTION_MEMBER_P (f))
{
tree type = currently_open_derived_class (DECL_CONTEXT (f));
+ if (!type)
+ type = DECL_CONTEXT (f);
fn = build_baselink (TYPE_BINFO (type),
TYPE_BINFO (type),
fn, /*optype=*/NULL_TREE);
diff -cprN gcc-main-save/gcc/testsuite/g++.dg/template/static5.C gcc-main-new/gcc/testsuite/g++.dg/template/static5.C
*** gcc-main-save/gcc/testsuite/g++.dg/template/static5.C Thu Jan 1 07:00:00 1970
--- gcc-main-new/gcc/testsuite/g++.dg/template/static5.C Tue Nov 18 22:40:28 2003
***************
*** 0 ****
--- 1,17 ----
+ // { dg-do compile }
+
+ // Origin: Mirek Fidler <cxl@ntllib.org>
+ // Wolfgang Bangerth <bangerth@ticam.utexas.edu>
+
+ // PR c++/12932: ICE address of static function as template argument
+
+ struct Test {
+ static void fun();
+ };
+
+ template <void (*fun)()>
+ void foo () { (*fun)(); }
+
+
+ template
+ void foo<Test::fun> ();