aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorJoseph Myers <jsm28@cam.ac.uk>2000-10-18 17:09:35 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2000-10-18 17:09:35 +0100
commit81cf47b209c433b6cb1ccffb030789a06ffa5c16 (patch)
tree85c536f50f4a4636eb737ad764e804903e9b46cd /gcc/c-common.c
parent27c35f4b2435bc05271dca75ec26a585e6853f4a (diff)
downloadgcc-81cf47b209c433b6cb1ccffb030789a06ffa5c16.zip
gcc-81cf47b209c433b6cb1ccffb030789a06ffa5c16.tar.gz
gcc-81cf47b209c433b6cb1ccffb030789a06ffa5c16.tar.bz2
c-common.c (check_format_types): Check for writing through a NULL pointer argument.
* c-common.c (check_format_types): Check for writing through a NULL pointer argument. testsuite: * gcc.dg/c90-printf-1.c, gcc.dg/c90-scanf-1.c: Add tests for writing through null pointers; remove comment about testing unterminated strings. From-SVN: r36936
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index e9548dc..09cb949 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -3119,6 +3119,15 @@ check_format_types (status, types)
if (TREE_CODE (cur_type) == ERROR_MARK)
break;
+ /* Check for writing through a NULL pointer. */
+ if (types->writing_in_flag
+ && i == 0
+ && cur_param != 0
+ && integer_zerop (cur_param))
+ status_warning (status,
+ "writing through null pointer (arg %d)",
+ arg_num);
+
if (cur_param != 0 && TREE_CODE (cur_param) == ADDR_EXPR)
cur_param = TREE_OPERAND (cur_param, 0);
else