00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "config.h"
00022 #include "system.h"
00023 #include "coretypes.h"
00024 #include "tm.h"
00025 #include "tree.h"
00026 #include "rtl.h"
00027 #include "insn-config.h"
00028 #include "integrate.h"
00029 #include "c-tree.h"
00030 #include "c-pretty-print.h"
00031 #include "function.h"
00032 #include "flags.h"
00033 #include "toplev.h"
00034 #include "diagnostic.h"
00035 #include "tree-inline.h"
00036 #include "varray.h"
00037 #include "ggc.h"
00038 #include "langhooks.h"
00039 #include "tree-mudflap.h"
00040 #include "target.h"
00041 #include "c-objc-common.h"
00042
00043 static bool c_tree_printer (pretty_printer *, text_info *);
00044
00045 bool
00046 c_missing_noreturn_ok_p (tree decl)
00047 {
00048
00049
00050 return flag_hosted && MAIN_NAME_P (DECL_ASSEMBLER_NAME (decl));
00051 }
00052
00053
00054
00055
00056
00057 int
00058 c_disregard_inline_limits (tree fn)
00059 {
00060 if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) != NULL)
00061 return 1;
00062
00063 return (!flag_really_no_inline && DECL_DECLARED_INLINE_P (fn)
00064 && DECL_EXTERNAL (fn));
00065 }
00066
00067 int
00068 c_cannot_inline_tree_fn (tree *fnp)
00069 {
00070 tree fn = *fnp;
00071 bool do_warning = (warn_inline
00072 && DECL_INLINE (fn)
00073 && DECL_DECLARED_INLINE_P (fn)
00074 && !DECL_IN_SYSTEM_HEADER (fn));
00075
00076 if (flag_really_no_inline
00077 && lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) == NULL)
00078 {
00079 if (do_warning)
00080 warning ("%Jfunction %qF can never be inlined because it "
00081 "is suppressed using -fno-inline", fn, fn);
00082 goto cannot_inline;
00083 }
00084
00085
00086
00087 if (!DECL_DECLARED_INLINE_P (fn) && !targetm.binds_local_p (fn))
00088 {
00089 if (do_warning)
00090 warning ("%Jfunction %qF can never be inlined because it might not "
00091 "be bound within this unit of translation", fn, fn);
00092 goto cannot_inline;
00093 }
00094
00095 if (!function_attribute_inlinable_p (fn))
00096 {
00097 if (do_warning)
00098 warning ("%Jfunction %qF can never be inlined because it uses "
00099 "attributes conflicting with inlining", fn, fn);
00100 goto cannot_inline;
00101 }
00102
00103 return 0;
00104
00105 cannot_inline:
00106 DECL_UNINLINABLE (fn) = 1;
00107 return 1;
00108 }
00109
00110
00111
00112 bool
00113 c_warn_unused_global_decl (tree decl)
00114 {
00115 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl))
00116 return false;
00117 if (DECL_IN_SYSTEM_HEADER (decl))
00118 return false;
00119
00120 return true;
00121 }
00122
00123
00124 bool
00125 c_objc_common_init (void)
00126 {
00127 static const enum tree_code stmt_codes[] = {
00128 c_common_stmt_codes
00129 };
00130
00131 INIT_STATEMENT_CODES (stmt_codes);
00132
00133 c_init_decl_processing ();
00134
00135 if (c_common_init () == false)
00136 return false;
00137
00138
00139
00140
00141 diagnostic_format_decoder (global_dc) = &c_tree_printer;
00142
00143
00144
00145 if (mesg_implicit_function_declaration < 0)
00146 {
00147 if (flag_isoc99)
00148 mesg_implicit_function_declaration = flag_pedantic_errors ? 2 : 1;
00149 else
00150 mesg_implicit_function_declaration = 0;
00151 }
00152
00153 return true;
00154 }
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168 static bool
00169 c_tree_printer (pretty_printer *pp, text_info *text)
00170 {
00171 tree t = va_arg (*text->args_ptr, tree);
00172 tree name;
00173 const char *n = "({anonymous})";
00174 c_pretty_printer *cpp = (c_pretty_printer *) pp;
00175 pp->padding = pp_none;
00176
00177 switch (*text->format_spec)
00178 {
00179 case 'D':
00180 if (DECL_DEBUG_EXPR (t) && DECL_DEBUG_EXPR_IS_FROM (t))
00181 {
00182 t = DECL_DEBUG_EXPR (t);
00183 if (!DECL_P (t))
00184 {
00185 pp_c_expression (cpp, t);
00186 return true;
00187 }
00188 }
00189
00190
00191 case 'F':
00192 if (DECL_NAME (t))
00193 n = lang_hooks.decl_printable_name (t, 2);
00194 break;
00195
00196 case 'T':
00197 gcc_assert (TYPE_P (t));
00198 name = TYPE_NAME (t);
00199
00200 if (name && TREE_CODE (name) == TYPE_DECL)
00201 {
00202 if (DECL_NAME (name))
00203 pp_string (cpp, lang_hooks.decl_printable_name (name, 2));
00204 else
00205 pp_type_id (cpp, t);
00206 return true;
00207 }
00208 else
00209 {
00210 pp_type_id (cpp, t);
00211 return true;
00212 }
00213 break;
00214
00215 case 'E':
00216 if (TREE_CODE (t) == IDENTIFIER_NODE)
00217 n = IDENTIFIER_POINTER (t);
00218 else
00219 {
00220 pp_expression (cpp, t);
00221 return true;
00222 }
00223 break;
00224
00225 default:
00226 return false;
00227 }
00228
00229 pp_string (cpp, n);
00230 return true;
00231 }
00232
00233 tree
00234 c_objc_common_truthvalue_conversion (tree expr)
00235 {
00236 retry:
00237 switch (TREE_CODE (TREE_TYPE (expr)))
00238 {
00239 case ARRAY_TYPE:
00240 expr = default_conversion (expr);
00241 if (TREE_CODE (TREE_TYPE (expr)) != ARRAY_TYPE)
00242 goto retry;
00243
00244 error ("used array that cannot be converted to pointer where scalar is required");
00245 return error_mark_node;
00246
00247 case RECORD_TYPE:
00248 error ("used struct type value where scalar is required");
00249 return error_mark_node;
00250
00251 case UNION_TYPE:
00252 error ("used union type value where scalar is required");
00253 return error_mark_node;
00254 default:
00255 break;
00256 }
00257
00258 return c_common_truthvalue_conversion (expr);
00259 }
00260
00261
00262 bool
00263 has_c_linkage (tree decl ATTRIBUTE_UNUSED)
00264 {
00265 return true;
00266 }
00267
00268 void
00269 c_initialize_diagnostics (diagnostic_context *context)
00270 {
00271 pretty_printer *base = context->printer;
00272 c_pretty_printer *pp = XNEW (c_pretty_printer);
00273 memcpy (pp_base (pp), base, sizeof (pretty_printer));
00274 pp_c_pretty_printer_init (pp);
00275 context->printer = (pretty_printer *) pp;
00276
00277
00278 XDELETE (base);
00279 }
00280
00281 int
00282 c_types_compatible_p (tree x, tree y)
00283 {
00284 return comptypes (TYPE_MAIN_VARIANT (x), TYPE_MAIN_VARIANT (y));
00285 }