diff options
author | Richard Guenther <rguenth@gcc.gnu.org> | 2005-05-13 09:48:12 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2005-05-13 09:48:12 +0000 |
commit | f5c9a09777ebdaa3fd74d356e00c1777d2610cd4 (patch) | |
tree | b9d23e0b16c4bdc7b552843f6fdf8735223307d0 /gcc/c-format.c | |
parent | 0e687cb4f16eb81036639406bdbbaa554e328052 (diff) | |
download | gcc-f5c9a09777ebdaa3fd74d356e00c1777d2610cd4.zip gcc-f5c9a09777ebdaa3fd74d356e00c1777d2610cd4.tar.gz gcc-f5c9a09777ebdaa3fd74d356e00c1777d2610cd4.tar.bz2 |
c-format.c (check_format_arg): Handle string literals of the form &"string"[offset].
2005-05-14 Richard Guenther <rguenth@gcc.gnu.org>
* c-format.c (check_format_arg): Handle string literals of
the form &"string"[offset].
* g++.dg/warn/format4.C: New testcase.
From-SVN: r99652
Diffstat (limited to 'gcc/c-format.c')
-rw-r--r-- | gcc/c-format.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/c-format.c b/gcc/c-format.c index dd570ab..daa071e 100644 --- a/gcc/c-format.c +++ b/gcc/c-format.c @@ -1260,6 +1260,10 @@ check_format_arg (void *ctx, tree format_tree, return; } format_tree = TREE_OPERAND (format_tree, 0); + if (TREE_CODE (format_tree) == ARRAY_REF + && host_integerp (TREE_OPERAND (format_tree, 1), 0) + && (offset += tree_low_cst (TREE_OPERAND (format_tree, 1), 0)) >= 0) + format_tree = TREE_OPERAND (format_tree, 0); if (TREE_CODE (format_tree) == VAR_DECL && TREE_CODE (TREE_TYPE (format_tree)) == ARRAY_TYPE && (array_init = decl_constant_value (format_tree)) != format_tree |