Skip to content
This repository has been archived by the owner on Feb 4, 2025. It is now read-only.

Commit

Permalink
treat -> properly
Browse files Browse the repository at this point in the history
closes #103
  • Loading branch information
jyn514 committed Dec 4, 2019
1 parent f2a774f commit de4175e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/parse/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,12 +835,15 @@ impl<I: Iterator<Item = Lexeme>> Parser<I> {
continue;
}
};
// mostly copied from Token::Star in prefix_expr
let expr = Expr {
constexpr: false,
location,
constexpr: expr.constexpr,
lval: false,
ctype: struct_type,
lval: true,
expr: ExprType::Deref(Box::new(expr)),
location,
// this is super hacky but the only way I can think of to prevent
// https://github.com/jyn514/rcc/issues/90
expr: ExprType::Noop(Box::new(expr.rval())),
};
self.struct_member(expr, id, location)?
}
Expand Down
7 changes: 7 additions & 0 deletions tests/runner-tests/expr/pointers/7.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// code: 1
struct s {
int i, j;
} my_s, *my_sp = &my_s;
int main() {
return my_sp->j = 1;
}
15 changes: 15 additions & 0 deletions tests/runner-tests/expr/pointers/8.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// code: 1
typedef unsigned int __uid_t;
extern __uid_t getuid (void) ;

struct passwd {
char *pw_name;
char *pw_passwd;
};

extern struct passwd *getpwuid (__uid_t __uid);
extern int puts (const char *__s);

int main(void) {
return puts(getpwuid(getuid())->pw_name) >= 0;
}

0 comments on commit de4175e

Please sign in to comment.