in the function call EXP. */
static void
-maybe_warn_rdwr_sizes (rdwr_map *rwm, tree exp)
+maybe_warn_rdwr_sizes (rdwr_map *rwm, tree fndecl, tree fntype, tree exp)
{
- tree fndecl = NULL_TREE;
- tree fntype = NULL_TREE;
- if (tree fnaddr = CALL_EXPR_FN (exp))
- {
- if (TREE_CODE (fnaddr) == ADDR_EXPR)
- {
- fndecl = TREE_OPERAND (fnaddr, 0);
- fntype = TREE_TYPE (fndecl);
- }
- else
- fntype = TREE_TYPE (TREE_TYPE (fnaddr));
- }
-
- if (!fntype)
- return;
-
auto_diagnostic_group adg;
/* A string describing the attributes that the warnings issued by this
maybe_warn_nonstring_arg (fndecl, exp);
/* Check attribute access arguments. */
- maybe_warn_rdwr_sizes (&rdwr_idx, exp);
+ maybe_warn_rdwr_sizes (&rdwr_idx, fndecl, fntype, exp);
}
/* Update ARGS_SIZE to contain the total size for the argument block.
--- /dev/null
+/* PR middle-end/96335 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+void bar (int, void *) __attribute__((__access__(__read_only__, 2)));
+
+void
+foo (void *x)
+{
+ void (*fn) () = bar;
+ fn (0, x);
+}