On 4/8/2021 4:15 PM, Martin Sebor via Gcc-patches wrote:
The C front end ordinarily merges function type attributes upon the redeclaration of a function but it doesn't do that for those at local scope, unless the declaration refers to a built-in. Because the new -Warray-parameter warning relies on the internal access attribute on the type of the function added by the C front end for parameters declared using the array notation, it triggers when it sees a redeclaration of a function in a local scope even when both declarations use the same array form, issuing a false positive. The same problem affects other similar redeclarations involving attributes, such as unused_result, causing false negatives there. (Clang and ICC behave as I expect.) The attached patch lets the front end propagate the type attributes for all redeclarations, resolving this class of problems for all affected attributes. There's another similar piece of code in pushdecl() that I didn't touch, although I couldn't come up with a test case showing it's necessary. Both hunks go back ages so I wonder if they might have been obviated by other improvements.
What I'd want to know is why the code didn't copy the attributes to the redeclarations. Did the git history provide any hints? Does the hunk of code post-date creation of the public lists? If so, was there any discussion in the public lists of the change that might give insights?
Jeff