On Wed, Feb 28, 2018 at 5:47 PM, Martin Sebor <mse...@gmail.com> wrote: > Attached is a patch for the failure to merge a subset of attributes > specified on redeclarations of a function template with those of > the first declaration (const, malloc, pure, noinline, noreturn, > and nothrow). This was uncovered this morning while debugging > failures in tests I added just yesterday and although it's not > a regression I figured since I introduced the test failures and > the fix appears easy it might as well be taken care of now. > > The test I added for this exposed a subtle bug in -Wreturn-type > where the warning triggers on a function template instantiated > on a noreturn function even though the middle end successfully > eliminates statements after the noreturn call. This is not > a regression either so to avoid mission creep I just xfailed > the test and opened bug 84621 to remind us to fix it in > the future.
OK. Incidentally, looking over duplicate_decls again, I noticed: /* [temp.expl.spec/14] We don't inline explicit specialization just because the primary template says so. */ if (merge_attr) { /* But still keep DECL_DISREGARD_INLINE_LIMITS in sync with the always_inline attribute. */ if (DECL_DISREGARD_INLINE_LIMITS (olddecl) && !DECL_DISREGARD_INLINE_LIMITS (newdecl)) { if (DECL_DECLARED_INLINE_P (newdecl)) DECL_DISREGARD_INLINE_LIMITS (newdecl) = true; else DECL_ATTRIBUTES (newdecl) = remove_attribute ("always_inline", DECL_ATTRIBUTES (newdecl)); } } else { DECL_DECLARED_INLINE_P (olddecl) = DECL_DECLARED_INLINE_P (newdecl); DECL_DISREGARD_INLINE_LIMITS (olddecl) = DECL_DISREGARD_INLINE_LIMITS (newdecl); DECL_UNINLINABLE (olddecl) = DECL_UNINLINABLE (newdecl); } The upper block here seems like dead code; here we're dealing with an explicit specialization, so merge_attr should always be false. Let's drop the if block. Jason