llvm / llvm-project

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

Build failed with CMAKE_CXX_STANDARD=20 #61611

Open wangzw opened 1 year ago

wangzw commented 1 year ago

Building with CMAKE_CXX_STANDARD=20 failed but with CMAKE_CXX_STANDARD=17 success

$ gcc --version
gcc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4)
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ uname -a
Linux be52cec1e796 5.15.49-linuxkit #1 SMP Tue Sep 13 07:51:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Cmake configure:

cmake ../llvm -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=20

Error message:

/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp:3499:38: error: expected unqualified-id before ‘const’
 3499 |   CachedReachabilityAA<BaseTy, ToTy>(const IRPosition &IRP, Attributor &A)
      |                                      ^~~~~
/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp:3499:38: error: expected ‘)’ before ‘const’
 3499 |   CachedReachabilityAA<BaseTy, ToTy>(const IRPosition &IRP, Attributor &A)
      |                                     ~^~~~~
      |                                      )
/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp: In constructor ‘{anonymous}::AAIntraFnReachabilityFunction::AAIntraFnReachabilityFunction(const llvm::IRPosition&, llvm::Attributor&)’:
/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp:3604:20: error: no matching function for call to ‘{anonymous}::CachedReachabilityAA<llvm::AAIntraFnReachability, llvm::Instruction>::CachedReachabilityAA(const llvm::IRPosition&, llvm::Attributor&)’
 3604 |       : Base(IRP, A) {}
      |                    ^
/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp:3496:8: note: candidate: ‘{anonymous}::CachedReachabilityAA<llvm::AAIntraFnReachability, llvm::Instruction>::CachedReachabilityAA(const {anonymous}::CachedReachabilityAA<llvm::AAIntraFnReachability, llvm::Instruction>&)’
 3496 | struct CachedReachabilityAA : public BaseTy {
      |        ^~~~~~~~~~~~~~~~~~~~
/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp:3496:8: note:   candidate expects 1 argument, 2 provided
/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp:3496:8: note: candidate: ‘{anonymous}::CachedReachabilityAA<llvm::AAIntraFnReachability, llvm::Instruction>::CachedReachabilityAA({anonymous}::CachedReachabilityAA<llvm::AAIntraFnReachability, llvm::Instruction>&&)’
/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp:3496:8: note:   candidate expects 1 argument, 2 provided
/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp: In lambda function:
/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp:7594:9: warning: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20 [-Wdeprecated]
 7594 |         [=](const Attributor::ArgumentReplacementInfo &ARI,
      |         ^
/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp:7594:9: note: add explicit ‘this’ or ‘*this’ capture
/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp: In lambda function:
/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp:7618:9: warning: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20 [-Wdeprecated]
 7618 |         [=, &AlignAA](const Attributor::ArgumentReplacementInfo &ARI,
      |         ^
/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp:7618:9: note: add explicit ‘this’ or ‘*this’ capture
/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp: In constructor ‘{anonymous}::AAInterFnReachabilityFunction::AAInterFnReachabilityFunction(const llvm::IRPosition&, llvm::Attributor&)’:
/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp:10543:69: error: no matching function for call to ‘{anonymous}::CachedReachabilityAA<llvm::AAInterFnReachability, llvm::Function>::CachedReachabilityAA(const llvm::IRPosition&, llvm::Attributor&)’
10543 |       : CachedReachabilityAA<AAInterFnReachability, Function>(IRP, A) {}
      |                                                                     ^
/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp:3496:8: note: candidate: ‘{anonymous}::CachedReachabilityAA<llvm::AAInterFnReachability, llvm::Function>::CachedReachabilityAA(const {anonymous}::CachedReachabilityAA<llvm::AAInterFnReachability, llvm::Function>&)’
 3496 | struct CachedReachabilityAA : public BaseTy {
      |        ^~~~~~~~~~~~~~~~~~~~
/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp:3496:8: note:   candidate expects 1 argument, 2 provided
/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp:3496:8: note: candidate: ‘{anonymous}::CachedReachabilityAA<llvm::AAInterFnReachability, llvm::Function>::CachedReachabilityAA({anonymous}::CachedReachabilityAA<llvm::AAInterFnReachability, llvm::Function>&&)’
/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp:3496:8: note:   candidate expects 1 argument, 2 provided
[ 65%] Building CXX object lib/Transforms/IPO/CMakeFiles/LLVMipo.dir/DeadArgumentElimination.cpp.o
make[2]: *** [lib/Transforms/IPO/CMakeFiles/LLVMipo.dir/build.make:132: lib/Transforms/IPO/CMakeFiles/LLVMipo.dir/AttributorAttributes.cpp.o] Error 1
dantealmeida commented 9 months ago

This simple change fixed it:

3499c3499
<   CachedReachabilityAA<BaseTy, ToTy>(const IRPosition &IRP, Attributor &A)
---
>   CachedReachabilityAA(const IRPosition &IRP, Attributor &A)