Skip to content

Commit

Permalink
sizeof works on pointer types now
Browse files Browse the repository at this point in the history
  • Loading branch information
QFSW committed Mar 26, 2019
1 parent a5488f2 commit 0dbdaf7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/c_parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,13 @@ IDENTIFIER_LIST

TYPE_NAME
: SPECIFIER_QUALIFIER_LIST
| SPECIFIER_QUALIFIER_LIST ABSTRACT_DECLARATOR
| SPECIFIER_QUALIFIER_LIST ABSTRACT_DECLARATOR { $$ = $2; }
;

ABSTRACT_DECLARATOR
: POINTER
: POINTER { $$ = new PointerType(new PrimitiveType(PrimitiveType::PrimitiveTypeEnum::_int)); }
| DIRECT_ABSTRACT_DECLARATOR
| POINTER DIRECT_ABSTRACT_DECLARATOR
| POINTER DIRECT_ABSTRACT_DECLARATOR { $$ = new PointerType($1); }
;

DIRECT_ABSTRACT_DECLARATOR
Expand Down
4 changes: 1 addition & 3 deletions test/parser/testProgram.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
int sizeof_long()
{
int x;
int arr[4];
return sizeof(arr);
return sizeof(int**);
}

0 comments on commit 0dbdaf7

Please sign in to comment.