Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed a typedef problem
  • Loading branch information
andydude committed Jan 5, 2015
1 parent 1dd2019 commit 18f1dda
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/C/Parser/StdC11Parser.pm6
Expand Up @@ -360,9 +360,14 @@ rule type-specifier:sym<__typeof__> { # GNU
# SS 6.7.2.1
proto rule struct-or-union-specifier {*}
rule struct-or-union-specifier:sym<decl> {
:my $previous_typedef_context;
#{ say "struct-or-union-specifier:sym<decl> 1"; }
<struct-or-union> <ident>?
'{' <struct-declaration-list> '}'
'{'
{ $previous_typedef_context = $*TYPEDEF_CONTEXT; $*TYPEDEF_CONTEXT = False; }
<struct-declaration-list>
{ $*TYPEDEF_CONTEXT = $previous_typedef_context; }
'}'
#{ say "struct-or-union-specifier:sym<decl> 2"; }
}
rule struct-or-union-specifier:sym<spec> {
Expand Down

1 comment on commit 18f1dda

@andydude
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example: 'typedef union { char __mbstate8[128]; } __mbstate_t;'

The only way I've been able to make it work so far is to distinguish between ident's that are types, and non-types, so whenever the grammar processes a typedef statement it turns on a bit, and records the name in a global hash for later. When processing the declaration specifiers for "__mbstate8", it incorrectly considered "__mbstate8" to be a type ident because the typedef bit was ON, but it should have considered "__mbstate8" to be a non-type.

So there's two overlapping issues, (1) how to distinguish between type and non-type _ident_s, and (2) how to get the ident being defined if there is not typedef bit to depend on

Please sign in to comment.