In this testcase, we have multiple declarations of malloc. The one in the "system header" has a non-throwing exception specification, while the one in user code has none. By default we allow this mismatch when the old declaration is in a system header, but we mean to prefer the type of the user declaration. In this testcase that was breaking because the old declaration had attributes added by the compiler, and the code at the bottom of merge_types decided to throw away the work earlier in the function to build up a new FUNCTION_TYPE in t1 because t2 had the right attributes. This is a C++17 regression. Fixed by limiting the attribute checking code to the case where we aren't building up a new type in t1. Tested x86_64-pc-linux-gnu, applying to trunk.