-
Notifications
You must be signed in to change notification settings - Fork 757
Closed
Labels
Description
I hit this found_namespace_keyword
assertion failure when trying to parse a C++ file compiled with -std=c++20. My C++ file doesn't use any C++20 functionality, but compiling with -std=c++20 pulls in some C++20 std header files that use C++20's nested inline namespaces. In particular:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.sdk/usr/include/c++/v1/concepts
namespace ranges::inline __cpo {
inline constexpr auto swap = __swap::__fn{};
} // namespace ranges::__cpo
Input C/C++ Header
namespace A::inline B { }
Bindgen Invocation
$ bindgen test.cpp -- -std=c++20
or
$ bindgen --enable-cxx-namespaces test.cpp -- -std=c++20
Actual Results
thread 'main' panicked at 'assertion failed: found_namespace_keyword', /Users/chris/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/bindgen-0.60.1/src/ir/context.rs:2127:21
stack backtrace:
0: rust_begin_unwind
at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:142:14
2: core::panicking::panic
at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:48:5
3: bindgen::ir::context::BindgenContext::module
4: <bindgen::ir::item::Item as bindgen::parse::ClangItemParser>::parse
5: bindgen::clang::visit_children
6: __ZN5clang8cxcursor13CursorVisitor5VisitE8CXCursorb
7: __ZN5clang8cxcursor13CursorVisitor23handleDeclForVisitationEPKNS_4DeclE
8: __ZN5clang8cxcursor13CursorVisitor13VisitChildrenE8CXCursor
9: _clang_visitChildren
10: clang_sys::clang_visitChildren
11: <bindgen::ir::item::Item as bindgen::parse::ClangItemParser>::parse
12: bindgen::clang::visit_children
13: __ZN5clang8cxcursor13CursorVisitor5VisitE8CXCursorb
14: __ZN5clang8cxcursor13CursorVisitor23handleDeclForVisitationEPKNS_4DeclE
15: __ZN5clang8cxcursor13CursorVisitor13VisitChildrenE8CXCursor
16: _clang_visitChildren
17: clang_sys::clang_visitChildren
18: bindgen::Builder::generate
19: std::panicking::try
20: bindgen::main
Expected Results
The nested inline namespace definition should be parsed according to https://en.cppreference.com/w/cpp/language/namespace:
- nested inline namespace definition:
namespace A::B::inline C { ... }
is equivalent tonamespace A::B { inline namespace C { ... } }
. inline may appear in front of every namespace name except the first:namespace A::inline B::C {}
is equivalent tonamespace A { inline namespace B { namespace C {} } }
.