===================================================================
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.
/* In c-ada-spec.c */
typedef enum {
+ HAS_DEPENDENT_TEMPLATE_ARGS,
IS_ABSTRACT,
IS_CONSTRUCTOR,
IS_DESTRUCTOR,
===================================================================
@@ -601,9 +601,12 @@ collect_ada_nodes (tree t, const char *s
tree n;
int i = to_dump_count;
- /* Count the likely relevant nodes. */
+ /* Count the likely relevant nodes: do not dump builtins (they are irrelevant
+ in the context of bindings) and namespaces (we do not handle them properly
+ yet). */
for (n = t; n; n = TREE_CHAIN (n))
if (!DECL_IS_BUILTIN (n)
+ && TREE_CODE (n) != NAMESPACE_DECL
&& LOCATION_FILE (decl_sloc (n, false)) == source_file)
to_dump_count++;
@@ -613,6 +616,7 @@ collect_ada_nodes (tree t, const char *s
/* Store the relevant nodes. */
for (n = t; n; n = TREE_CHAIN (n))
if (!DECL_IS_BUILTIN (n)
+ && TREE_CODE (n) != NAMESPACE_DECL
&& LOCATION_FILE (decl_sloc (n, false)) == source_file)
to_dump[i++] = n;
}
@@ -1753,7 +1757,7 @@ dump_ada_template (pretty_printer *buffe
!= LOCATION_FILE (decl_sloc (t, false)))
return 0;
- while (inst && inst != error_mark_node)
+ for (; inst && inst != error_mark_node; inst = TREE_CHAIN (inst))
{
tree types = TREE_PURPOSE (inst);
tree instance = TREE_VALUE (inst);
@@ -1764,6 +1768,13 @@ dump_ada_template (pretty_printer *buffe
if (!RECORD_OR_UNION_TYPE_P (instance) || !TYPE_METHODS (instance))
break;
+ /* We are interested in concrete template instantiations only: skip
+ partially specialized nodes. */
+ if ((TREE_CODE (instance) == RECORD_TYPE
+ || TREE_CODE (instance) == UNION_TYPE)
+ && cpp_check && cpp_check (instance, HAS_DEPENDENT_TEMPLATE_ARGS))
+ continue;
+
num_inst++;
INDENT (spc);
pp_string (buffer, "package ");
@@ -1799,8 +1810,6 @@ dump_ada_template (pretty_printer *buffe
pp_semicolon (buffer);
pp_newline (buffer);
pp_newline (buffer);
-
- inst = TREE_CHAIN (inst);
}
return num_inst > 0;
===================================================================
@@ -4044,6 +4044,16 @@ cpp_check (tree t, cpp_operation op)
{
switch (op)
{
+ case HAS_DEPENDENT_TEMPLATE_ARGS:
+ {
+ tree ti = CLASSTYPE_TEMPLATE_INFO (t);
+ if (!ti)
+ return 0;
+ ++processing_template_decl;
+ const bool dep = any_dependent_template_arguments_p (TI_ARGS (ti));
+ --processing_template_decl;
+ return dep;
+ }
case IS_ABSTRACT:
return DECL_PURE_VIRTUAL_P (t);
case IS_CONSTRUCTOR: