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
This commit is contained in:
Jakub Jelinek 2007-11-13 19:27:09 +01:00 committed by Jakub Jelinek
parent f6ee9faefc
commit 046e407180
9 changed files with 88 additions and 5 deletions

View File

@ -1,5 +1,18 @@
2007-11-13 Jakub Jelinek <jakub@redhat.com>
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.

View File

@ -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);

View File

@ -1,5 +1,17 @@
2007-11-13 Jakub Jelinek <jakub@redhat.com>
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.

View File

@ -0,0 +1,5 @@
// PR c++/34054
// { dg-do compile }
// { dg-options "-std=c++0x" }
template<typename... T> T foo() {} // { dg-error "not expanded|T" }

View File

@ -0,0 +1,10 @@
// PR c++/34056
// { dg-do compile }
// { dg-options "-std=c++0x" }
template<typename... T> 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" }
};

View File

@ -0,0 +1,8 @@
// PR c++/34057
// { dg-do compile }
// { dg-options "-std=c++0x" }
template <typename... T> struct A
{
typedef T X __attribute__ ((vector_size (8))); // { dg-error "not expanded|T" }
};

View File

@ -0,0 +1,10 @@
// PR c++/34058
// { dg-do compile }
// { dg-options "-std=c++0x" }
template <typename...T> struct A
{
typedef T X; // { dg-error "not expanded|T" }
};
A<int> a;

View File

@ -0,0 +1,11 @@
// PR c++/34060
// { dg-do compile }
// { dg-options "-std=c++0x" }
template <int> struct A
{
template <typename... > struct B {};
template <typename... T> struct B <int, T *> {}; // { dg-error "not expanded|T" }
};
A<0>::B<int>b;

View File

@ -5,7 +5,7 @@
template <typename... T> 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 <int>::i]; // { dg-error "is not an integral constant-expression" }