Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed to correctly diagnose expressions with NPC #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/c.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ extern Tree cnsttree(Type, ...);
extern Tree consttree(int, Type);
extern Tree eqtree(int, Tree, Tree);
extern int iscallb(Tree);
extern int isnullptr(Tree);
extern Tree shtree(int, Tree, Tree);
extern void typeerror(int, Tree, Tree);

Expand Down
3 changes: 1 addition & 2 deletions src/enode.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ static Tree addtree(int, Tree, Tree);
static Tree andtree(int, Tree, Tree);
static Tree cmptree(int, Tree, Tree);
static int compatible(Type, Type);
static int isnullptr(Tree e);
static Tree multree(int, Tree, Tree);
static Tree subtree(int, Tree, Tree);
#define isvoidptr(ty) \
Expand Down Expand Up @@ -226,7 +225,7 @@ static int compatible(Type ty1, Type ty2) {
&& isptr(ty2) && !isfunc(ty2->type)
&& eqtype(unqual(ty1->type), unqual(ty2->type), 0);
}
static int isnullptr(Tree e) {
int isnullptr(Tree e) {
Type ty = unqual(e->type);

return generic(e->op) == CNST
Expand Down
2 changes: 1 addition & 1 deletion src/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ Tree cast(Tree p, Type type) {
p = simplify(CVP, dst, p, NULL);
else {
if (isfunc(src->type) && !isfunc(dst->type)
|| !isfunc(src->type) && isfunc(dst->type))
|| !isnullptr(p) && !isfunc(src->type) && isfunc(dst->type))
warning("conversion from `%t' to `%t' is compiler dependent\n", p->type, type);

if (src->size != dst->size)
Expand Down