summaryrefslogtreecommitdiff
path: root/src/tools/lcc
diff options
context:
space:
mode:
authorJun Woong <woong.jun@gmail.com>2014-12-10 15:26:29 +0900
committerTim Angus <tim@ngus.net>2015-03-17 11:39:12 +0000
commita7acfa1fe1fafcbf87d161a12186ffbbb58010e0 (patch)
tree2017b40ac8b04c1e1afdbf96ff3900c8ac36a68c /src/tools/lcc
parentf9e07391d15c775a586c10c88e57ec69fe18d119 (diff)
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
Diffstat (limited to 'src/tools/lcc')
-rw-r--r--src/tools/lcc/src/c.h1
-rw-r--r--src/tools/lcc/src/enode.c3
-rw-r--r--src/tools/lcc/src/expr.c2
3 files changed, 3 insertions, 3 deletions
diff --git a/src/tools/lcc/src/c.h b/src/tools/lcc/src/c.h
index 68c8f629..43bec083 100644
--- a/src/tools/lcc/src/c.h
+++ b/src/tools/lcc/src/c.h
@@ -577,6 +577,7 @@ extern Tree cnsttree(Type, ...);
extern Tree consttree(unsigned 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);
diff --git a/src/tools/lcc/src/enode.c b/src/tools/lcc/src/enode.c
index 760096de..4a37618c 100644
--- a/src/tools/lcc/src/enode.c
+++ b/src/tools/lcc/src/enode.c
@@ -5,7 +5,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) \
@@ -220,7 +219,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
diff --git a/src/tools/lcc/src/expr.c b/src/tools/lcc/src/expr.c
index b8cb08b6..96eec217 100644
--- a/src/tools/lcc/src/expr.c
+++ b/src/tools/lcc/src/expr.c
@@ -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)