code: def test_domain_cpp_parse_mix_decl_duplicate(app, warning):
      # Issue 8270
      text = (
          ".. cpp:struct:: A\n"
          ".. cpp:function:: void A()\n"
          ".. cpp:struct:: A\n"
      )
      restructuredtext.parse(app, text)
      ws = warning.getvalue().split("\n")
      assert len(ws) == 5
      assert (
          "index.rst:2: WARNING: Duplicate C++ declaration, also defined at index:1."
          in ws[0]
      )
      assert "Declaration is '.. cpp:function:: void A()'." in ws[1]
      assert (
          "index.rst:3: WARNING: Duplicate C++ declaration, also defined at index:1."
          in ws[2]
      )
      assert "Declaration is '.. cpp:struct:: A'." in ws[3]
      assert ws[4] == ""
  
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 38 for calling a global function with example usage: test_domain_cpp_parse_mix_decl_duplicate(app, warning) without return types