+2020-03-17 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/94189
+ * builtins.c (expand_builtin_strnlen): Do return NULL_RTX if we would
+ emit a warning if it was enabled and don't depend on TREE_NO_WARNING
+ for code-generation.
+
2020-03-16 Vladimir Makarov <vmakarov@redhat.com>
PR target/94185
return NULL_RTX;
}
- if (lendata.decl
- && !TREE_NO_WARNING (exp)
- && ((tree_int_cst_lt (len, bound))
- || !exact))
+ if (lendata.decl && (tree_int_cst_lt (len, bound) || !exact))
{
location_t warnloc
= expansion_point_location_if_in_system_header (loc);
- if (warning_at (warnloc, OPT_Wstringop_overflow_,
- exact
- ? G_("%K%qD specified bound %E exceeds the size %E "
- "of unterminated array")
- : G_("%K%qD specified bound %E may exceed the size "
- "of at most %E of unterminated array"),
- exp, func, bound, len))
+ if (!TREE_NO_WARNING (exp)
+ && warning_at (warnloc, OPT_Wstringop_overflow_,
+ exact
+ ? G_("%K%qD specified bound %E exceeds the size "
+ "%E of unterminated array")
+ : G_("%K%qD specified bound %E may exceed the "
+ "size of at most %E of unterminated array"),
+ exp, func, bound, len))
{
inform (DECL_SOURCE_LOCATION (lendata.decl),
"referenced argument declared here");
TREE_NO_WARNING (exp) = true;
- return NULL_RTX;
}
+ return NULL_RTX;
}
if (!len)
--- /dev/null
+/* PR middle-end/94189 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fcompare-debug" } */
+
+const char a[] = { 'a', 'b', 'c', 'd' };/* { dg-message "declared here" } */
+
+int
+foo (void)
+{
+ return __builtin_strnlen (a, 5); /* { dg-warning "specified bound 5 exceeds the size 4 of unterminated array" } */
+}