diff options
author | Nathaniel Shead <nathanieloshead@gmail.com> | 2024-05-24 00:08:57 +1000 |
---|---|---|
committer | Nathaniel Shead <nathanieloshead@gmail.com> | 2024-05-25 00:10:42 +1000 |
commit | dae606a11eb99814e452b49241fa76f7678f53b8 (patch) | |
tree | 9d1ff2aa2e2bf31d53a3009b207fc206a25120be /libcpp | |
parent | 03531ec45f15aa187bbab7842a1eb6cf746a104b (diff) | |
download | gcc-dae606a11eb99814e452b49241fa76f7678f53b8.zip gcc-dae606a11eb99814e452b49241fa76f7678f53b8.tar.gz gcc-dae606a11eb99814e452b49241fa76f7678f53b8.tar.bz2 |
c++/modules: Improve errors for bad module-directives [PR115200]
This fixes an ICE when a module directive is not given at global scope.
Although not explicitly mentioned, it seems implied from [basic.link] p1
and [module.global.frag] that a module-declaration must appear at the
global scope after preprocessing. Apart from this the patch also
slightly improves the errors given when accidentally using a module
control-line in other situations where it is not expected.
PR c++/115200
gcc/cp/ChangeLog:
* parser.cc (cp_parser_error_1): Special-case unexpected module
directives for better diagnostics.
(cp_parser_module_declaration): Check that the module
declaration is at global scope.
(cp_parser_import_declaration): Sync error message with that in
cp_parser_error_1.
gcc/testsuite/ChangeLog:
* g++.dg/modules/mod-decl-1.C: Update error messages.
* g++.dg/modules/mod-decl-6.C: New test.
* g++.dg/modules/mod-decl-7.C: New test.
* g++.dg/modules/mod-decl-8.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'libcpp')
0 files changed, 0 insertions, 0 deletions