1/* Language-specific hook definitions for C front end. 2 Copyright (C) 1991, 1995, 1997, 1998 Free Software Foundation, Inc. 3 4This file is part of GNU CC. 5 6GNU CC is free software; you can redistribute it and/or modify 7it under the terms of the GNU General Public License as published by 8the Free Software Foundation; either version 2, or (at your option) 9any later version. 10 11GNU CC is distributed in the hope that it will be useful, 12but WITHOUT ANY WARRANTY; without even the implied warranty of 13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14GNU General Public License for more details. 15 16You should have received a copy of the GNU General Public License 17along with GNU CC; see the file COPYING. If not, write to 18the Free Software Foundation, 59 Temple Place - Suite 330, 19Boston, MA 02111-1307, USA. */ 20 21 22#include "config.h" 23#include "system.h" 24#include "tree.h" 25#include "input.h" 26#include "c-tree.h" 27#include "c-lex.h" 28#include "toplev.h" 29#include "output.h" 30 31#if USE_CPPLIB 32#include "cpplib.h" 33extern char *yy_cur; 34extern cpp_reader parse_in; 35extern cpp_options parse_options; 36#endif 37 38/* Each of the functions defined here 39 is an alternative to a function in objc-actions.c. */ 40 41int 42lang_decode_option (argc, argv) 43 int argc; 44 char **argv; 45{ 46 return c_decode_option (argc, argv); 47} 48 49void 50lang_init_options () 51{ 52#if USE_CPPLIB 53 cpp_reader_init (&parse_in); 54 parse_in.opts = &parse_options; 55 cpp_options_init (&parse_options); 56#endif 57} 58 59void 60lang_init () 61{ 62 /* the beginning of the file is a new line; check for # */ 63 /* With luck, we discover the real source file's name from that 64 and put it in input_filename. */ 65#if !USE_CPPLIB 66 ungetc (check_newline (), finput); 67#else 68 check_newline (); 69 yy_cur--; 70#endif 71} 72 73void 74lang_finish () 75{ 76} 77 78char * 79lang_identify () 80{ 81 return "c"; 82} 83 84void 85print_lang_statistics () 86{ 87} 88 89/* used by print-tree.c */ 90 91void 92lang_print_xnode (file, node, indent) 93 FILE *file ATTRIBUTE_UNUSED; 94 tree node ATTRIBUTE_UNUSED; 95 int indent ATTRIBUTE_UNUSED; 96{ 97} 98 99/* Used by c-lex.c, but only for objc. */ 100 101tree 102lookup_interface (arg) 103 tree arg ATTRIBUTE_UNUSED; 104{ 105 return 0; 106} 107 108tree 109is_class_name (arg) 110 tree arg ATTRIBUTE_UNUSED; 111{ 112 return 0; 113} 114 115void 116maybe_objc_check_decl (decl) 117 tree decl ATTRIBUTE_UNUSED; 118{ 119} 120 121int 122maybe_objc_comptypes (lhs, rhs, reflexive) 123 tree lhs ATTRIBUTE_UNUSED; 124 tree rhs ATTRIBUTE_UNUSED; 125 int reflexive ATTRIBUTE_UNUSED; 126{ 127 return -1; 128} 129 130tree 131maybe_objc_method_name (decl) 132 tree decl ATTRIBUTE_UNUSED; 133{ 134 return 0; 135} 136 137tree 138maybe_building_objc_message_expr () 139{ 140 return 0; 141} 142 143int 144recognize_objc_keyword () 145{ 146 return 0; 147} 148 149tree 150build_objc_string (len, str) 151 int len ATTRIBUTE_UNUSED; 152 const char *str ATTRIBUTE_UNUSED; 153{ 154 abort (); 155 return NULL_TREE; 156} 157 158/* Called at end of parsing, but before end-of-file processing. */ 159 160void 161finish_file () 162{ 163#ifndef ASM_OUTPUT_CONSTRUCTOR 164 extern tree static_ctors; 165#endif 166#ifndef ASM_OUTPUT_DESTRUCTOR 167 extern tree static_dtors; 168#endif 169 extern tree build_function_call PROTO((tree, tree)); 170#if !defined(ASM_OUTPUT_CONSTRUCTOR) || !defined(ASM_OUTPUT_DESTRUCTOR) 171 tree void_list_node = build_tree_list (NULL_TREE, void_type_node); 172#endif 173#ifndef ASM_OUTPUT_CONSTRUCTOR 174 if (static_ctors) 175 { 176 tree fnname = get_file_function_name ('I'); 177 start_function (void_list_node, 178 build_parse_node (CALL_EXPR, fnname, 179 tree_cons (NULL_TREE, NULL_TREE, 180 void_list_node), 181 NULL_TREE), 182 NULL_TREE, NULL_TREE, 0); 183 fnname = DECL_ASSEMBLER_NAME (current_function_decl); 184 store_parm_decls (); 185 186 for (; static_ctors; static_ctors = TREE_CHAIN (static_ctors)) 187 expand_expr_stmt (build_function_call (TREE_VALUE (static_ctors), 188 NULL_TREE)); 189 190 finish_function (0); 191 192 assemble_constructor (IDENTIFIER_POINTER (fnname)); 193 } 194#endif 195#ifndef ASM_OUTPUT_DESTRUCTOR 196 if (static_dtors) 197 { 198 tree fnname = get_file_function_name ('D'); 199 start_function (void_list_node, 200 build_parse_node (CALL_EXPR, fnname, 201 tree_cons (NULL_TREE, NULL_TREE, 202 void_list_node), 203 NULL_TREE), 204 NULL_TREE, NULL_TREE, 0); 205 fnname = DECL_ASSEMBLER_NAME (current_function_decl); 206 store_parm_decls (); 207 208 for (; static_dtors; static_dtors = TREE_CHAIN (static_dtors)) 209 expand_expr_stmt (build_function_call (TREE_VALUE (static_dtors), 210 NULL_TREE)); 211 212 finish_function (0); 213 214 assemble_destructor (IDENTIFIER_POINTER (fnname)); 215 } 216#endif 217} 218