Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate long typedef disallowed #731

Closed
ehaas opened this issue Jul 31, 2024 · 3 comments · Fixed by #808
Closed

Duplicate long typedef disallowed #731

ehaas opened this issue Jul 31, 2024 · 3 comments · Fixed by #808
Labels
bug Something isn't working

Comments

@ehaas
Copy link
Collaborator

ehaas commented Jul 31, 2024

Duplicate typedefs should be allowed if they're equal. This one is weird; it seems it only happens for long (not long int or unsigned long or any other specifier):

typedef long foo;
typedef long foo;
test.c:2:17: error: expected identifier or '('
typedef long foo;
                ^
@ehaas ehaas added the bug Something isn't working label Jul 31, 2024
@ehaas
Copy link
Collaborator Author

ehaas commented Aug 1, 2024

Happens because the existing typedef we find here:

const typedef = (try p.syms.findTypedef(p, interned_name, p.tok_i, ty.specifier != .none)) orelse break;

Gets combined with long to form a long long specifier here:

if (!ty.combineTypedef(p, typedef.ty, typedef.tok)) break;

That also led me to suspect other patterns could trigger it:

typedef double foo;
typedef long foo;
test.c:2:17: error: expected identifier or '('
typedef long foo;
                ^

@aidenfoxivey
Copy link

Is there error message here also considered a bug? It seems pretty vague - like I wouldn't understand it by default.

@Vexu
Copy link
Owner

Vexu commented Aug 17, 2024

The bug here is that there shouldn't be any errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants