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

[clang][AST] NULL node for function template body with -target x86_64-pc-win32 pre c++20 #71203

Closed
5chmidti opened this issue Nov 3, 2023 · 3 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

Comments

@5chmidti
Copy link
Contributor

5chmidti commented Nov 3, 2023

This bug was found during #70559.

Repro case:

template <typename T>
void f() {}

Clang creates valid ASTs for this snippet with:

  • -target x86_64-pc-win32 -std=c++20
  • -std=c++17 (linux)
  • -std=c++20 (linux)

But not with:

  • -target x86_64-pc-win32 -std=c++17
  • -target x86_64-pc-win32 -std=c++14
  • -target x86_64-pc-win32 -std=c++11

https://godbolt.org/z/9v98vnbsx

TranslationUnitDecl
`-FunctionTemplateDecl <line:1:1, line:2:11> col:6 f
  |-TemplateTypeParmDecl <line:1:11, col:20> col:20 typename depth 0 index 0 T
  `-FunctionDecl <line:2:1, col:11> col:6 f 'void ()'
    `-CompoundStmt <col:10, col:11>

vs

TranslationUnitDecl
`-FunctionTemplateDecl <line:1:1, line:2:8> col:6 f
  |-TemplateTypeParmDecl <line:1:11, col:20> col:20 typename depth 0 index 0 T
  `-FunctionDecl <line:2:1, col:8> col:6 f 'void ()'
    `-<<<NULL>>>
@github-actions github-actions bot added the clang Clang issues not falling into any other category label Nov 3, 2023
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed clang Clang issues not falling into any other category labels Nov 3, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Nov 3, 2023

@llvm/issue-subscribers-clang-frontend

Author: Julian Schmidt (5chmidti)

This bug was found during #70559.

Repro case:

template &lt;typename T&gt;
void f() {}

Clang creates valid ASTs for this snippet with:

  • -target x86_64-pc-win32 -std=c++20
  • -std=c++17 (linux)
  • -std=c++20 (linux)

But not with:

  • -target x86_64-pc-win32 -std=c++17
  • -target x86_64-pc-win32 -std=c++14
  • -target x86_64-pc-win32 -std=c++11

https://godbolt.org/z/9v98vnbsx

TranslationUnitDecl
`-FunctionTemplateDecl &lt;line:1:1, line:2:11&gt; col:6 f
  |-TemplateTypeParmDecl &lt;line:1:11, col:20&gt; col:20 typename depth 0 index 0 T
  `-FunctionDecl &lt;line:2:1, col:11&gt; col:6 f 'void ()'
    `-CompoundStmt &lt;col:10, col:11&gt;

vs

TranslationUnitDecl
`-FunctionTemplateDecl &lt;line:1:1, line:2:8&gt; col:6 f
  |-TemplateTypeParmDecl &lt;line:1:11, col:20&gt; col:20 typename depth 0 index 0 T
  `-FunctionDecl &lt;line:2:1, col:8&gt; col:6 f 'void ()'
    `-&lt;&lt;&lt;NULL&gt;&gt;&gt;

@5chmidti
Copy link
Contributor Author

5chmidti commented Nov 6, 2023

Thanks. I'm going to close this issue. As far as I can tell, this is expected behavior: the change for C++20 was due to MSVC changing the default for C++20, and the pre C++20 behavior is to use the delayed template parsing. Clang simply mirrors this behavior, from what I can tell. I'll figure something out for my CI failure.

@5chmidti 5chmidti closed this as completed Nov 6, 2023
@5chmidti 5chmidti reopened this Nov 6, 2023
@5chmidti 5chmidti closed this as not planned Won't fix, can't repro, duplicate, stale Nov 6, 2023
@EugeneZelenko EugeneZelenko added the question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! label Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Projects
None yet
Development

No branches or pull requests

4 participants