Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'assertion failed: found_namespace_keyword' when parsing C++20 nested inline namespace definition #2293

Closed
cpeterso opened this issue Oct 4, 2022 · 0 comments · Fixed by #2294
Labels

Comments

@cpeterso
Copy link

cpeterso commented Oct 4, 2022

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.com-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:

  1. nested inline namespace definition: namespace A::B::inline C { ... } is equivalent to namespace A::B { inline namespace C { ... } }. inline may appear in front of every namespace name except the first: namespace A::inline B::C {} is equivalent to namespace A { inline namespace B { namespace C {} } }.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants