[clang] acaf6b9 - [NFC] Add [[maybe_unused]] to avoid warning in gcc9

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 23 10:59:48 PDT 2022


Thanks for the link - fair enough. We'll see how ubiquitous the
constexpr-creating-sort-of-unused-variables situation is. If it comes
up a lot we might want to disable the warning for GCC 9.

On Mon, Aug 22, 2022 at 7:58 PM chuanqi.xcq <yedeng.yd at linux.alibaba.com> wrote:
>
> Hi David,
>
>   This is the reproduce link from godbolt: https://godbolt.org/z/nEc7WYKnq. It is weird that it requries `-Wunused-but-set-parameter` instead of `-Wunused-parameter`. The bug exists in all versions of GCC9. And it gets fixed in GCC10 and later. Personally, I feel it looks better to suppress the warning for GCC9.
>
> Thanks,
> Chuanqi
>
> ------------------------------------------------------------------
> From:David Blaikie <dblaikie at gmail.com>
> Send Time:2022年8月23日(星期二) 07:22
> To:Chuanqi Xu <yedeng.yd at linux.alibaba.com>; Chuanqi Xu <llvmlistbot at llvm.org>
> Cc:cfe-commits <cfe-commits at lists.llvm.org>
> Subject:Re: [clang] acaf6b9 - [NFC] Add [[maybe_unused]] to avoid warning in gcc9
>
> Seems like a bug in the GCC9 warning - any chance we can disable it?
> (is it fixed in later versions of GCC?)
>
> I can't seem to reproduce this with godbolt at least with basic
> examples - it'd be good to know how bad the thing is we're working
> around so we know if we want to keep working around it, or suppress
> the warning for certainly compiler versions entirely.
>
> On Thu, Aug 18, 2022 at 11:43 PM Chuanqi Xu via cfe-commits
> <cfe-commits at lists.llvm.org> wrote:
> >
> >
> > Author: Chuanqi Xu
> > Date: 2022-08-19T14:43:22+08:00
> > New Revision: acaf6b9dc07de3c12c8a1a55fd8674bca547a917
> >
> > URL: https://github.com/llvm/llvm-project/commit/acaf6b9dc07de3c12c8a1a55fd8674bca547a917
> > DIFF: https://github.com/llvm/llvm-project/commit/acaf6b9dc07de3c12c8a1a55fd8674bca547a917.diff
> >
> > LOG: [NFC] Add [[maybe_unused]] to avoid warning in gcc9
> >
> > GCC9 may issue warning for the 'unused' parameters in if constexpr.
> > This commit try to fix it by adding the [[maybe_unused]] attribute.
> >
> > Added:
> >
> >
> > Modified:
> >     clang/include/clang/AST/RecursiveASTVisitor.h
> >
> > Removed:
> >
> >
> >
> > ################################################################################
> > diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h
> > index 91baad51b26e..bd7fadb87c5f 100644
> > --- a/clang/include/clang/AST/RecursiveASTVisitor.h
> > +++ b/clang/include/clang/AST/RecursiveASTVisitor.h
> > @@ -73,7 +73,8 @@ struct has_same_member_pointer_type<R (T::*)(P...), R (U::*)(P...)>
> >  /// are pointers to the same non-static member function.
> >  template <typename FirstMethodPtrTy, typename SecondMethodPtrTy>
> >  LLVM_ATTRIBUTE_ALWAYS_INLINE LLVM_ATTRIBUTE_NODEBUG auto
> > -isSameMethod(FirstMethodPtrTy FirstMethodPtr, SecondMethodPtrTy SecondMethodPtr)
> > +isSameMethod([[maybe_unused]] FirstMethodPtrTy FirstMethodPtr,
> > +             [[maybe_unused]] SecondMethodPtrTy SecondMethodPtr)
> >      -> bool {
> >    if constexpr (has_same_member_pointer_type<FirstMethodPtrTy,
> >                                               SecondMethodPtrTy>::value)
> >
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


More information about the cfe-commits mailing list