Commit 7e4da766 authored by Richard Pospesel's avatar Richard Pospesel Committed by Alexandre Julliard

widl: Store the "const" type qualifier inside the decl_spec_t structure.

parent df948ccc
...@@ -521,11 +521,11 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc ...@@ -521,11 +521,11 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc
break; break;
case EXPR_STRLIT: case EXPR_STRLIT:
result.is_temporary = TRUE; result.is_temporary = TRUE;
result.type = type_new_pointer(FC_UP, type_new_int(TYPE_BASIC_CHAR, 0), NULL); result.type = type_new_pointer(FC_UP, type_new_int(TYPE_BASIC_CHAR, 0));
break; break;
case EXPR_WSTRLIT: case EXPR_WSTRLIT:
result.is_temporary = TRUE; result.is_temporary = TRUE;
result.type = type_new_pointer(FC_UP, type_new_int(TYPE_BASIC_WCHAR, 0), NULL); result.type = type_new_pointer(FC_UP, type_new_int(TYPE_BASIC_WCHAR, 0));
break; break;
case EXPR_CHARCONST: case EXPR_CHARCONST:
result.is_temporary = TRUE; result.is_temporary = TRUE;
...@@ -575,7 +575,7 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc ...@@ -575,7 +575,7 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc
expr_loc->attr ? expr_loc->attr : ""); expr_loc->attr ? expr_loc->attr : "");
result.is_variable = FALSE; result.is_variable = FALSE;
result.is_temporary = TRUE; result.is_temporary = TRUE;
result.type = type_new_pointer(FC_UP, result.type, NULL); result.type = type_new_pointer(FC_UP, result.type);
break; break;
case EXPR_PPTR: case EXPR_PPTR:
result = resolve_expression(expr_loc, cont_type, e->ref); result = resolve_expression(expr_loc, cont_type, e->ref);
......
...@@ -318,8 +318,7 @@ void write_type_left(FILE *h, const decl_spec_t *ds, enum name_type name_type, i ...@@ -318,8 +318,7 @@ void write_type_left(FILE *h, const decl_spec_t *ds, enum name_type name_type, i
name = type_get_name(t, name_type); name = type_get_name(t, name_type);
if (is_attr(t->attrs, ATTR_CONST) && if ((ds->qualifier & TYPE_QUALIFIER_CONST) && (type_is_alias(t) || !is_ptr(t)))
(type_is_alias(t) || !is_ptr(t)))
fprintf(h, "const "); fprintf(h, "const ");
if (type_is_alias(t)) fprintf(h, "%s", t->name); if (type_is_alias(t)) fprintf(h, "%s", t->name);
...@@ -369,7 +368,7 @@ void write_type_left(FILE *h, const decl_spec_t *ds, enum name_type name_type, i ...@@ -369,7 +368,7 @@ void write_type_left(FILE *h, const decl_spec_t *ds, enum name_type name_type, i
{ {
write_type_left(h, type_pointer_get_ref(t), name_type, declonly, FALSE); write_type_left(h, type_pointer_get_ref(t), name_type, declonly, FALSE);
write_pointer_left(h, type_pointer_get_ref_type(t)); write_pointer_left(h, type_pointer_get_ref_type(t));
if (is_attr(t->attrs, ATTR_CONST)) fprintf(h, "const "); if (ds->qualifier & TYPE_QUALIFIER_CONST) fprintf(h, "const ");
break; break;
} }
case TYPE_ARRAY: case TYPE_ARRAY:
...@@ -813,17 +812,17 @@ static void write_typedef(FILE *header, type_t *type) ...@@ -813,17 +812,17 @@ static void write_typedef(FILE *header, type_t *type)
int is_const_decl(const var_t *var) int is_const_decl(const var_t *var)
{ {
const type_t *t; const decl_spec_t *t;
/* strangely, MIDL accepts a const attribute on any pointer in the /* strangely, MIDL accepts a const attribute on any pointer in the
* declaration to mean that data isn't being instantiated. this appears * declaration to mean that data isn't being instantiated. this appears
* to be a bug, but there is no benefit to being incompatible with MIDL, * to be a bug, but there is no benefit to being incompatible with MIDL,
* so we'll do the same thing */ * so we'll do the same thing */
for (t = var->declspec.type; ; ) for (t = &var->declspec; ; )
{ {
if (is_attr(t->attrs, ATTR_CONST)) if (t->qualifier & TYPE_QUALIFIER_CONST)
return TRUE; return TRUE;
else if (is_ptr(t)) else if (is_ptr(t->type))
t = type_pointer_get_ref_type(t); t = type_pointer_get_ref(t->type);
else break; else break;
} }
return FALSE; return FALSE;
......
...@@ -176,12 +176,11 @@ type_t *type_new_function(var_list_t *args) ...@@ -176,12 +176,11 @@ type_t *type_new_function(var_list_t *args)
return t; return t;
} }
type_t *type_new_pointer(unsigned char pointer_default, type_t *ref, attr_list_t *attrs) type_t *type_new_pointer(unsigned char pointer_default, type_t *ref)
{ {
type_t *t = make_type(TYPE_POINTER); type_t *t = make_type(TYPE_POINTER);
t->details.pointer.def_fc = pointer_default; t->details.pointer.def_fc = pointer_default;
t->details.pointer.ref.type = ref; t->details.pointer.ref.type = ref;
t->attrs = attrs;
return t; return t;
} }
......
...@@ -30,7 +30,7 @@ enum name_type { ...@@ -30,7 +30,7 @@ enum name_type {
}; };
type_t *type_new_function(var_list_t *args); type_t *type_new_function(var_list_t *args);
type_t *type_new_pointer(unsigned char pointer_default, type_t *ref, attr_list_t *attrs); type_t *type_new_pointer(unsigned char pointer_default, type_t *ref);
type_t *type_new_alias(const decl_spec_t *t, const char *name); type_t *type_new_alias(const decl_spec_t *t, const char *name);
type_t *type_new_module(char *name); type_t *type_new_module(char *name);
type_t *type_new_array(const char *name, const decl_spec_t *element, int declptr, type_t *type_new_array(const char *name, const decl_spec_t *element, int declptr,
......
...@@ -81,7 +81,6 @@ enum attr_type ...@@ -81,7 +81,6 @@ enum attr_type
ATTR_CASE, ATTR_CASE,
ATTR_CODE, ATTR_CODE,
ATTR_COMMSTATUS, ATTR_COMMSTATUS,
ATTR_CONST, /* const pseudo-attribute */
ATTR_CONTEXTHANDLE, ATTR_CONTEXTHANDLE,
ATTR_CONTROL, ATTR_CONTROL,
ATTR_DECODE, ATTR_DECODE,
...@@ -235,6 +234,11 @@ enum storage_class ...@@ -235,6 +234,11 @@ enum storage_class
STG_REGISTER, STG_REGISTER,
}; };
enum type_qualifier
{
TYPE_QUALIFIER_CONST = 1,
};
enum statement_type enum statement_type
{ {
STMT_LIBRARY, STMT_LIBRARY,
...@@ -299,6 +303,7 @@ struct _decl_spec_t ...@@ -299,6 +303,7 @@ struct _decl_spec_t
type_t *type; type_t *type;
attr_list_t *attrs; attr_list_t *attrs;
enum storage_class stgclass; enum storage_class stgclass;
enum type_qualifier qualifier;
}; };
struct _attr_t { struct _attr_t {
...@@ -478,6 +483,7 @@ struct _var_t { ...@@ -478,6 +483,7 @@ struct _var_t {
struct _declarator_t { struct _declarator_t {
var_t *var; var_t *var;
type_t *type; type_t *type;
enum type_qualifier qualifier;
expr_t *bits; expr_t *bits;
/* parser-internal */ /* parser-internal */
...@@ -626,6 +632,7 @@ static inline decl_spec_t *init_declspec(decl_spec_t *declspec, type_t *type) ...@@ -626,6 +632,7 @@ static inline decl_spec_t *init_declspec(decl_spec_t *declspec, type_t *type)
declspec->type = type; declspec->type = type;
declspec->attrs = NULL; declspec->attrs = NULL;
declspec->stgclass = STG_NONE; declspec->stgclass = STG_NONE;
declspec->qualifier = 0;
return declspec; return declspec;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment