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

C, distinguish between ordinary identifiers and tag names #7819

Open
jakobandersen opened this issue Jun 11, 2020 · 2 comments
Open

C, distinguish between ordinary identifiers and tag names #7819

jakobandersen opened this issue Jun 11, 2020 · 2 comments

Comments

@jakobandersen
Copy link
Contributor

Describe the bug
It should be possible to have a type with the same name as a struct/union/enum, as in the language.

To Reproduce
Steps to reproduce the behavior: as example, consider the following documentation (where every instance of struct could be replaced with union or enum instead):

.. c:struct:: foo
.. c:type:: struct foo foo

   No duplicate declaration warning.

- :c:struct::`foo`, link to the struct.
- :c:type::``foo``, link to the typedef.
- :c:any:``foo``, probably link to the type?
- Perhaps new feature: :c:any:``struct foo``, link to the struct.
- :c:expr:``foo*``, hyperlink ``foo`` to the typedef.
- c:expr:``struct foo*``, hyperlink ``foo`` (or all of ``struct foo``?) to the struct.

Expected behavior
See above.

Additional context

@Shamino0
Copy link

Hi. I reported this over at the Breathe site. Attached is a test-case that shows the problem. I've got four cases:

  1. A C struct where the typedef and struct have the same name (processed via Doxygen and Breathe)
  2. A C struct where the typedef and the struct have different names (processed via Doxygen and Breathe)
  3. Sphinx markup declaring a C type and struct with the same name
  4. Sphinx markup declaring a C type and struct with different names

Cases 2 and 4 work correctly - I can link to the types or the structs.

Cases 1 and 3 are broken - trying to reference the struct results in a link to the typedef.

I don't know what the cause is, but I did notice that the URLs for the links don't include the full domain. They are of the form .../html/foo.html/#c.foo_t. The top-level domain (:c:) is present, but the next-level domain (:type: or :struct:) is not, making it impossible to distinguish between the two.

testcase.zip

@jakobandersen
Copy link
Contributor Author

(Just to avoid nomenclature confusion: "domain" in Sphinx means something specific, so for example "c", "cpp", and "python" are domains, without further subdivision.)

The cause is relatively simple: the C domain keeps track of declarations without partitioning names into tag and non-tag names. The links include an ID generated by the C domain (if you try other domains you will see very different patterns for the IDs), and you are absolutely correct that the ID needs to include tagging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants