1/* Process the ObjC-specific declarations and variables for 2 the Objective-C++ compiler. 3 Copyright (C) 2005-2015 Free Software Foundation, Inc. 4 Contributed by Ziemowit Laski <zlaski@apple.com> 5 6This file is part of GCC. 7 8GCC is free software; you can redistribute it and/or modify it under 9the terms of the GNU General Public License as published by the Free 10Software Foundation; either version 3, or (at your option) any later 11version. 12 13GCC is distributed in the hope that it will be useful, but WITHOUT ANY 14WARRANTY; without even the implied warranty of MERCHANTABILITY or 15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16for more details. 17 18You should have received a copy of the GNU General Public License 19along with GCC; see the file COPYING3. If not see 20<http://www.gnu.org/licenses/>. */ 21 22#include "config.h" 23#include "system.h" 24#include "coretypes.h" 25#include "tm.h" 26#include "hash-set.h" 27#include "machmode.h" 28#include "vec.h" 29#include "double-int.h" 30#include "input.h" 31#include "alias.h" 32#include "symtab.h" 33#include "options.h" 34#include "wide-int.h" 35#include "inchash.h" 36#include "tree.h" 37#include "cp-tree.h" 38 39#include "c-family/c-objc.h" 40#include "objc-act.h" 41#include "objcp-decl.h" 42 43/* Hacks to simulate start_struct() and finish_struct(). */ 44 45tree 46objcp_start_struct (location_t loc ATTRIBUTE_UNUSED, 47 enum tree_code code ATTRIBUTE_UNUSED, tree name) 48{ 49 tree s; 50 /* The idea here is to mimic the actions that the C++ parser takes when 51 constructing 'extern "C" struct NAME {'. */ 52 push_lang_context (lang_name_c); 53 54 if (!name) 55 name = make_anon_name (); 56 57 s = xref_tag (record_type, name, ts_global, 0); 58 CLASSTYPE_DECLARED_CLASS (s) = 0; /* this is a 'struct', not a 'class'. */ 59 xref_basetypes (s, NULL_TREE); /* no base classes here! */ 60 61 return begin_class_definition (s); 62} 63 64tree 65objcp_finish_struct (location_t loc ATTRIBUTE_UNUSED, 66 tree t, tree fieldlist, tree attributes) 67{ 68 tree field, next_field; 69 70 for (field = fieldlist; field; field = next_field) 71 { 72 next_field = TREE_CHAIN (field); /* insert one field at a time; */ 73 TREE_CHAIN (field) = NULL_TREE; /* otherwise, grokfield croaks. */ 74 finish_member_declaration (field); 75 } 76 t = finish_struct (t, attributes); 77 78 /* If we are inside an @interface and are generating the list of 79 ivars, we need to check for duplicate ivars. 80 */ 81 if (fieldlist) 82 objc_detect_field_duplicates (true); 83 84 pop_lang_context (); 85 86 return t; 87} 88 89void 90objcp_finish_function (void) 91{ 92 /* The C++ flavor of 'finish_function' does not generate RTL -- one has 93 to call 'expand_or_defer_fn' to do that. */ 94 expand_or_defer_fn (finish_function (0)); 95} 96 97tree 98objcp_xref_tag (enum tree_code code ATTRIBUTE_UNUSED, tree name) 99{ 100 return xref_tag (record_type, name, ts_global, false); 101} 102 103int 104objcp_comptypes (tree type1, tree type2) 105{ 106 return comptypes (type1, type2, COMPARE_STRICT); 107} 108 109tree 110objcp_begin_compound_stmt (int flags ATTRIBUTE_UNUSED) 111{ 112 return begin_compound_stmt (0); 113} 114 115tree 116objcp_end_compound_stmt (tree stmt, int flags ATTRIBUTE_UNUSED) 117{ 118 /* The following has been snarfed from 119 cp/semantics.c:finish_compound_stmt(). */ 120 if (TREE_CODE (stmt) == BIND_EXPR) 121 BIND_EXPR_BODY (stmt) = do_poplevel (BIND_EXPR_BODY (stmt)); 122 else if (STATEMENT_LIST_NO_SCOPE (stmt)) 123 stmt = pop_stmt_list (stmt); 124 else 125 stmt = do_poplevel (stmt); 126 127 return stmt; 128} 129