arocc icon indicating copy to clipboard operation
arocc copied to clipboard

Duplicate `long` typedef disallowed

Open ehaas opened this issue 1 year ago • 3 comments

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 avatar Jul 31 '24 06:07 ehaas

Happens because the existing typedef we find here: https://github.com/Vexu/arocc/blob/8ab72a4b1a4ff445b39b1f6d23fe2cbe59f37763/src/aro/Parser.zig#L2069

Gets combined with long to form a long long specifier here: https://github.com/Vexu/arocc/blob/8ab72a4b1a4ff445b39b1f6d23fe2cbe59f37763/src/aro/Parser.zig#L2070

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;
                ^

ehaas avatar Aug 01 '24 18:08 ehaas

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

aidenfoxivey avatar Aug 17 '24 00:08 aidenfoxivey

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

Vexu avatar Aug 17 '24 10:08 Vexu