C++: show location of unclosed extern "C" specifications
If the user fails to close an extern "C" linkage specifier, and then
uses templates, they will run into "template with C linkage" errors.
From personal experience, it can be hard to tell where the
extern "C" began. As of r251026 there will be a message highlighting
the unclosed '{', but this may be hard to spot at the very end of
the errors.
This patch adds a note to the various diagnostics that complain
about C linkage, showing the user where the extern "C" specification
began.
gcc/cp/ChangeLog:
* cp-tree.h (maybe_show_extern_c_location): New decl.
* decl.c (grokfndecl): When complaining about literal operators
with C linkage, issue a note giving the location of the
extern "C".
* parser.c (cp_parser_new): Initialize new field
"innermost_linkage_specification_location".
(cp_parser_linkage_specification): Store the location
of the linkage specification within the cp_parser.
(cp_parser_explicit_specialization): When complaining about
template specializations with C linkage, issue a note giving the
location of the extern "C".
(cp_parser_explicit_template_declaration): Likewise for templates.
(maybe_show_extern_c_location): New function.
* parser.h (struct cp_parser): New field
"innermost_linkage_specification_location".
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/udlit-extern-c.C: New test case.
* g++.dg/diagnostic/unclosed-extern-c.C: Add example of a template
erroneously covered by an unclosed extern "C".
* g++.dg/template/extern-c.C: New test case.
From-SVN: r253726