llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.92k stars 11.53k forks source link

[libc] GCC reports a warning when using `[[gnu::visibility("hidden")]]` with `LIBC_NAMESPACE` #98548

Open petrhosek opened 2 months ago

petrhosek commented 2 months ago

After #98075, we're seeing the following warning on GCC builders:

/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/big_int.h: In instantiation of ‘constexpr __llvm_libc_19_0_0_git::cpp::array<word, N> __llvm_libc_19_0_0_git::multiword::shift(__llvm_libc_19_0_0_git::cpp::array<word, N>, size_t) [with Direction direction = __llvm_libc_19_0_0_git::multiword::RIGHT; bool is_signed = false; word = long unsigned int; long unsigned int N = 5; size_t = long unsigned int]’:
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/big_int.h:760:61:   required from ‘constexpr __llvm_libc_19_0_0_git::BigInt<Bits, Signed, WordType> __llvm_libc_19_0_0_git::BigInt<Bits, Signed, WordType>::operator>>(size_t) const [with long unsigned int Bits = 320; bool Signed = false; WordType = long unsigned int; size_t = long unsigned int]’
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/float_to_string.h:390:29:   required from here
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/big_int.h:281:28: error: ‘__llvm_libc_19_0_0_git::multiword::shift<__llvm_libc_19_0_0_git::multiword::RIGHT, false, long unsigned int, 5>(__llvm_libc_19_0_0_git::cpp::array<long unsigned int, 5>, size_t)::<lambda(size_t)>’ declared with greater visibility than the type of its field ‘__llvm_libc_19_0_0_git::multiword::shift<__llvm_libc_19_0_0_git::multiword::RIGHT, false, long unsigned int, 5>(__llvm_libc_19_0_0_git::cpp::array<long unsigned int, 5>, size_t)::<lambda(size_t)>::<array capture>’ [-Werror=attributes]
  281 |   const auto safe_get_at = [&](size_t index) -> word {
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  282 |     // return appropriate value when accessing out of bound elements.
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  283 |     const int i = at(index);
      |     ~~~~~~~~~~~~~~~~~~~~~~~~
  284 |     if (i < 0)
      |     ~~~~~~~~~~              
  285 |       return 0;
      |       ~~~~~~~~~             
  286 |     if (i >= int(N))
      |     ~~~~~~~~~~~~~~~~        
  287 |       return is_neg ? -1 : 0;
      |       ~~~~~~~~~~~~~~~~~~~~~~~
  288 |     return array[i];
      |     ~~~~~~~~~~~~~~~~        
  289 |   };
      |   ~                         
llvmbot commented 2 months ago

@llvm/issue-subscribers-libc

Author: Petr Hosek (petrhosek)

After #98075, we're seeing the following warning on GCC builders: ``` /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/big_int.h: In instantiation of ‘constexpr __llvm_libc_19_0_0_git::cpp::array<word, N> __llvm_libc_19_0_0_git::multiword::shift(__llvm_libc_19_0_0_git::cpp::array<word, N>, size_t) [with Direction direction = __llvm_libc_19_0_0_git::multiword::RIGHT; bool is_signed = false; word = long unsigned int; long unsigned int N = 5; size_t = long unsigned int]’: /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/big_int.h:760:61: required from ‘constexpr __llvm_libc_19_0_0_git::BigInt<Bits, Signed, WordType> __llvm_libc_19_0_0_git::BigInt<Bits, Signed, WordType>::operator>>(size_t) const [with long unsigned int Bits = 320; bool Signed = false; WordType = long unsigned int; size_t = long unsigned int]’ /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/float_to_string.h:390:29: required from here /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/big_int.h:281:28: error: ‘__llvm_libc_19_0_0_git::multiword::shift<__llvm_libc_19_0_0_git::multiword::RIGHT, false, long unsigned int, 5>(__llvm_libc_19_0_0_git::cpp::array<long unsigned int, 5>, size_t)::<lambda(size_t)>’ declared with greater visibility than the type of its field ‘__llvm_libc_19_0_0_git::multiword::shift<__llvm_libc_19_0_0_git::multiword::RIGHT, false, long unsigned int, 5>(__llvm_libc_19_0_0_git::cpp::array<long unsigned int, 5>, size_t)::<lambda(size_t)>::<array capture>’ [-Werror=attributes] ```