PR c++/34055
PR c++/34103
PR c++/34219
PR c++/34606
PR c++/34753
PR c++/34754
PR c++/34755
PR c++/34919
PR c++/34961
* c-pretty-print.c (pp_c_type_qualifier_list): Don't try to print
qualifiers for an ERROR_MARK_NODE or a NULL_TREE.
2008-01-29 Douglas Gregor <doug.gregor@gmail.com>
PR c++/34055
PR c++/34103
PR c++/34219
PR c++/34606
PR c++/34753
PR c++/34754
PR c++/34755
PR c++/34919
PR c++/34961
* typeck.c (check_return_expr): Tweak call to
check_for_bare_parameter_packs.
* class.c (add_method): Be careful with error_mark_nodes.
* cp-tree.h (check_for_bare_parameter_packs): Remove "*" from
signature.
* pt.c (struct find_parameter_pack_data): Remove
SET_PACKS_TO_ERROR.
(find_parameter_packs_r): Don't use SET_PACKS_TO_ERROR.
(uses_parameter_packs): Don't set SET_PACKS_TO_ERROR.
(make_pack_expansion): Ditto.
(check_for_bare_parameter_packs): Parameter is now a tree, not a
tree*.
(process_template_parm): Tweak call to
check_for_bare_parameter_packs.
(push_template_decl_real): Tweak calls to
check_for_bare_parameter_packs. If bare parameter packs are found
in the list of exceptions, clear out that list after giving an
error.
* semantics.c (finish_cond): Tweak call to
check_for_bare_parameter_packs.
(finish_expr_stmt): Ditto.
(finish_for_expr): Ditto.
(finish_switch_cond): Ditto.
(finish_mem_initializers): Ditto.
(finish_member_declaration): Ditto.
(finish_static_assert): Check for bare parameter packs in the
condition.
* decl2.c (cplus_decl_attributes): Check for bare parameter packs in the
attributes of a declaration.
* parser.c (cp_parser_using_declaration): Tweak call to
check_for_bare_parameter_packs.
(cp_parser_base_clause): Ditto.
2008-01-29 Douglas Gregor <doug.gregor@gmail.com>
PR c++/34055
PR c++/34103
PR c++/34219
PR c++/34606
PR c++/34753
PR c++/34754
PR c++/34755
PR c++/34919
PR c++/34961
* g++.dg/cpp0x/vt-34219-2.C: New.
* g++.dg/cpp0x/pr32126.C: Tweak expected error messages.
* g++.dg/cpp0x/vt-34961.C: New.
* g++.dg/cpp0x/vt-34055.C: Tweak error messages; add new test
cases from the re-opened PR.
* g++.dg/cpp0x/vt-34753.C: New.
* g++.dg/cpp0x/vt-34919.C: New.
* g++.dg/cpp0x/vt-34754.C: New.
* g++.dg/cpp0x/vt-34606.C: New.
* g++.dg/cpp0x/vt-34219.C: New.
* g++.dg/cpp0x/pr32125.C: Tweak expected error messages.
* g++.dg/cpp0x/vt-34755.C: New.
* g++.dg/cpp0x/pr31438.C: Ditto.
* g++.dg/cpp0x/variadic81.C: Ditto.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@131938
138bc75d-0d04-0410-961f-
82ee72b054a4
+2008-01-29 Douglas Gregor <doug.gregor@gmail.com>
+
+ PR c++/34055
+ PR c++/34103
+ PR c++/34219
+ PR c++/34606
+ PR c++/34753
+ PR c++/34754
+ PR c++/34755
+ PR c++/34919
+ PR c++/34961
+ * c-pretty-print.c (pp_c_type_qualifier_list): Don't try to print
+ qualifiers for an ERROR_MARK_NODE or a NULL_TREE.
+
2008-01-28 Andy Hutchinson <hutchinsonandy@netscape.net>
PR target/34412
void
pp_c_type_qualifier_list (c_pretty_printer *pp, tree t)
{
- int qualifiers;
+ int qualifiers;
+
+ if (!t || t == error_mark_node)
+ return;
if (!TYPE_P (t))
t = TREE_TYPE (t);
+2008-01-29 Douglas Gregor <doug.gregor@gmail.com>
+
+ PR c++/34055
+ PR c++/34103
+ PR c++/34219
+ PR c++/34606
+ PR c++/34753
+ PR c++/34754
+ PR c++/34755
+ PR c++/34919
+ PR c++/34961
+ * typeck.c (check_return_expr): Tweak call to
+ check_for_bare_parameter_packs.
+ * class.c (add_method): Be careful with error_mark_nodes.
+ * cp-tree.h (check_for_bare_parameter_packs): Remove "*" from
+ signature.
+ * pt.c (struct find_parameter_pack_data): Remove
+ SET_PACKS_TO_ERROR.
+ (find_parameter_packs_r): Don't use SET_PACKS_TO_ERROR.
+ (uses_parameter_packs): Don't set SET_PACKS_TO_ERROR.
+ (make_pack_expansion): Ditto.
+ (check_for_bare_parameter_packs): Parameter is now a tree, not a
+ tree*.
+ (process_template_parm): Tweak call to
+ check_for_bare_parameter_packs.
+ (push_template_decl_real): Tweak calls to
+ check_for_bare_parameter_packs. If bare parameter packs are found
+ in the list of exceptions, clear out that list after giving an
+ error.
+ * semantics.c (finish_cond): Tweak call to
+ check_for_bare_parameter_packs.
+ (finish_expr_stmt): Ditto.
+ (finish_for_expr): Ditto.
+ (finish_switch_cond): Ditto.
+ (finish_mem_initializers): Ditto.
+ (finish_member_declaration): Ditto.
+ (finish_static_assert): Check for bare parameter packs in the
+ condition.
+ * decl2.c (cplus_decl_attributes): Check for bare parameter packs in the
+ attributes of a declaration.
+ * parser.c (cp_parser_using_declaration): Tweak call to
+ check_for_bare_parameter_packs.
+ (cp_parser_base_clause): Ditto.
+
2008-01-28 Jason Merrill <jason@redhat.com>
PR c++/35007
coming from the using class in overload resolution. */
if (! DECL_STATIC_FUNCTION_P (fn)
&& ! DECL_STATIC_FUNCTION_P (method)
+ && TREE_TYPE (TREE_VALUE (parms1)) != error_mark_node
+ && TREE_TYPE (TREE_VALUE (parms2)) != error_mark_node
&& (TYPE_QUALS (TREE_TYPE (TREE_VALUE (parms1)))
!= TYPE_QUALS (TREE_TYPE (TREE_VALUE (parms2)))))
continue;
extern bool uses_parameter_packs (tree);
extern bool template_parameter_pack_p (const_tree);
extern tree make_pack_expansion (tree);
-extern bool check_for_bare_parameter_packs (tree*);
+extern bool check_for_bare_parameter_packs (tree);
extern tree get_template_info (tree);
extern int template_class_depth (tree);
extern int is_specialization_of (tree, tree);
type_dependent_p = dependent_type_p (type);
+ if (check_for_bare_parameter_packs (init))
+ {
+ init = NULL_TREE;
+ DECL_INITIAL (decl) = NULL_TREE;
+ }
+
if (init && init_const_expr_p)
{
DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl) = 1;
if (processing_template_decl)
{
+ if (check_for_bare_parameter_packs (attributes))
+ return;
+
save_template_attributes (&attributes, decl);
if (attributes == NULL_TREE)
return;
/* Create the USING_DECL. */
decl = do_class_using_decl (parser->scope, identifier);
- if (check_for_bare_parameter_packs (&decl))
+ if (check_for_bare_parameter_packs (decl))
return false;
else
/* Add it to the list of members in this class. */
decl = cp_parser_lookup_name_simple (parser, identifier);
if (decl == error_mark_node)
cp_parser_name_lookup_error (parser, identifier, decl, NULL);
- else if (check_for_bare_parameter_packs (&decl))
+ else if (check_for_bare_parameter_packs (decl))
return false;
else if (!at_namespace_scope_p ())
do_local_using_decl (decl, qscope, identifier);
TREE_VALUE (base) = make_pack_expansion (TREE_VALUE (base));
- if (!check_for_bare_parameter_packs (&TREE_VALUE (base)))
+ if (!check_for_bare_parameter_packs (TREE_VALUE (base)))
{
TREE_CHAIN (base) = bases;
bases = base;
/* Set of AST nodes that have been visited by the traversal. */
struct pointer_set_t *visited;
-
- /* Whether we should replace parameter packs with
- ERROR_MARK_NODE. Used by check_for_bare_parameter_packs. */
- bool set_packs_to_error;
};
/* Identifies all of the argument packs that occur in a template
(struct find_parameter_pack_data*)data;
bool parameter_pack_p = false;
- /* Don't visit nodes twice, except when we're clearing out parameter
- packs. */
+ /* Don't visit nodes twice. */
if (pointer_set_contains (ppd->visited, *tp))
{
*walk_subtrees = 0;
return NULL_TREE;
}
-recheck:
/* Identify whether this is a parameter pack or not. */
switch (TREE_CODE (t))
{
}
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;
{
/* Add this parameter pack to the list. */
*ppd->parameter_packs = tree_cons (NULL_TREE, t, *ppd->parameter_packs);
-
- if (ppd->set_packs_to_error)
- /* The caller requested that we set the parameter packs to
- ERROR_MARK_NODE so that they will not trip up the compiler
- later. The caller is responsible for emitting an error. */
- *tp = error_mark_node;
- else
- /* Make sure we do not visit this node again. */
- pointer_set_insert (ppd->visited, *tp);
}
- else
- /* Make sure we do not visit this node again. */
- pointer_set_insert (ppd->visited, *tp);
+
+ /* Make sure we do not visit this node again. */
+ pointer_set_insert (ppd->visited, *tp);
if (TYPE_P (t))
cp_walk_tree (&TYPE_CONTEXT (t),
struct find_parameter_pack_data ppd;
ppd.parameter_packs = ¶meter_packs;
ppd.visited = pointer_set_create ();
- ppd.set_packs_to_error = false;
cp_walk_tree (&t, &find_parameter_packs_r, &ppd, NULL);
pointer_set_destroy (ppd.visited);
return parameter_packs != NULL_TREE;
bool for_types = false;
struct find_parameter_pack_data ppd;
- ppd.set_packs_to_error = false;
-
if (!arg || arg == error_mark_node)
return arg;
Returns TRUE and emits an error if there were bare parameter packs,
returns FALSE otherwise. */
bool
-check_for_bare_parameter_packs (tree* t)
+check_for_bare_parameter_packs (tree t)
{
tree parameter_packs = NULL_TREE;
struct find_parameter_pack_data ppd;
- if (!processing_template_decl || !t || !*t || *t == error_mark_node)
+ if (!processing_template_decl || !t || t == error_mark_node)
return false;
- if (TREE_CODE (*t) == TYPE_DECL)
- t = &TREE_TYPE (*t);
+ if (TREE_CODE (t) == TYPE_DECL)
+ t = TREE_TYPE (t);
ppd.parameter_packs = ¶meter_packs;
ppd.visited = pointer_set_create ();
- ppd.set_packs_to_error = false;
- cp_walk_tree (t, &find_parameter_packs_r, &ppd, NULL);
+ cp_walk_tree (&t, &find_parameter_packs_r, &ppd, NULL);
pointer_set_destroy (ppd.visited);
if (parameter_packs)
tree. */
ppd.parameter_packs = ¶meter_packs;
ppd.visited = pointer_set_create ();
- ppd.set_packs_to_error = true;
- cp_walk_tree (t, &find_parameter_packs_r, &ppd, NULL);
+ cp_walk_tree (&t, &find_parameter_packs_r, &ppd, NULL);
pointer_set_destroy (ppd.visited);
return true;
{
/* This template parameter is not a parameter pack, but it
should be. Complain about "bare" parameter packs. */
- check_for_bare_parameter_packs (&TREE_TYPE (parm));
+ check_for_bare_parameter_packs (TREE_TYPE (parm));
/* Recover by calling this a parameter pack. */
is_parameter_pack = true;
while (arg && argtype)
{
if (!FUNCTION_PARAMETER_PACK_P (arg)
- && check_for_bare_parameter_packs (&TREE_TYPE (arg)))
+ && check_for_bare_parameter_packs (TREE_TYPE (arg)))
{
/* This is a PARM_DECL that contains unexpanded parameter
packs. We have already complained about this in the
/* Check for bare parameter packs in the return type and the
exception specifiers. */
- if (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));
+ if (check_for_bare_parameter_packs (TYPE_RAISES_EXCEPTIONS (type)))
+ TYPE_RAISES_EXCEPTIONS (type) = NULL_TREE;
}
- else if (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)
if (TREE_CODE (cond) == DECL_EXPR)
expr = cond;
- if (check_for_bare_parameter_packs (&expr))
+ if (check_for_bare_parameter_packs (expr))
*cond_p = error_mark_node;
}
*cond_p = expr;
else if (!type_dependent_expression_p (expr))
convert_to_void (build_non_dependent_expr (expr), "statement");
- if (check_for_bare_parameter_packs (&expr))
+ if (check_for_bare_parameter_packs (expr))
expr = error_mark_node;
/* Simplification of inner statement expressions, compound exprs,
else if (!type_dependent_expression_p (expr))
convert_to_void (build_non_dependent_expr (expr), "3rd expression in for");
expr = maybe_cleanup_point_expr_void (expr);
- if (check_for_bare_parameter_packs (&expr))
+ if (check_for_bare_parameter_packs (expr))
expr = error_mark_node;
FOR_EXPR (for_stmt) = expr;
}
cond = index;
}
}
- if (check_for_bare_parameter_packs (&cond))
+ if (check_for_bare_parameter_packs (cond))
cond = error_mark_node;
finish_cond (&SWITCH_STMT_COND (switch_stmt), cond);
SWITCH_STMT_TYPE (switch_stmt) = orig_type;
bound as part of the TREE_PURPOSE. See
make_pack_expansion for more information. */
if (TREE_CODE (TREE_PURPOSE (mem)) != TYPE_PACK_EXPANSION
- && check_for_bare_parameter_packs (&TREE_VALUE (mem)))
+ && check_for_bare_parameter_packs (TREE_VALUE (mem)))
TREE_VALUE (mem) = error_mark_node;
}
/* Check for bare parameter packs in the member variable declaration. */
if (TREE_CODE (decl) == FIELD_DECL)
{
- if (check_for_bare_parameter_packs (&TREE_TYPE (decl)))
+ if (check_for_bare_parameter_packs (TREE_TYPE (decl)))
TREE_TYPE (decl) = error_mark_node;
- if (check_for_bare_parameter_packs (&DECL_ATTRIBUTES (decl)))
+ if (check_for_bare_parameter_packs (DECL_ATTRIBUTES (decl)))
DECL_ATTRIBUTES (decl) = NULL_TREE;
}
finish_static_assert (tree condition, tree message, location_t location,
bool member_p)
{
+ if (check_for_bare_parameter_packs (condition))
+ condition = error_mark_node;
+
if (type_dependent_expression_p (condition)
|| value_dependent_expression_p (condition))
{
if (processing_template_decl)
{
current_function_returns_value = 1;
- if (check_for_bare_parameter_packs (&retval))
+ if (check_for_bare_parameter_packs (retval))
retval = error_mark_node;
return retval;
}
+2008-01-29 Douglas Gregor <doug.gregor@gmail.com>
+
+ PR c++/34055
+ PR c++/34103
+ PR c++/34219
+ PR c++/34606
+ PR c++/34753
+ PR c++/34754
+ PR c++/34755
+ PR c++/34919
+ PR c++/34961
+ * g++.dg/cpp0x/vt-34219-2.C: New.
+ * g++.dg/cpp0x/pr32126.C: Tweak expected error messages.
+ * g++.dg/cpp0x/vt-34961.C: New.
+ * g++.dg/cpp0x/vt-34055.C: Tweak error messages; add new test
+ cases from the re-opened PR.
+ * g++.dg/cpp0x/vt-34753.C: New.
+ * g++.dg/cpp0x/vt-34919.C: New.
+ * g++.dg/cpp0x/vt-34754.C: New.
+ * g++.dg/cpp0x/vt-34606.C: New.
+ * g++.dg/cpp0x/vt-34219.C: New.
+ * g++.dg/cpp0x/pr32125.C: Tweak expected error messages.
+ * g++.dg/cpp0x/vt-34755.C: New.
+ * g++.dg/cpp0x/pr31438.C: Ditto.
+ * g++.dg/cpp0x/variadic81.C: Ditto.
+
2008-01-29 Richard Sandiford <rsandifo@nildram.co.uk>
* g++.dg/torture/pr34641.C: Put the dg-do first.
// { dg-options "-std=gnu++0x" }
template<typename> struct A;
-template<typename T, typename... U> struct A<T(U)> // { dg-error "parameter packs|U|not used|U" }
-{
- template<typename X> A(X);
+template<typename T, typename... U> struct A<T(U)> // { dg-error "parameter packs|U" }
+{ // { dg-error "parameter packs|U" }
+ template<typename X> A(X); // { dg-error "parameter packs|U" }
};
A<void(int)> a(0); // { dg-error "incomplete type" }
// { dg-options "-std=c++0x" }
template<typename...> struct A;
-template<typename...T> struct A<T*> // { dg-error "not expanded|T|not used|T" }
-{
- A();
+template<typename...T> struct A<T*> // { dg-error "not expanded|T" }
+{ // { dg-error "not expanded|T" }
+ A(); // { dg-error "not expanded|T" }
A(T); // { dg-error "not expanded|T" }
};
// { dg-options "-std=c++0x" }
template<typename...> struct A;
-template<typename...T> struct A<T> // { dg-error "not expanded|T|not used|T" }
-{
+template<typename...T> struct A<T> // { dg-error "not expanded|T|" }
+{ // { dg-error "not expanded|T|" }
static int i;
};
template<typename> struct A;
template<typename... T> struct A<T*> // { dg-error "not expanded|T|not used|T" }
-{
+{ // { dg-error "not expanded|T|not used|T" }
struct B;
};
// { dg-options "-std=c++0x" }
// PR c++/34055
-template<typename...> struct A; // { dg-error "declaration" }
+template<typename...> struct A;
template<typename...T> struct A<T*> // { dg-error "parameter packs|T" }
-{
- void foo();
+{ // { dg-error "parameter packs|T" }
+ void foo(); // { dg-error "parameter packs|T|candidate" }
};
-template<typename...T> void A<T*>::foo() {} // { dg-error "invalid use" }
+template<typename...T> void A<T*>::foo() {} // { dg-error "does not match" }
+
+
+
+template<typename...> struct B;
+
+template<typename...T> struct B<T&> // { dg-error "parameter packs|T" }
+{ // { dg-error "parameter packs|T" }
+ void foo(); // { dg-error "parameter packs|T" }
+};
+
+template<typename...T> void B<T&>::foo() {} // { dg-error "does not match" }
+
+
+template<typename...> struct C;
+
+template<typename...T> struct C<T()> // { dg-error "parameter packs|T" }
+{ // { dg-error "parameter packs|T" }
+ void foo(); // { dg-error "parameter packs|T" }
+};
+
+template<typename...T> void C<T()>::foo() {} // { dg-error "does not match" }
--- /dev/null
+// { dg-options "-std=c++0x" }
+template<template<typename... T> class Comp, typename... T> void f( T... Value)
+{
+ static_assert( Comp<T>::value > 0, "" ); // { dg-error "parameter packs|T" }
+}
+
+template<template<typename... T> class Comp, typename... T> void g( T... Value)
+{
+ static_assert( Comp<T...>::value > 0, "" );
+}
+
+template <typename... T>
+struct Foo
+{
+ static const int value=1;
+};
+
+int main()
+{
+ f<Foo>( 2 );
+ g<Foo>( 2 );
+}
--- /dev/null
+// { dg-options "-std=c++0x" }
+template<typename T, T a, T... Params>
+struct max
+{
+ static const T value = a > max<T, Params>::value ? a : max<T, Params>::value; // { dg-error "not expanded|Params" }
+};
+
+template<typename T, T a, T b>
+struct max<T, a, b>
+{
+ static const T value = a > b ? a : b;
+};
+
+static const int value1 = max< int, 1, 2>::value;
+static const int value2 = max< int, 1, 3, 5>::value;
--- /dev/null
+// { dg-options "-std=c++0x" }
+template<typename...> struct A;
+
+template<typename T, typename... U> struct A<T, U> // { dg-error "parameter packs|U" }
+{ // { dg-error "parameter packs|U" }
+ template<typename> struct B;
+
+ template<typename X> struct B<X*> {}; // { dg-error "parameter packs|U" }
+};
--- /dev/null
+// { dg-options "-std=c++0x" }
+template<typename... T> struct A
+{
+ template<T> struct B {}; // { dg-error "not expanded|T" }
+};
+
+A<int>::B<0> b;
+
+template<typename... T> struct B
+{
+ template<T> B(); // { dg-error "not expanded|T" }
+};
+
+B<int> c;
--- /dev/null
+// { dg-options "-std=c++0x" }
+template<template<int> class... T> struct A
+{
+ void foo(T<0>); // { dg-error "not expanded|T" }
+ void bar(T<0>); // { dg-error "not expanded|T" }
+};
--- /dev/null
+// { dg-options "-std=c++0x" }
+template<typename> struct A {};
+
+template<template<typename> class... T> void foo(T<int>) {} // { dg-error "not expanded|T" }
+
+template void foo<A>(A<int>); // { dg-error "does not match" }
--- /dev/null
+// { dg-options "-std=c++0x" }
+template<int... N> struct A
+{
+ static void foo()
+ {
+ int i = N; // { dg-error "not expanded|N" }
+ }
+};
+
+void bar()
+{
+ A<0>::foo();
+}
--- /dev/null
+// { dg-options "-std=c++0x" }
+template<typename... T> struct A
+{
+ static const int i __attribute__((aligned(__alignof(T)))) = 0; // { dg-error "not expanded|T" }
+};
+
+A<int> a;