/* Definitions for C++ parsing and type checking.
Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
Contributed by Michael Tiemann (tiemann@cygnus.com)
This file is part of GCC.
#define DECL_TEMPLATE_TEMPLATE_PARM_P(NODE) \
(TREE_CODE (NODE) == TEMPLATE_DECL && DECL_TEMPLATE_PARM_P (NODE))
+/* Nonzero if NODE is a TEMPLATE_DECL representing an
+ UNBOUND_CLASS_TEMPLATE tree node. */
+#define DECL_UNBOUND_CLASS_TEMPLATE_P(NODE) \
+ (TREE_CODE (NODE) == TEMPLATE_DECL && !DECL_TEMPLATE_RESULT (NODE))
+
#define DECL_FUNCTION_TEMPLATE_P(NODE) \
(TREE_CODE (NODE) == TEMPLATE_DECL \
+ && !DECL_UNBOUND_CLASS_TEMPLATE_P (NODE) \
&& TREE_CODE (DECL_TEMPLATE_RESULT (NODE)) == FUNCTION_DECL)
/* Nonzero for a DECL that represents a template class. */
#define DECL_CLASS_TEMPLATE_P(NODE) \
(TREE_CODE (NODE) == TEMPLATE_DECL \
+ && !DECL_UNBOUND_CLASS_TEMPLATE_P (NODE) \
&& TREE_CODE (DECL_TEMPLATE_RESULT (NODE)) == TYPE_DECL \
&& !DECL_TEMPLATE_TEMPLATE_PARM_P (NODE))
/* C++ Parser.
- Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
Written by Mark Mitchell <mark@codesourcery.com>.
This file is part of GCC.
/* Utility Routines */
static tree cp_parser_lookup_name
- (cp_parser *, tree, bool, bool, bool);
+ (cp_parser *, tree, bool, bool, bool, bool);
static tree cp_parser_lookup_name_simple
(cp_parser *, tree);
static tree cp_parser_maybe_treat_template_as_class
default-argument. */
if (cp_lexer_next_token_is (parser->lexer, CPP_EQ))
{
+ bool is_template;
+
/* Consume the `='. */
cp_lexer_consume_token (parser->lexer);
/* Parse the id-expression. */
= cp_parser_id_expression (parser,
/*template_keyword_p=*/false,
/*check_dependency_p=*/true,
- /*template_p=*/NULL,
+ /*template_p=*/&is_template,
/*declarator_p=*/false);
/* Look up the name. */
default_argument
- = cp_parser_lookup_name_simple (parser, default_argument);
+ = cp_parser_lookup_name (parser, default_argument,
+ /*is_type=*/false,
+ /*is_template=*/is_template,
+ /*is_namespace=*/false,
+ /*check_dependency=*/true);
/* See if the default argument is valid. */
default_argument
= check_template_template_default_arg (default_argument);
/* Look up the name. */
decl = cp_parser_lookup_name (parser, identifier,
/*is_type=*/false,
+ /*is_template=*/false,
/*is_namespace=*/false,
check_dependency_p);
decl = maybe_get_template_decl_from_type_decl (decl);
cp_parser_lookup_name. */
decl = cp_parser_lookup_name (parser, identifier,
/*is_type=*/true,
+ /*is_template=*/false,
/*is_namespace=*/false,
/*check_dependency=*/true);
operator.) */
namespace_decl = cp_parser_lookup_name (parser, identifier,
/*is_type=*/false,
+ /*is_template=*/false,
/*is_namespace=*/true,
/*check_dependency=*/true);
/* If it's not a namespace, issue an error. */
/* Look up the name. */
decl = cp_parser_lookup_name (parser, identifier,
type_p,
+ /*is_template=*/false,
/*is_namespace=*/false,
check_dependency_p);
}
If IS_TYPE is TRUE, bindings that do not refer to types are
ignored.
+ If IS_TEMPLATE is TRUE, bindings that do not refer to templates are
+ ignored.
+
If IS_NAMESPACE is TRUE, bindings that do not refer to namespaces
are ignored.
static tree
cp_parser_lookup_name (cp_parser *parser, tree name,
- bool is_type, bool is_namespace, bool check_dependency)
+ bool is_type, bool is_template, bool is_namespace,
+ bool check_dependency)
{
tree decl;
tree object_type = parser->context->object_type;
if ((check_dependency || !CLASS_TYPE_P (parser->scope))
&& dependent_p)
{
- if (!is_type)
- decl = build_nt (SCOPE_REF, parser->scope, name);
- else
+ if (is_type)
/* The resolution to Core Issue 180 says that `struct A::B'
should be considered a type-name, even if `A' is
dependent. */
decl = TYPE_NAME (make_typename_type (parser->scope,
name,
/*complain=*/1));
+ else if (is_template)
+ decl = TYPE_NAME (make_unbound_class_template (parser->scope,
+ name,
+ /*complain=*/1));
+ else
+ decl = build_nt (SCOPE_REF, parser->scope, name);
}
else
{
}
/* Like cp_parser_lookup_name, but for use in the typical case where
- CHECK_ACCESS is TRUE, IS_TYPE is FALSE, and CHECK_DEPENDENCY is
- TRUE. */
+ CHECK_ACCESS is TRUE, IS_TYPE is FALSE, IS_TEMPLATE is FALSE,
+ IS_NAMESPACE is FALSE, and CHECK_DEPENDENCY is TRUE. */
static tree
cp_parser_lookup_name_simple (cp_parser* parser, tree name)
{
return cp_parser_lookup_name (parser, name,
/*is_type=*/false,
+ /*is_template=*/false,
/*is_namespace=*/false,
/*check_dependency=*/true);
}
--- /dev/null
+// { dg-do compile }
+
+// Origin: Philippe Van Deyck <hetadres@email.com>
+
+// PR c++/13520: Default template template argument that is a qualified id
+// with dependent scope.
+
+template<typename regular_type> class Policy {};
+
+template <typename regular_type, template<typename> class OriginalPolicy>
+class ChangedPolicy_impl {};
+
+template <template<typename> class OriginalPolicy > class ChangedPolicy {
+public:
+ template<typename regular_type> class Type : public
+ ChangedPolicy_impl<regular_type,OriginalPolicy> { };
+};
+
+template <typename regular_type, template<typename> class Policy1,
+ template<typename> class Policy2
+ = ChangedPolicy<Policy1>::template Type>
+class Host : public Policy1<regular_type>, public Policy2<regular_type> { };
+
+int main()
+{
+ Host<void, Policy> h;
+ return 0;
+}