From bf98d3b6c0453c71f0659848e7673ebc2cc3ee0c Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Tue, 16 Oct 2007 22:21:59 +0000 Subject: [PATCH] re PR c++/31446 (ICE with invalid template parameter) /cp 2007-10-16 Paolo Carlini PR c++/31446 * pt.c (current_template_args): Do not change TREE_LIST elements with a TREE_VALUE of error_mark_node. /testsuite 2007-10-16 Paolo Carlini PR c++/31446 * g++.dg/template/void11.C: New. * g++.dg/template/void2.C: Adjust error markers. * g++.dg/template/void10.C: Likewise. * g++.dg/template/crash55.C: Likewise. From-SVN: r129391 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 2 +- gcc/testsuite/ChangeLog | 8 ++++++++ gcc/testsuite/g++.dg/template/crash55.C | 2 +- gcc/testsuite/g++.dg/template/void10.C | 2 +- gcc/testsuite/g++.dg/template/void11.C | 12 ++++++++++++ gcc/testsuite/g++.dg/template/void2.C | 4 ++-- 7 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/void11.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 559226b4f4e..5fd1c1b5e76 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2007-10-16 Paolo Carlini + + PR c++/31446 + * pt.c (current_template_args): Do not change TREE_LIST elements + with a TREE_VALUE of error_mark_node. + 2007-10-16 Mark Mitchell * typeck.c (cp_apply_type_quals_to_decl): Expand documentation. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c3ce0d13734..773c1041762 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -3136,8 +3136,8 @@ current_template_args (void) TREE_TYPE (t) = type; } } + TREE_VEC_ELT (a, i) = t; } - TREE_VEC_ELT (a, i) = t; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3535b314801..34f8c0826c4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2007-10-16 Paolo Carlini + + PR c++/31446 + * g++.dg/template/void11.C: New. + * g++.dg/template/void2.C: Adjust error markers. + * g++.dg/template/void10.C: Likewise. + * g++.dg/template/crash55.C: Likewise. + 2007-10-16 Mark Mitchell * g++.dg/opt/const5.C: New test. diff --git a/gcc/testsuite/g++.dg/template/crash55.C b/gcc/testsuite/g++.dg/template/crash55.C index 377603dcff3..7cf9f1eae80 100644 --- a/gcc/testsuite/g++.dg/template/crash55.C +++ b/gcc/testsuite/g++.dg/template/crash55.C @@ -1,6 +1,6 @@ //PR c++/27668 template // { dg-error "nested-name-specifier|two or more|valid type" } -struct A {}; // { dg-error "definition|template" } +struct A {}; template void foo(A); // { dg-error "mismatch|constant|template argument" } diff --git a/gcc/testsuite/g++.dg/template/void10.C b/gcc/testsuite/g++.dg/template/void10.C index 56e0b6d2e5b..4904a281a40 100644 --- a/gcc/testsuite/g++.dg/template/void10.C +++ b/gcc/testsuite/g++.dg/template/void10.C @@ -7,4 +7,4 @@ template struct A // { dg-error "not a valid type" } template struct B {}; -B b; // { dg-error "template argument|invalid type" } +B b; diff --git a/gcc/testsuite/g++.dg/template/void11.C b/gcc/testsuite/g++.dg/template/void11.C new file mode 100644 index 00000000000..1aad7a157da --- /dev/null +++ b/gcc/testsuite/g++.dg/template/void11.C @@ -0,0 +1,12 @@ +// PR c++/31446 + +template struct A // { dg-error "valid type" } + +{ + template friend void foo(); +}; + +void bar() +{ + foo<0>(); // { dg-error "not declared|primary-expression" } +} diff --git a/gcc/testsuite/g++.dg/template/void2.C b/gcc/testsuite/g++.dg/template/void2.C index 05a8186e03a..eceb36219aa 100644 --- a/gcc/testsuite/g++.dg/template/void2.C +++ b/gcc/testsuite/g++.dg/template/void2.C @@ -3,7 +3,7 @@ template struct A { - template friend class X; // { dg-error "void" } + template friend class X; // { dg-error "void|valid type" } }; -A<0> a; +A<0> a; -- 2.30.2