Add missing auto diagnostic group
GCC now correctly handles diagnostic groups for explicit instantiations of C++ variable templates.
This commit adds an auto_diagnostic_group to the check_explicit_inst_of_var_template function in the C++ front end. This ensures that diagnostics reported during the checking of explicit instantiations of variable templates are properly grouped and managed, preventing potential issues with diagnostic handling that were previously overlooked.
In Details
The auto_diagnostic_group is a scoped object that manages the emission of diagnostics messages within the GCC C++ front end. Its constructor pushes a new diagnostic group onto a stack, and its destructor pops it off, ensuring that warnings and errors generated within its scope are correctly associated. In the context of pt.cc, this ensures that any diagnostics related to explicit instantiations of variable templates are properly categorized.
For Context
When a compiler translates code, it often produces warnings or errors—these are called diagnostics. To help developers understand and manage these messages, compilers group related diagnostics together. This commit improves how GCC, the GNU Compiler Collection, handles these diagnostic groups for a specific feature in C++: explicit instantiations of variable templates. This ensures that any messages generated while checking these templates are correctly categorized, making it easier for you to understand and address potential issues in your C++ code.