+2005-05-13 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.
+
2005-05-13 Kazu Hirata <kazu@cs.umass.edu>
* config/mips/3000.md, config/mips/4000.md,
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
--- /dev/null
+// { dg-do compile }
+// { dg-options "-Wformat=2" }
+
+extern "C" int printf (const char*, ...);
+
+void foo(int i)
+{
+ printf("Hello World %d!\n", i);
+ printf(&"Hello World %d!\n"[0], i);
+ printf(&"Hello World %d!\n"[6], i);
+ printf(&"Hello World %d!\n"[8]-2, i);
+ printf(&"Hello World %d!\n"[4]+2, i);
+}