diff options
author | David Malcolm <dmalcolm@redhat.com> | 2017-10-13 12:42:39 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2017-10-13 12:42:39 +0000 |
commit | 15f7a4692667ce38eed325a9567f5ef492a5ce07 (patch) | |
tree | 7b2e27753270c83805872cbc3270007b040ce3bb /libgcc/libgcc2.c | |
parent | 3b0dd4fea23a695df1fb9a7e5c7017f9d1f1ea84 (diff) | |
download | gcc-15f7a4692667ce38eed325a9567f5ef492a5ce07.zip gcc-15f7a4692667ce38eed325a9567f5ef492a5ce07.tar.gz gcc-15f7a4692667ce38eed325a9567f5ef492a5ce07.tar.bz2 |
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
Diffstat (limited to 'libgcc/libgcc2.c')
0 files changed, 0 insertions, 0 deletions