From 2010cdcdd7bfd38c480fdffc147e875b7f277a70 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Fri, 16 Sep 2005 15:41:45 +0000 Subject: [PATCH] re PR c++/21514 ([DR 488] templates and anonymous enum) PR c++/21514 * pt.c (check_instantiated_args): Treat uses of anonymous types as causing type-deduction failure. PR c++/21514 * g++.dg/template/crash19.C: Remove dg-error marker. * g++.dg/template/local4.C: New test. From-SVN: r104344 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 17 ++++++++++------- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/template/crash19.C | 2 +- gcc/testsuite/g++.dg/template/local4.C | 5 +---- 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 683af879ca9..91dc40597f2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2005-09-16 Mark Mitchell + + PR c++/21514 + * pt.c (check_instantiated_args): Treat uses of anonymous types as + causing type-deduction failure. + 2005-09-15 Jason Merrill PR c++/23357 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index ece96146c2e..be2f0312bdf 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -8967,7 +8967,6 @@ check_instantiated_args (tree tmpl, tree args, tsubst_flags_t complain) { int ix, len = DECL_NTPARMS (tmpl); bool result = false; - bool error_p = complain & tf_error; for (ix = 0; ix != len; ix++) { @@ -8984,12 +8983,16 @@ check_instantiated_args (tree tmpl, tree args, tsubst_flags_t complain) if (nt) { - if (TYPE_ANONYMOUS_P (nt)) - error ("%qT is/uses anonymous type", t); - else - error ("%qT uses local type %qT", t, nt); + /* DR 488 makes use of a type with no linkage causes + type deduction to fail. */ + if (complain & tf_error) + { + if (TYPE_ANONYMOUS_P (nt)) + error ("%qT is/uses anonymous type", t); + else + error ("%qT uses local type %qT", t, nt); + } result = true; - error_p = true; } /* In order to avoid all sorts of complications, we do not allow variably-modified types as template arguments. */ @@ -9011,7 +9014,7 @@ check_instantiated_args (tree tmpl, tree args, tsubst_flags_t complain) result = true; } } - if (result && error_p) + if (result && (complain & tf_error)) error (" trying to instantiate %qD", tmpl); return result; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c0a37445298..6103389ca2b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2005-09-16 Mark Mitchell + + PR c++/21514 + * g++.dg/template/crash19.C: Remove dg-error marker. + * g++.dg/template/local4.C: New test. + 2005-09-16 Paul Brook PR fortran/23906 diff --git a/gcc/testsuite/g++.dg/template/crash19.C b/gcc/testsuite/g++.dg/template/crash19.C index 59b4140c578..a28827f31ac 100644 --- a/gcc/testsuite/g++.dg/template/crash19.C +++ b/gcc/testsuite/g++.dg/template/crash19.C @@ -9,7 +9,7 @@ template struct X { enum { SIXTY_FOUR=64 }; struct node { - unsigned char *ptr[sizeof(T)*SIXTY_FOUR]; // { dg-error "" } + unsigned char *ptr[sizeof(T)*SIXTY_FOUR]; void d() {} }; node *head; diff --git a/gcc/testsuite/g++.dg/template/local4.C b/gcc/testsuite/g++.dg/template/local4.C index 20f8bf29441..cfa37364975 100644 --- a/gcc/testsuite/g++.dg/template/local4.C +++ b/gcc/testsuite/g++.dg/template/local4.C @@ -4,8 +4,5 @@ template void foo() {} int main () { struct S {}; - // We do not simply use "local|match" on line 10 because we want to - // make sure that "local" appears. - // { dg-error "local" "local" { target *-*-* } 10 } - foo (); // { dg-error "trying|match" } + foo (); // { dg-error "match" } }