inline is not a type qualifier anymore, fix function entity creation
[cparser] / type_t.h
1 #ifndef TYPE_T_H
2 #define TYPE_T_H
3
4 #include <stdbool.h>
5
6 #include <libfirm/firm_types.h>
7
8 #include "type.h"
9 #include "symbol.h"
10 #include "token_t.h"
11 #include "ast_t.h"
12 #include "adt/obst.h"
13
14 struct obstack *type_obst;
15
16 typedef enum {
17         TYPE_INVALID,
18         TYPE_ATOMIC,
19         TYPE_COMPOUND_STRUCT,
20         TYPE_COMPOUND_UNION,
21         TYPE_ENUM,
22         TYPE_FUNCTION,
23         TYPE_POINTER,
24         TYPE_ARRAY,
25         TYPE_BUILTIN,
26         TYPE_TYPEDEF,
27         TYPE_TYPEOF
28 } type_type_t;
29
30 /* note that the constant values represent the rank of the types as defined
31  * in ยง 6.3.1 */
32 typedef enum {
33         ATOMIC_TYPE_INVALID = 0,
34         ATOMIC_TYPE_VOID,
35         ATOMIC_TYPE_CHAR,
36         ATOMIC_TYPE_SCHAR,
37         ATOMIC_TYPE_UCHAR,
38         ATOMIC_TYPE_SHORT,
39         ATOMIC_TYPE_USHORT,
40         ATOMIC_TYPE_INT,
41         ATOMIC_TYPE_UINT,
42         ATOMIC_TYPE_LONG,
43         ATOMIC_TYPE_ULONG,
44         ATOMIC_TYPE_LONGLONG,
45         ATOMIC_TYPE_ULONGLONG,
46         ATOMIC_TYPE_FLOAT,
47         ATOMIC_TYPE_DOUBLE,
48         ATOMIC_TYPE_LONG_DOUBLE,
49         ATOMIC_TYPE_BOOL,
50 #ifdef PROVIDE_COMPLEX
51         ATOMIC_TYPE_FLOAT_COMPLEX,
52         ATOMIC_TYPE_DOUBLE_COMPLEX,
53         ATOMIC_TYPE_LONG_DOUBLE_COMPLEX,
54 #endif
55 #ifdef PROVIDE_IMAGINARY
56         ATOMIC_TYPE_FLOAT_IMAGINARY,
57         ATOMIC_TYPE_DOUBLE_IMAGINARY,
58         ATOMIC_TYPE_LONG_DOUBLE_IMAGINARY,
59 #endif
60 } atomic_type_type_t;
61
62 typedef enum {
63         TYPE_QUALIFIER_CONST    = 1 << 0,
64         TYPE_QUALIFIER_RESTRICT = 1 << 1,
65         TYPE_QUALIFIER_VOLATILE = 1 << 2,
66 } type_qualifier_t;
67
68 struct type_t {
69         type_type_t       type;
70         type_qualifier_t  qualifiers;
71
72         ir_type          *firm_type;
73 };
74
75 struct atomic_type_t {
76         type_t              type;
77         atomic_type_type_t  atype;
78 };
79
80 struct builtin_type_t {
81         type_t    type;
82         symbol_t *symbol;
83         type_t   *real_type;
84 };
85
86 struct pointer_type_t {
87         type_t   type;
88         type_t  *points_to;
89 };
90
91 struct array_type_t {
92         type_t        type;
93         type_t       *element_type;
94         bool          is_static;
95         bool          is_variable;
96         expression_t *size;
97 };
98
99 struct function_parameter_t {
100         type_t               *type;
101         function_parameter_t *next;
102 };
103
104 struct function_type_t {
105         type_t                type;
106         type_t               *result_type;
107         function_parameter_t *parameters;
108         bool                  variadic;
109         bool                  unspecified_parameters;
110 };
111
112 struct compound_type_t {
113         type_t         type;
114         /** the declaration of the compound type, it's context field
115          * contains the compound entries. */
116         declaration_t *declaration;
117 };
118
119 struct enum_type_t {
120         type_t         type;
121         /** the declaration of the enum type. You can find the enum entries by
122          * walking the declaration->context_next list until you don't find
123          * STORAGE_CLASS_ENUM_ENTRY declarations anymore */
124         declaration_t *declaration;
125 };
126
127 struct typedef_type_t {
128         type_t         type;
129         declaration_t *declaration;
130 };
131
132 struct typeof_type_t {
133         type_t        type;
134         expression_t *expression;
135         type_t       *typeof_type;
136 };
137
138 type_t *make_atomic_type(atomic_type_type_t type, type_qualifier_t qualifiers);
139 type_t *make_pointer_type(type_t *points_to, type_qualifier_t qualifiers);
140
141 #endif