Stop LCC from warning about null pointer conversion to function pointer

Fixed LCC to correctly diagnose expressions with NPC. It no longer reports messages such as

    warning: conversion from `pointer to void' to `pointer to void function(void)' is compiler dependent
This commit is contained in:
Jun Woong 2014-12-10 15:26:29 +09:00 committed by Zack Middleton
parent dd82b9d1a8
commit 8469c40c2b
3 changed files with 3 additions and 3 deletions

View file

@ -577,6 +577,7 @@ extern Tree cnsttree(Type, ...);
extern Tree consttree(unsigned int, Type); extern Tree consttree(unsigned int, Type);
extern Tree eqtree(int, Tree, Tree); extern Tree eqtree(int, Tree, Tree);
extern int iscallb(Tree); extern int iscallb(Tree);
extern int isnullptr(Tree);
extern Tree shtree(int, Tree, Tree); extern Tree shtree(int, Tree, Tree);
extern void typeerror(int, Tree, Tree); extern void typeerror(int, Tree, Tree);

View file

@ -5,7 +5,6 @@ static Tree addtree(int, Tree, Tree);
static Tree andtree(int, Tree, Tree); static Tree andtree(int, Tree, Tree);
static Tree cmptree(int, Tree, Tree); static Tree cmptree(int, Tree, Tree);
static int compatible(Type, Type); static int compatible(Type, Type);
static int isnullptr(Tree e);
static Tree multree(int, Tree, Tree); static Tree multree(int, Tree, Tree);
static Tree subtree(int, Tree, Tree); static Tree subtree(int, Tree, Tree);
#define isvoidptr(ty) \ #define isvoidptr(ty) \
@ -220,7 +219,7 @@ static int compatible(Type ty1, Type ty2) {
&& isptr(ty2) && !isfunc(ty2->type) && isptr(ty2) && !isfunc(ty2->type)
&& eqtype(unqual(ty1->type), unqual(ty2->type), 0); && eqtype(unqual(ty1->type), unqual(ty2->type), 0);
} }
static int isnullptr(Tree e) { int isnullptr(Tree e) {
Type ty = unqual(e->type); Type ty = unqual(e->type);
return generic(e->op) == CNST return generic(e->op) == CNST

View file

@ -621,7 +621,7 @@ Tree cast(Tree p, Type type) {
p = simplify(CVP, dst, p, NULL); p = simplify(CVP, dst, p, NULL);
else { else {
if ((isfunc(src->type) && !isfunc(dst->type)) 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); warning("conversion from `%t' to `%t' is compiler dependent\n", p->type, type);
if (src->size != dst->size) if (src->size != dst->size)