aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@adacore.com>2010-10-29 10:03:43 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2010-10-29 12:03:43 +0200
commit1e4bf85b80166e3315532ba50608fd5e19411f32 (patch)
tree0e45c1489e9211aba58ccd281c74237649502fdb /gcc
parentf3f637378c413c7f584910be7cc741b83cb40cd8 (diff)
downloadgcc-1e4bf85b80166e3315532ba50608fd5e19411f32.zip
gcc-1e4bf85b80166e3315532ba50608fd5e19411f32.tar.gz
gcc-1e4bf85b80166e3315532ba50608fd5e19411f32.tar.bz2
c-ada-spec.c (separate_class_package): New function.
* 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. Co-Authored-By: Matthew Gingell <gingell@adacore.com> From-SVN: r166059
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-family/ChangeLog8
-rw-r--r--gcc/c-family/c-ada-spec.c31
2 files changed, 36 insertions, 3 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 4c18990..51b7b32 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,11 @@
+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.
diff --git a/gcc/c-family/c-ada-spec.c b/gcc/c-family/c-ada-spec.c
index d8910a8..455151a 100644
--- a/gcc/c-family/c-ada-spec.c
+++ b/gcc/c-family/c-ada-spec.c
@@ -51,6 +51,7 @@ static void dump_ada_withs (FILE *);
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)
@@ -1152,6 +1153,23 @@ to_ada_name (const char *name, int *space_found)
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
@@ -1209,7 +1227,15 @@ pp_ada_tree_identifier (pretty_printer *buffer, tree node, tree type,
default:
break;
}
- }
+
+ if (separate_class_package (decl))
+ {
+ pp_string (buffer, "Class_");
+ pp_string (buffer, s);
+ pp_string (buffer, ".");
+ }
+
+ }
}
}
@@ -2607,8 +2633,7 @@ print_ada_declaration (pretty_printer *buffer, tree t, tree type,
{
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_");