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

chuanqi.xcq via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 22 19:58:10 PDT 2022


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220823/3baf45f0/attachment-0001.html>


More information about the cfe-commits mailing list