From 046e40718070e75485fd70ff7d4349596bb7630a Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 13 Nov 2007 19:27:09 +0100 Subject: [PATCH] re PR c++/34054 (ICE with parameter pack in return type) PR c++/34054 PR c++/34056 PR c++/34057 PR c++/34058 PR c++/34060 * pt.c (find_parameter_packs_r): If ppd->set_packs_to_error, set to error_mark_node the outermost POINTER_TYPE to the pack if it is seen in a POINTER_TYPE. (push_template_decl_real): If check_for_bare_parameter_packs fails for function return type, set the return type to integer_type_node. If check_for_bare_parameter_packs failed for non-function, return error_mark_node. * g++.dg/parse/crash36.C: Add another dg-error. * g++.dg/cpp0x/pr34054.C: New test. * g++.dg/cpp0x/pr34056.C: New test. * g++.dg/cpp0x/pr34057.C: New test. * g++.dg/cpp0x/pr34058.C: New test. * g++.dg/cpp0x/pr34060.C: New test. From-SVN: r130152 --- gcc/cp/ChangeLog | 13 +++++++++++++ gcc/cp/pt.c | 22 ++++++++++++++++++---- gcc/testsuite/ChangeLog | 12 ++++++++++++ gcc/testsuite/g++.dg/cpp0x/pr34054.C | 5 +++++ gcc/testsuite/g++.dg/cpp0x/pr34056.C | 10 ++++++++++ gcc/testsuite/g++.dg/cpp0x/pr34057.C | 8 ++++++++ gcc/testsuite/g++.dg/cpp0x/pr34058.C | 10 ++++++++++ gcc/testsuite/g++.dg/cpp0x/pr34060.C | 11 +++++++++++ gcc/testsuite/g++.dg/parse/crash36.C | 2 +- 9 files changed, 88 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr34054.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr34056.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr34057.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr34058.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr34060.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1bcad75c1ce..efc48a95bd7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,18 @@ 2007-11-13 Jakub Jelinek + PR c++/34054 + PR c++/34056 + PR c++/34057 + PR c++/34058 + PR c++/34060 + * pt.c (find_parameter_packs_r): If ppd->set_packs_to_error, + set to error_mark_node the outermost POINTER_TYPE to the pack if + it is seen in a POINTER_TYPE. + (push_template_decl_real): If check_for_bare_parameter_packs + fails for function return type, set the return type to + integer_type_node. If check_for_bare_parameter_packs failed + for non-function, return error_mark_node. + PR c++/29225 * call.c (build_new_op): Call resolve_args before calling build_over_call. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 0339a8c02d3..8a95ccf7f74 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -2454,6 +2454,7 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data) return NULL_TREE; } +recheck: /* Identify whether this is a parameter pack or not. */ switch (TREE_CODE (t)) { @@ -2478,6 +2479,16 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data) } break; + case POINTER_TYPE: + if (ppd->set_packs_to_error) + /* Pointer types are shared, set in that case the outermost + POINTER_TYPE to error_mark_node rather than the parameter pack. */ + { + t = TREE_TYPE (t); + goto recheck; + } + break; + default: /* Not a parameter pack. */ break; @@ -2553,7 +2564,6 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data) ppd, NULL); *walk_subtrees = 0; return NULL_TREE; - case TYPE_PACK_EXPANSION: case EXPR_PACK_EXPANSION: @@ -3864,11 +3874,15 @@ push_template_decl_real (tree decl, bool is_friend) /* Check for bare parameter packs in the return type and the exception specifiers. */ - check_for_bare_parameter_packs (&TREE_TYPE (type)); + if (!check_for_bare_parameter_packs (&TREE_TYPE (type))) + /* Errors were already issued, set return type to int + as the frontend doesn't expect error_mark_node as + the return type. */ + TREE_TYPE (type) = integer_type_node; check_for_bare_parameter_packs (&TYPE_RAISES_EXCEPTIONS (type)); } - else - check_for_bare_parameter_packs (&TREE_TYPE (decl)); + else if (!check_for_bare_parameter_packs (&TREE_TYPE (decl))) + return error_mark_node; if (is_partial) return process_partial_specialization (decl); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7a5f41af85b..f4337d28539 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,17 @@ 2007-11-13 Jakub Jelinek + PR c++/34054 + PR c++/34056 + PR c++/34057 + PR c++/34058 + PR c++/34060 + * g++.dg/parse/crash36.C: Add another dg-error. + * g++.dg/cpp0x/pr34054.C: New test. + * g++.dg/cpp0x/pr34056.C: New test. + * g++.dg/cpp0x/pr34057.C: New test. + * g++.dg/cpp0x/pr34058.C: New test. + * g++.dg/cpp0x/pr34060.C: New test. + PR tree-optimization/34063 * g++.dg/tree-ssa/pr34063.C: New test. diff --git a/gcc/testsuite/g++.dg/cpp0x/pr34054.C b/gcc/testsuite/g++.dg/cpp0x/pr34054.C new file mode 100644 index 00000000000..cfc6c4bdc76 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr34054.C @@ -0,0 +1,5 @@ +// PR c++/34054 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template T foo() {} // { dg-error "not expanded|T" } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr34056.C b/gcc/testsuite/g++.dg/cpp0x/pr34056.C new file mode 100644 index 00000000000..0e5246b6ab6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr34056.C @@ -0,0 +1,10 @@ +// PR c++/34056 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template struct A +{ + void foo (T *) { ++p; } // { dg-error "not expanded|T" } + void bar (T **) { } // { dg-error "not expanded|T" } + T *p; // { dg-error "not expanded|T" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr34057.C b/gcc/testsuite/g++.dg/cpp0x/pr34057.C new file mode 100644 index 00000000000..38da5ff5015 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr34057.C @@ -0,0 +1,8 @@ +// PR c++/34057 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template struct A +{ + typedef T X __attribute__ ((vector_size (8))); // { dg-error "not expanded|T" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr34058.C b/gcc/testsuite/g++.dg/cpp0x/pr34058.C new file mode 100644 index 00000000000..0cf1faec73f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr34058.C @@ -0,0 +1,10 @@ +// PR c++/34058 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template struct A +{ + typedef T X; // { dg-error "not expanded|T" } +}; + +A a; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr34060.C b/gcc/testsuite/g++.dg/cpp0x/pr34060.C new file mode 100644 index 00000000000..8e0d321b2ac --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr34060.C @@ -0,0 +1,11 @@ +// PR c++/34060 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template struct A +{ + template struct B {}; + template struct B {}; // { dg-error "not expanded|T" } +}; + +A<0>::Bb; diff --git a/gcc/testsuite/g++.dg/parse/crash36.C b/gcc/testsuite/g++.dg/parse/crash36.C index e73e928350d..bcd96e4ec1f 100644 --- a/gcc/testsuite/g++.dg/parse/crash36.C +++ b/gcc/testsuite/g++.dg/parse/crash36.C @@ -5,7 +5,7 @@ template struct A // { dg-error "does not include variadic templates" } { static T &t; // { dg-error "not expanded with|T" } - static const int i = sizeof (++t); + static const int i = sizeof (++t); // { dg-error "was not declared in this scope" } }; int x[A ::i]; // { dg-error "is not an integral constant-expression" }