aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.h
diff options
context:
space:
mode:
authorNathaniel Shead <nathanieloshead@gmail.com>2024-03-04 23:58:30 +1100
committerNathaniel Shead <nathanieloshead@gmail.com>2024-05-01 15:04:38 +1000
commit79420dd344145819677b3f975bb305a778fcaf91 (patch)
treeea6a60c01d101ce01dc87a01ba61b044fbe877a8 /gcc/cp/parser.h
parent610415bb7ddc5626ec301ca20833e78696978601 (diff)
downloadgcc-79420dd344145819677b3f975bb305a778fcaf91.zip
gcc-79420dd344145819677b3f975bb305a778fcaf91.tar.gz
gcc-79420dd344145819677b3f975bb305a778fcaf91.tar.bz2
c++: Implement P2615 'Meaningful Exports' [PR107688]
This clarifies which kinds of declarations may and may not be exported in various contexts. The patch additionally fixes up some small issues that were clarified by the paper. Most of the changes are with regards to export-declarations, which are applied for all standards modes that we support '-fmodules-ts' for. However there are also a couple of changes made to linkage specifiers ('extern "C"'); I've applied these as since C++20, to line up with when modules were actually introduced. PR c++/107688 gcc/cp/ChangeLog: * name-lookup.cc (push_namespace): Error when exporting namespace with internal linkage. * parser.h (struct cp_parser): Add new flag 'in_unbraced_export_declaration_p'. * parser.cc (cp_debug_parser): Print the new flag. (cp_parser_new): Initialise the new flag. (cp_parser_module_export): Set the new flag. (cp_parser_class_specifier): Clear and restore the new flag. (cp_parser_import_declaration): Imports can now appear directly in a linkage specification. (cp_parser_declaration): Categorise declarations as "name" or "special"; error on the later in contexts where the former is required. (cp_parser_class_head): Error when exporting a partial specialisation. gcc/testsuite/ChangeLog: * g++.dg/modules/contracts-1_a.C: Avoid now-illegal syntax. * g++.dg/modules/contracts-2_a.C: Likewise. * g++.dg/modules/contracts-3_a.C: Likewise. * g++.dg/modules/contracts-4_a.C: Likewise. * g++.dg/modules/lang-1_c.C: Clarify now-legal syntax. * g++.dg/modules/pr101582-1.C: Remove now-legal XFAILS. * g++.dg/template/crash71.C: Update error messages. * g++.dg/cpp2a/linkage-spec1.C: New test. * g++.dg/modules/export-3.C: New test. * g++.dg/modules/export-4_a.C: New test. * g++.dg/modules/export-4_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Diffstat (limited to 'gcc/cp/parser.h')
-rw-r--r--gcc/cp/parser.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/cp/parser.h b/gcc/cp/parser.h
index 373e78f..09b356e 100644
--- a/gcc/cp/parser.h
+++ b/gcc/cp/parser.h
@@ -312,9 +312,13 @@ struct GTY(()) cp_parser {
/* TRUE if the declaration we are parsing is part of a
linkage-specification of the form `extern string-literal
- declaration'. */
+ name-declaration'. */
bool in_unbraced_linkage_specification_p;
+ /* TRUE if the declaration we are parsing is part of an
+ export-declaration of the form 'export name-declaration'. */
+ bool in_unbraced_export_declaration_p;
+
/* TRUE if we are presently parsing a declarator, after the
direct-declarator. */
bool in_declarator_p;