diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/objcp/objcp-decl.c | |
download | cbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.tar.bz2 cbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/objcp/objcp-decl.c')
-rw-r--r-- | gcc/objcp/objcp-decl.c | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/gcc/objcp/objcp-decl.c b/gcc/objcp/objcp-decl.c new file mode 100644 index 000000000..e3571c4a1 --- /dev/null +++ b/gcc/objcp/objcp-decl.c @@ -0,0 +1,145 @@ +/* Process the ObjC-specific declarations and variables for + the Objective-C++ compiler. + Copyright (C) 2005, 2007, 2010 Free Software Foundation, Inc. + Contributed by Ziemowit Laski <zlaski@apple.com> + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "tree.h" +#include "cp-tree.h" +#include "hashtab.h" + +#include "c-family/c-objc.h" +#include "objc-act.h" +#include "objcp-decl.h" + +/* Hacks to simulate start_struct() and finish_struct(). */ + +tree +objcp_start_struct (location_t loc ATTRIBUTE_UNUSED, + enum tree_code code ATTRIBUTE_UNUSED, tree name) +{ + tree s; + /* The idea here is to mimic the actions that the C++ parser takes when + constructing 'extern "C" struct NAME {'. */ + push_lang_context (lang_name_c); + + if (!name) + name = make_anon_name (); + + s = xref_tag (record_type, name, ts_global, 0); + CLASSTYPE_DECLARED_CLASS (s) = 0; /* this is a 'struct', not a 'class'. */ + xref_basetypes (s, NULL_TREE); /* no base classes here! */ + + return begin_class_definition (s, NULL_TREE); +} + +tree +objcp_finish_struct (location_t loc ATTRIBUTE_UNUSED, + tree t, tree fieldlist, tree attributes) +{ + tree field, next_field; + + for (field = fieldlist; field; field = next_field) + { + next_field = TREE_CHAIN (field); /* insert one field at a time; */ + TREE_CHAIN (field) = NULL_TREE; /* otherwise, grokfield croaks. */ + finish_member_declaration (field); + } + t = finish_struct (t, attributes); + + /* If we are inside an @interface and are generating the list of + ivars, we need to check for duplicate ivars. + */ + if (fieldlist) + { + tree original_fieldlist = fieldlist; + fieldlist = objc_get_interface_ivars (fieldlist); + if (fieldlist != original_fieldlist) + { + /* Minimal implementation of the equivalent of the C + front-end's detect_field_duplicates(). + */ + htab_t htab = htab_create (37, htab_hash_pointer, htab_eq_pointer, NULL); + tree x, y; + void **slot; + + for (x = fieldlist; x ; x = DECL_CHAIN (x)) + if ((y = DECL_NAME (x)) != 0) + { + slot = htab_find_slot (htab, y, INSERT); + if (*slot) + { + error ("duplicate member %q+D", x); + DECL_NAME (x) = NULL_TREE; + } + *slot = y; + } + + htab_delete (htab); + } + } + + pop_lang_context (); + + return t; +} + +void +objcp_finish_function (void) +{ + /* The C++ flavor of 'finish_function' does not generate RTL -- one has + to call 'expand_or_defer_fn' to do that. */ + expand_or_defer_fn (finish_function (0)); +} + +tree +objcp_xref_tag (enum tree_code code ATTRIBUTE_UNUSED, tree name) +{ + return xref_tag (record_type, name, ts_global, false); +} + +int +objcp_comptypes (tree type1, tree type2) +{ + return comptypes (type1, type2, COMPARE_STRICT); +} + +tree +objcp_begin_compound_stmt (int flags ATTRIBUTE_UNUSED) +{ + return begin_compound_stmt (0); +} + +tree +objcp_end_compound_stmt (tree stmt, int flags ATTRIBUTE_UNUSED) +{ + /* The following has been snarfed from + cp/semantics.c:finish_compound_stmt(). */ + if (TREE_CODE (stmt) == BIND_EXPR) + BIND_EXPR_BODY (stmt) = do_poplevel (BIND_EXPR_BODY (stmt)); + else if (STATEMENT_LIST_NO_SCOPE (stmt)) + stmt = pop_stmt_list (stmt); + else + stmt = do_poplevel (stmt); + + return stmt; +} |