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

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 22 16:22:24 PDT 2022


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