for (tree curp = curparms, newp = newparms; curp;
curp = TREE_CHAIN (curp), newp = TREE_CHAIN (newp), ++parmpos)
{
+ if (!newp)
+ /* Bail on invalid redeclarations with fewer arguments. */
+ return;
+
/* Only check pointers and C++ references. */
tree newptype = TREE_TYPE (newp);
if (!POINTER_TYPE_P (newptype))
continue;
- {
- /* Skip mismatches in __builtin_va_list that is commonly
- an array but that in declarations of built-ins decays
- to a pointer. */
- if (builtin && TREE_TYPE (newptype) == TREE_TYPE (va_list_type_node))
- continue;
- }
+ /* Skip mismatches in __builtin_va_list that is commonly
+ an array but that in declarations of built-ins decays
+ to a pointer. */
+ if (builtin && TREE_TYPE (newptype) == TREE_TYPE (va_list_type_node))
+ continue;
/* Access specs for the argument on the current (previous) and
new (to replace the current) declarations. Either may be null,
--- /dev/null
+/* PR middle-end/97861 - ICE on an invalid redeclaration of a function
+ with attribute access
+ { dg-do compile }
+ { dg-options "-Wall" } */
+
+__attribute__ ((access (read_only, 2)))
+void f (int, int*);
+void f (int a) { } // { dg-error "conflicting types for 'f'" }