diff options
author | Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> | 2003-11-18 15:54:22 +0000 |
---|---|---|
committer | Kriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org> | 2003-11-18 15:54:22 +0000 |
commit | c44e68a5f70cca855b79dce8b8ba5c7274a8c731 (patch) | |
tree | bb256035baabb26b8721b836ce81c524c986d175 /gcc | |
parent | df964a183fdc0fa5fae0409bfa305ee95b3b3d6b (diff) | |
download | gcc-c44e68a5f70cca855b79dce8b8ba5c7274a8c731.zip gcc-c44e68a5f70cca855b79dce8b8ba5c7274a8c731.tar.gz gcc-c44e68a5f70cca855b79dce8b8ba5c7274a8c731.tar.bz2 |
re PR c++/12932 (ICE with use of ptr-to-function as template arg)
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.
* g++.dg/template/static5.C: New test.
From-SVN: r73705
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cp/class.c | 3 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 2 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/static5.C | 17 |
6 files changed, 38 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e143dea..7f75b43 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2003-11-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-11-17 Jason Merrill <jason@redhat.com> * init.c (build_new_1): Preevaluate placement args. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 300d846..1e1b71c 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5585,6 +5585,9 @@ currently_open_derived_class (tree t) 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 --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 1c6154f..75245ab 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1000,7 +1000,7 @@ enum languages { lang_c, lang_cplusplus, lang_java }; /* 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) + (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 --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 13d8734..cb25972 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1638,6 +1638,8 @@ finish_call_expr (tree fn, tree args, bool disallow_virtual, bool koenig_p) 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 --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f200f42..fd389b5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-11-18 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> + + PR c++/12932 + * g++.dg/template/static5.C: New test. + 2003-11-18 Joseph S. Myers <jsm@polyomino.org.uk> * gcc.dg/nested-func-1.c: New test. diff --git a/gcc/testsuite/g++.dg/template/static5.C b/gcc/testsuite/g++.dg/template/static5.C new file mode 100644 index 0000000..05eaf8f --- /dev/null +++ b/gcc/testsuite/g++.dg/template/static5.C @@ -0,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> (); |