Repository navigation
kencc: `auto <type> <name>;' parses -- root the C23 declarator at LNAME - #609
Merged
Merged
Conversation
The first pcc run over EDG's generated C stopped on the fourth file:
array_new_aligned.c:25 syntax error, last name: __T41392176
`autoadlist' began with `xdecor', and `xdecor -> xdecor2 -> tag ->
ltag -> LNAME | LTYPE', so after LAUTO the parser could SHIFT a
typedef name as the variable being declared. That collides with
`cname: LAUTO', the storage-class reduction, and yacc resolves
shift/reduce in favour of SHIFT -- so `auto size_t x;' took the C23
deduction path, read `size_t' as the NAME, and died on the next token.
EDG's C writes `auto <type> <name>;' for every local: 116,079 of them
across 103 of its 133 files, so one conflict blocked the whole port.
-std= would not have fixed this. The conflict is resolved when yacc
builds the table, so no runtime flag has a say; and there is no
dialect disagreement to arbitrate, because C23 kept `auto' as a
storage-class specifier and its type inference applies only where
`auto' is the sole type specifier. Both standards want the same
answer. The grammar can decide alone, since `size_t' is LTYPE and `x'
is LNAME: a new `autoxdecor' roots the first declarator at LNAME, so
LTYPE leaves the shift set and that lookahead reduces to the storage
class. `*' still shifts -- `auto *p = &x;' is deduction, while
`auto *p;' as a storage class would need implicit int.
Measured with bison, since kencc's sources need Plan 9's <u.h> and
<libc.h> and cannot be compiled on the host:
before after
shift/reduce 26 22
reduce/reduce 6 6 (pre-existing, LTYPEOF)
state 417 (adecl) 4 2 LTYPE and '(' shifts gone
state 517 (forexpr) 4 2 same, renumbered from 513
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first pcc run over EDG's generated C stopped on the fourth file:
array_new_aligned.c:25 syntax error, last name: __T41392176
autoadlist' began withxdecor', andxdecor -> xdecor2 -> tag -> ltag -> LNAME | LTYPE', so after LAUTO the parser could SHIFT a typedef name as the variable being declared. That collides withcname: LAUTO', the storage-class reduction, and yacc resolves shift/reduce in favour of SHIFT -- soauto size_t x;' took the C23 deduction path, readsize_t' as the NAME, and died on the next token.EDG's C writes `auto ;' for every local: 116,079 of them across 103 of its 133 files, so one conflict blocked the whole port.
-std= would not have fixed this. The conflict is resolved when yacc builds the table, so no runtime flag has a say; and there is no dialect disagreement to arbitrate, because C23 kept
auto' as a storage-class specifier and its type inference applies only whereauto' is the sole type specifier. Both standards want the same answer. The grammar can decide alone, sincesize_t' is LTYPE andx' is LNAME: a newautoxdecor' roots the first declarator at LNAME, so LTYPE leaves the shift set and that lookahead reduces to the storage class.*' still shifts --auto *p = &x;' is deduction, whileauto *p;' as a storage class would need implicit int.Measured with bison, since kencc's sources need Plan 9's <u.h> and <libc.h> and cannot be compiled on the host:
shift/reduce 26 22
reduce/reduce 6 6 (pre-existing, LTYPEOF)
state 417 (adecl) 4 2 LTYPE and '(' shifts gone
state 517 (forexpr) 4 2 same, renumbered from 513
Claude-Session: https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs