From: Dodji Seketeli Date: Wed, 19 Nov 2008 22:26:56 +0000 (+0000) Subject: re PR c++/35405 (Internal compiler error) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b55276c8acf960a6316f93ad55fb75003c36f9e2;p=gcc.git re PR c++/35405 (Internal compiler error) gcc/cp/ChangeLog: 2008-11-19 Dodji Seketeli PR c++/35405 * pt.c (lookup_template_class): Check pointers before dereferencing Them. * error.c (dump_template_decl): Likewise. gcc/testsuite/ChangeLog: 2008-11-19 Dodji Seketeli PR c++/35405 * g++.dg/template/crash84.C: New test. From-SVN: r142022 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5e47e58b7ac..73e07d73f9d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2008-11-19 Dodji Seketeli + + PR c++/35405 + * pt.c (lookup_template_class): Check pointers before dereferencing + Them. + * error.c (dump_template_decl): Likewise. + 2008-11-19 Jason Merrill PR c++/36410 diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 3aa9b595fa7..a2db1575fe7 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1044,11 +1044,13 @@ dump_template_decl (tree t, int flags) } } - if (TREE_CODE (DECL_TEMPLATE_RESULT (t)) == TYPE_DECL) + if (DECL_TEMPLATE_RESULT (t) + && TREE_CODE (DECL_TEMPLATE_RESULT (t)) == TYPE_DECL) dump_type (TREE_TYPE (t), ((flags & ~TFF_CLASS_KEY_OR_ENUM) | TFF_TEMPLATE_NAME | (flags & TFF_DECL_SPECIFIERS ? TFF_CLASS_KEY_OR_ENUM : 0))); - else if (TREE_CODE (DECL_TEMPLATE_RESULT (t)) == VAR_DECL) + else if (DECL_TEMPLATE_RESULT (t) + && TREE_CODE (DECL_TEMPLATE_RESULT (t)) == VAR_DECL) dump_decl (DECL_TEMPLATE_RESULT (t), flags | TFF_TEMPLATE_NAME); else { diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2b938c36881..96c510f3d4c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5585,6 +5585,7 @@ lookup_template_class (tree d1, d1 = DECL_NAME (templ); } else if (TREE_CODE (d1) == TEMPLATE_DECL + && DECL_TEMPLATE_RESULT (d1) && TREE_CODE (DECL_TEMPLATE_RESULT (d1)) == TYPE_DECL) { templ = d1; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ab27dd9dd5e..85f9f279faf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-11-19 Dodji Seketeli + + PR c++/35405 + * g++.dg/template/crash84.C: New test. + 2008-11-19 Jakub Jelinek * gcc.c-torture/compile/pr11832.c: XFAIL even on s390*-*-*. diff --git a/gcc/testsuite/g++.dg/template/crash84.C b/gcc/testsuite/g++.dg/template/crash84.C new file mode 100644 index 00000000000..f622aaa5e10 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash84.C @@ -0,0 +1,19 @@ +// Contributed by Dodji Seketeli +// Origin PR c++/35405 +// { dg-do compile } + +template struct a +{ + template