OSDN Git Service

Move declarations and building code for common tree nodes to tree.[ch]
[pf3gnuchains/gcc-fork.git] / gcc / c-common.h
1 /* Definitions for c-common.c.
2    Copyright (C) 1987, 93, 94, 95, 97, 98, 1999 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING.  If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20
21 /* Standard named or nameless data types of the C compiler.  */
22
23 enum c_tree_index
24 {
25     CTI_WCHAR_TYPE,
26     CTI_SIGNED_WCHAR_TYPE,
27     CTI_UNSIGNED_WCHAR_TYPE,
28     CTI_WIDEST_INT_LIT_TYPE,
29     CTI_WIDEST_UINT_LIT_TYPE,
30
31     CTI_CHAR_ARRAY_TYPE,
32     CTI_WCHAR_ARRAY_TYPE,
33     CTI_INT_ARRAY_TYPE,
34     CTI_STRING_TYPE,
35     CTI_CONST_STRING_TYPE,
36
37     CTI_BOOLEAN_TYPE,
38     CTI_BOOLEAN_TRUE,
39     CTI_BOOLEAN_FALSE,
40     CTI_DEFAULT_FUNCTION_TYPE,
41     CTI_VOID_LIST,
42
43     CTI_VOID_FTYPE,
44     CTI_VOID_FTYPE_PTR,
45     CTI_INT_FTYPE_INT,
46     CTI_PTR_FTYPE_SIZETYPE,
47     
48     CTI_MAX
49 };
50
51 extern tree c_global_trees[CTI_MAX];
52
53 #define wchar_type_node                 c_global_trees[CTI_WCHAR_TYPE]
54 #define signed_wchar_type_node          c_global_trees[CTI_SIGNED_WCHAR_TYPE]
55 #define unsigned_wchar_type_node        c_global_trees[CTI_UNSIGNED_WCHAR_TYPE]
56 #define widest_integer_literal_type_node c_global_trees[CTI_WIDEST_INT_LIT_TYPE]
57 #define widest_unsigned_literal_type_node c_global_trees[CTI_WIDEST_UINT_LIT_TYPE]
58
59 #define boolean_type_node               c_global_trees[CTI_BOOLEAN_TYPE]
60 #define boolean_true_node               c_global_trees[CTI_BOOLEAN_TRUE]
61 #define boolean_false_node              c_global_trees[CTI_BOOLEAN_FALSE]
62
63 #define char_array_type_node            c_global_trees[CTI_CHAR_ARRAY_TYPE]
64 #define wchar_array_type_node           c_global_trees[CTI_WCHAR_ARRAY_TYPE]
65 #define int_array_type_node             c_global_trees[CTI_INT_ARRAY_TYPE]
66 #define string_type_node                c_global_trees[CTI_STRING_TYPE]
67 #define const_string_type_node          c_global_trees[CTI_CONST_STRING_TYPE]
68
69 #define default_function_type           c_global_trees[CTI_DEFAULT_FUNCTION_TYPE]
70 #define void_list_node                  c_global_trees[CTI_VOID_LIST]
71 #define void_ftype                      c_global_trees[CTI_VOID_FTYPE]
72 #define void_ftype_ptr                  c_global_trees[CTI_VOID_FTYPE_PTR]
73 #define int_ftype_int                   c_global_trees[CTI_INT_FTYPE_INT]
74 #define ptr_ftype_sizetype              c_global_trees[CTI_PTR_FTYPE_SIZETYPE]
75
76 extern void declare_function_name               PROTO((void));
77 extern void decl_attributes                     PROTO((tree, tree, tree));
78 extern void init_function_format_info           PROTO((void));
79 extern void check_function_format               PROTO((tree, tree, tree));
80 extern void c_apply_type_quals_to_decl          PROTO((int, tree));
81 extern int c_get_alias_set                      PROTO((tree));
82 /* Print an error message for invalid operands to arith operation CODE.
83    NOP_EXPR is used as a special case (see truthvalue_conversion).  */
84 extern void binary_op_error                     PROTO((enum tree_code));
85 extern void c_expand_expr_stmt                  PROTO((tree));
86 extern void c_expand_start_cond                 PROTO((tree, int, int));
87 extern void c_expand_start_else                 PROTO((void));
88 extern void c_expand_end_cond                   PROTO((void));
89 /* Validate the expression after `case' and apply default promotions.  */
90 extern tree check_case_value                    PROTO((tree));
91 /* Concatenate a list of STRING_CST nodes into one STRING_CST.  */
92 extern tree combine_strings                     PROTO((tree));
93 extern void constant_expression_warning         PROTO((tree));
94 extern tree convert_and_check                   PROTO((tree, tree));
95 extern void overflow_warning                    PROTO((tree));
96 extern void unsigned_conversion_warning         PROTO((tree, tree));
97 /* Read the rest of the current #-directive line.  */
98 #if USE_CPPLIB
99 extern char *get_directive_line                 PROTO((void));
100 #define GET_DIRECTIVE_LINE() get_directive_line ()
101 #else
102 extern char *get_directive_line                 PROTO((FILE *));
103 #define GET_DIRECTIVE_LINE() get_directive_line (finput)
104 #endif
105
106 /* Subroutine of build_binary_op, used for comparison operations.
107    See if the operands have both been converted from subword integer types
108    and, if so, perhaps change them both back to their original type.  */
109 extern tree shorten_compare                     PROTO((tree *, tree *, tree *, enum tree_code *));
110 /* Prepare expr to be an argument of a TRUTH_NOT_EXPR,
111    or validate its data type for an `if' or `while' statement or ?..: exp. */
112 extern tree truthvalue_conversion               PROTO((tree));
113 extern tree type_for_mode                       PROTO((enum machine_mode, int));
114 extern tree type_for_size                       PROTO((unsigned, int));
115
116 /* Declare a predefined function.  Return the declaration.  This function is
117    provided by each language frontend.  */
118 extern tree builtin_function                    PROTO((const char *, tree, enum built_in_function, const char *));
119
120 /* Build tree nodes and builtin functions common to both C and C++ language
121    frontends.  */
122 extern void c_common_nodes_and_builtins         PROTO((int, int, int));
123
124 extern tree build_va_arg                        PROTO((tree, tree));
125
126 extern tree initializer_constant_valid_p        PROTO((tree, tree));
127
128 /* Nonzero if the type T promotes to itself.
129    ANSI C states explicitly the list of types that promote;
130    in particular, short promotes to int even if they have the same width.  */
131 #define C_PROMOTING_INTEGER_TYPE_P(t)                           \
132   (TREE_CODE ((t)) == INTEGER_TYPE                              \
133    && (TYPE_MAIN_VARIANT (t) == char_type_node                  \
134        || TYPE_MAIN_VARIANT (t) == signed_char_type_node        \
135        || TYPE_MAIN_VARIANT (t) == unsigned_char_type_node      \
136        || TYPE_MAIN_VARIANT (t) == short_integer_type_node      \
137        || TYPE_MAIN_VARIANT (t) == short_unsigned_type_node))
138
139 extern int self_promoting_args_p                PROTO((tree));
140 extern tree simple_type_promotes_to             PROTO((tree));