aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--symbol.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/symbol.c b/symbol.c
index 6fcb1b15..7f0c8558 100644
--- a/symbol.c
+++ b/symbol.c
@@ -307,6 +307,29 @@ void merge_type(struct symbol *sym, struct symbol *base_type)
merge_type(sym, sym->ctype.base_type);
}
+static bool is_wstring_expr(struct expression *expr)
+{
+ while (expr) {
+ switch (expr->type) {
+ case EXPR_STRING:
+ return 1;
+ case EXPR_INITIALIZER:
+ if (expression_list_size(expr->expr_list) != 1)
+ return 0;
+ expr = first_expression(expr->expr_list);
+ break;
+ case EXPR_PREOP:
+ if (expr->op == '(') {
+ expr = expr->unop;
+ break;
+ }
+ default:
+ return 0;
+ }
+ }
+ return 0;
+}
+
static int count_array_initializer(struct symbol *t, struct expression *expr)
{
int nr = 0;
@@ -321,6 +344,8 @@ static int count_array_initializer(struct symbol *t, struct expression *expr)
*/
if (t->ctype.base_type == &int_type && t->rank == -2)
is_char = 1;
+ else if (t == wchar_ctype && is_wstring_expr(expr))
+ is_char = 1;
switch (expr->type) {
case EXPR_INITIALIZER: {