Handle explicit template specializations in sg.pl#134
Conversation
There was a problem hiding this comment.
Pull request overview
Prevents sg.pl from crashing on explicit template specializations (template <>) by detecting the empty parameter list case and skipping parsing of the specialization body.
Changes:
- Return an empty parameter list from
template_args()when encounteringtemplate <>. - In
parse_template(), detect explicit specializations and skip the entire declaration/body so they don’t generate.boutputs.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sg.pl crashes when a header contains an explicit template specialization (template <>) because template_args() expects class/bool/int after '<' but gets '>'. Return an empty parameter list from template_args() on 'template <>' and skip the entire specialization in parse_template(), since explicit specializations are not new class definitions and should not generate .b files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Hi @Ozaq could you please provide a test that was previously crashing? |
|
If I understood correctly, the issue occurs when the file contains something like: which ends with the failure Assuming this is indeed the problem the issue is fixed! But this certainly deserves a test to ensure the use case is handled properly |
marcosbento
left a comment
There was a problem hiding this comment.
Please add a test to cover the failure test that triggered these changes.
Verifies the fix from 5b88770 by running sg.pl on a header containing both body and semicolon-only forms of template <>, asserting no crash, correct .b file generation for regular/template classes, and proper parser recovery for classes appearing after the specializations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@wdeconinck / @marcosbento Tests added |
|
All runners are failing |
|
@wdeconinck I've fixed a few outstanding issues, and the ecbuild build (including the new test) is passing -- the issues detected downstream don't seem related. |
Description
sg.pl crashes when a header contains an explicit template specialization (template <>) because template_args() expects class/bool/int after '<' but gets '>'.
Return an empty parameter list from template_args() on 'template <>' and skip the entire specialization in parse_template(), since explicit specializations are not new class definitions and should not generate .b files.
Contributor Declaration
By opening this pull request, I affirm the following: