code: def test_domain_cpp_ast_attributes():
      # style: C++
      check("member", "[[]] int f", {1: "f__i", 2: "1f"})
      check(
          "member",
          "[ [ ] ] int f",
          {1: "f__i", 2: "1f"},
          # this will fail when the proper grammar is implemented
          output="[[ ]] int f",
      )
      check("member", "[[a]] int f", {1: "f__i", 2: "1f"})
      # style: GNU
      check("member", "__attribute__(()) int f", {1: "f__i", 2: "1f"})
      check("member", "__attribute__((a)) int f", {1: "f__i", 2: "1f"})
      check(
          "member", "__attribute__((a, b)) int f", {1: "f__i", 2: "1f"}
      )
      check(
          "member",
          "__attribute__((optimize(3))) int f",
          {1: "f__i", 2: "1f"},
      )
      check(
          "member",
          "__attribute__((format(printf, 1, 2))) int f",
          {1: "f__i", 2: "1f"},
      )
      # style: user-defined id
      check("member", "id_attr int f", {1: "f__i", 2: "1f"})
      # style: user-defined paren
      check("member", "paren_attr() int f", {1: "f__i", 2: "1f"})
      check("member", "paren_attr(a) int f", {1: "f__i", 2: "1f"})
      check("member", 'paren_attr("") int f', {1: "f__i", 2: "1f"})
      check(
          "member", "paren_attr(()[{}][]{}) int f", {1: "f__i", 2: "1f"}
      )
      with pytest.raises(DefinitionError):
          parse("member", "paren_attr(() int f")
      with pytest.raises(DefinitionError):
          parse("member", "paren_attr([) int f")
      with pytest.raises(DefinitionError):
          parse("member", "paren_attr({) int f")
      with pytest.raises(DefinitionError):
          parse("member", "paren_attr([)]) int f")
      with pytest.raises(DefinitionError):
          parse("member", "paren_attr((])) int f")
      with pytest.raises(DefinitionError):
          parse("member", "paren_attr({]}) int f")
  
      # position: decl specs
      check(
          "function",
          "static inline __attribute__(()) void f()",
          {1: "f", 2: "1fv"},
          output="__attribute__(()) static inline void f()",
      )
      check(
          "function", "[[attr1]] [[attr2]] void f()", {1: "f", 2: "1fv"}
      )
      # position: declarator
      check(
          "member", "int *[[attr1]] [[attr2]] i", {1: "i__iP", 2: "1i"}
      )
      check(
          "member",
          "int *const [[attr1]] [[attr2]] volatile i",
          {1: "i__iPVC", 2: "1i"},
          output="int *[[attr1]] [[attr2]] volatile const i",
      )
      check(
          "member", "int &[[attr1]] [[attr2]] i", {1: "i__iR", 2: "1i"}
      )
      check(
          "member",
          "int *[[attr1]] [[attr2]] *i",
          {1: "i__iPP", 2: "1i"},
      )
      # position: parameters and qualifiers
      check(
          "function", "void f() [[attr1]] [[attr2]]", {1: "f", 2: "1fv"}
      )
  
      # position: class, union, enum
      check(
          "class",
          "{key}[[attr1]] [[attr2]] Foo",
          {1: "Foo", 2: "3Foo"},
          key="class",
      )
      check(
          "union",
          "{key}[[attr1]] [[attr2]] Foo",
          {2: "3Foo"},
          key="union",
      )
      check(
          "enum",
          "{key}[[attr1]] [[attr2]] Foo",
          {2: "3Foo"},
          key="enum",
      )
      # position: enumerator
      check("enumerator", "{key}Foo [[attr1]] [[attr2]]", {2: "3Foo"})
      check(
          "enumerator", "{key}Foo [[attr1]] [[attr2]] = 42", {2: "3Foo"}
      )
  
imports: import itertools
  import re
  import zlib
  import pytest
  import sphinx.domains.cpp
  from sphinx import addnodes
  from sphinx.addnodes import desc, desc_content, desc_name, desc_parameter, desc_parameterlist, desc_sig_name, desc_sig_space, desc_signature, desc_signature_line, pending_xref
  from sphinx.domains.cpp import DefinitionError, DefinitionParser, NoOldIdError, Symbol, _id_prefix, _max_id
  from sphinx.ext.intersphinx import load_mappings, normalize_intersphinx_mapping
  from sphinx.testing import restructuredtext
  from sphinx.testing.util import assert_node
  from sphinx.writers.text import STDINDENT
label_desc: Use image node_id 21 for calling a global function with example usage: test_domain_cpp_ast_attributes() without return types