summaryrefslogtreecommitdiff
path: root/gnu/egcs/gcc
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2003-01-07 18:07:34 +0000
committerMarc Espie <espie@cvs.openbsd.org>2003-01-07 18:07:34 +0000
commit881282ddab183397fa55e3c9699eb0ed081e0dfd (patch)
tree43b71bca9622c83d7087a499497b8ee011eaaea9 /gnu/egcs/gcc
parent63329f576db2a359872cf8dd4b44518833b40cba (diff)
attribute(sentinel) improvements:
- move __null node to c-common.c so that sentinel can check for it (since g++ __null is `special') - rework diagnostics to be more clear. In particular, distinguish `not terminated' from `terminated with a 0 of the wrong type' ok miod@, millert@
Diffstat (limited to 'gnu/egcs/gcc')
-rw-r--r--gnu/egcs/gcc/c-common.c13
-rw-r--r--gnu/egcs/gcc/cp/decl.c2
2 files changed, 13 insertions, 2 deletions
diff --git a/gnu/egcs/gcc/c-common.c b/gnu/egcs/gcc/c-common.c
index 32f561fcef3..bc8399e0c97 100644
--- a/gnu/egcs/gcc/c-common.c
+++ b/gnu/egcs/gcc/c-common.c
@@ -45,6 +45,8 @@ static enum cpp_token cpp_token;
#endif
#endif
+tree null_node;
+
extern struct obstack permanent_obstack;
/* Nonzero means the expression being parsed will never be evaluated.
@@ -1686,6 +1688,7 @@ check_sentinel_info (info, params)
{
tree arg;
int arg_num;
+ int found_zero = 0;
/* Skip to first checked argument. If the argument isn't available, there's
no work for us to do; prototype checking will catch the problem. */
@@ -1705,12 +1708,20 @@ check_sentinel_info (info, params)
break;
while (TREE_CODE (arg) == NOP_EXPR)
arg = TREE_OPERAND (arg, 0); /* strip coercion */
+ /* Special C++ check */
+ if (arg == null_node)
+ return;
if (POINTER_TYPE_P (TREE_TYPE (arg)) && integer_zerop (arg))
return;
+ if (integer_zerop (arg))
+ found_zero = 1;
params = TREE_CHAIN (params);
}
- warning("couldn't find sentinel value starting at %d", arg_num);
+
+ warning("couldn't find null pointer sentinel value starting at %d", arg_num);
+ if (found_zero)
+ warning("(integer 0 is not a null pointer in varargs context)");
}
/* Check the argument list of a call to printf, scanf, etc.
diff --git a/gnu/egcs/gcc/cp/decl.c b/gnu/egcs/gcc/cp/decl.c
index 6a6aeddb4a0..4b4f26a5f65 100644
--- a/gnu/egcs/gcc/cp/decl.c
+++ b/gnu/egcs/gcc/cp/decl.c
@@ -466,7 +466,7 @@ tree null_pointer_node;
/* The value for __null (NULL), namely, a zero of an integer type with
the same number of bits as a pointer. */
-tree null_node;
+extern tree null_node;
/* A node for the integer constants 1, 2, and 3. */