History

tccgen.c: In parse_btype, handle typedef types with added type qualifiers.

In a case like typedef int T[1]; const T x; we must make a copy of the typedef type so that we can add the type qualifiers to it. The following code used to give error: incompatible types for redefinition of 'f' typedef int T[1]; void f(const int [1]); void f(const T);

Edmund Grimley Evans committed 10 years ago

Commit 30c54c91 parent 58a34d21 file · +11 −1Browse files

Unified · Split

tccgen.c+11−1
@@ -3314,7 +3314,17 @@ static int parse_btype(CType *type, AttributeDef *ad) · 3313 unmodified lines
3314 if (!s || !(s->type.t & VT_TYPEDEF))3314 if (!s || !(s->type.t & VT_TYPEDEF))
3315 goto the_end;3315 goto the_end;
3316 t |= (s->type.t & ~VT_TYPEDEF);3316 t |= (s->type.t & ~VT_TYPEDEF);
3317 type->ref = s->type.ref;3317 if ((t & VT_ARRAY) &&
3318 t & (VT_CONSTANT | VT_VOLATILE) & ~s->type.ref->type.t) {
3319 /* This is a case like "typedef int T[1]; const T x;"
3320 in which which we must make a copy of the typedef
3321 type so that we can add the type qualifiers to it. */
3322 type->ref = sym_push(SYM_FIELD, &s->type.ref->type,
3323 0, s->type.ref->c);
3324 type->ref->type.t |= t & (VT_CONSTANT | VT_VOLATILE);
3325 }
3326 else
3327 type->ref = s->type.ref;
3318 if (s->r) {3328 if (s->r) {
3319 /* get attributes from typedef */3329 /* get attributes from typedef */
3320 if (0 == ad->a.aligned)3330 if (0 == ad->a.aligned)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t