Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions bindgen-tests/tests/expectations/tests/namespace-attributes.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions bindgen-tests/tests/headers/namespace-attributes.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// bindgen-flags: --enable-cxx-namespaces -- -std=c++17

int take(int value);

namespace [[deprecated]] {
int helper(int value);
}

namespace [[deprecated]] Named {
int named(int value);
}
5 changes: 5 additions & 0 deletions bindgen/ir/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2258,8 +2258,13 @@ If you encounter an error missing from this list, please file an issue or a PR!"

let mut kind = ModuleKind::Normal;
let mut looking_for_name = false;
let mut attribute_depth = 0;
for token in cursor.tokens().iter() {
match token.spelling() {
// Skip C++ attributes before the namespace name or `{`.
b"[" if looking_for_name => attribute_depth += 1,
b"]" if attribute_depth > 0 => attribute_depth -= 1,
_ if attribute_depth > 0 => {}
b"inline" => {
debug_assert!(
kind != ModuleKind::Inline,
Expand Down
Loading