+2010-10-29 Arnaud Charlet <charlet@adacore.com>
+ Matthew Gingell <gingell@adacore.com>
+
+ * c-ada-spec.c (separate_class_package): New function.
+ (pp_ada_tree_identifier): Prefix references to C++ classes with the
+ name of their enclosing package.
+ (print_ada_declaration): Use separate_class_package.
+
2010-10-27 Jason Merrill <jason@redhat.com>
* c-common.c (c_common_reswords): Add __is_literal_type.
static void dump_ads (const char *, void (*)(const char *),
int (*)(tree, cpp_operation));
static char *to_ada_name (const char *, int *);
+static bool separate_class_package (tree);
#define LOCATION_COL(LOC) ((expand_location (LOC)).column)
return s;
}
+/* Return true if DECL refers to a C++ class type for which a
+ separate enclosing package has been or should be generated. */
+
+static bool
+separate_class_package (tree decl)
+{
+ if (decl)
+ {
+ tree type = TREE_TYPE (decl);
+ return type
+ && TREE_CODE (type) == RECORD_TYPE
+ && (TYPE_METHODS (type) || has_static_fields (type));
+ }
+ else
+ return false;
+}
+
static bool package_prefix = true;
/* Dump in BUFFER the name of an identifier NODE of type TYPE, following Ada
default:
break;
}
- }
+
+ if (separate_class_package (decl))
+ {
+ pp_string (buffer, "Class_");
+ pp_string (buffer, s);
+ pp_string (buffer, ".");
+ }
+
+ }
}
}
{
dump_nested_types (buffer, t, t, false, cpp_check, spc);
- if (TYPE_METHODS (TREE_TYPE (t))
- || has_static_fields (TREE_TYPE (t)))
+ if (separate_class_package (t))
{
is_class = true;
pp_string (buffer, "package Class_");