public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99040] New: [modules] partitions & using declarations
@ 2021-02-09 18:31 nathan at gcc dot gnu.org
2021-02-10 21:05 ` [Bug c++/99040] " nathan at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: nathan at gcc dot gnu.org @ 2021-02-09 18:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99040
Bug ID: 99040
Summary: [modules] partitions & using declarations
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: nathan at gcc dot gnu.org
Target Milestone: ---
triaged from pr98760
// t1.ii
export module format;
export namespace NS
{
void Format ();
}
// t2.ii
export module hello:check;
export namespace NS {}
// t3.ii
export module hello;
export import :check;
import format;
export namespace NS
{
using NS::Format;
}
// t4.ii
module hello;
./cc1plus -quiet -std=c++17 -fmodules-ts -fpreprocessed t1.ii && ./cc1plus
-quiet -std=c++17 -fmodules-ts -fpreprocessed t2.ii && ./cc1plus -quiet
-std=c++17 -fmodules-ts -fpreprocessed t3.ii && ./cc1plus -quiet -std=c++17
-fmodules-ts -fpreprocessed t4.ii -fno-module-lazy
t4.ii:1:14: internal compiler error: in add_module_decl, at
cp/name-lookup.c:4199
1 | module hello;
| ^
0xd3c3ae add_module_decl(tree_node*, tree_node*, tree_node*)
../../../src/gcc/cp/name-lookup.c:4199
0xd0a848 module_state::read_cluster(unsigned int)
../../../src/gcc/cp/module.cc:14908
0xd13cf8 module_state::load_section(unsigned int, binding_slot*)
../../../src/gcc/cp/module.cc:18068
0xd13a26 module_state::read_language(bool)
../../../src/gcc/cp/module.cc:17997
0xd16625 direct_import
../../../src/gcc/cp/module.cc:18870
0xd16a79 declare_module(module_state*, unsigned int, bool, tree_node*,
cpp_reader*)
../../../src/gcc/cp/module.cc:18975
0xd72cf2 cp_parser_module_declaration
../../../src/gcc/cp/parser.c:13757
0xd5f315 cp_parser_translation_unit
../../../src/gcc/cp/parser.c:4894
0xdc21a4 c_parse_file()
../../../src/gcc/cp/parser.c:45179
0xfa7278 c_common_parse_file()
../../../src/gcc/c-family/c-opts.c:1218
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/99040] [modules] partitions & using declarations
2021-02-09 18:31 [Bug c++/99040] New: [modules] partitions & using declarations nathan at gcc dot gnu.org
@ 2021-02-10 21:05 ` nathan at gcc dot gnu.org
2021-02-12 21:50 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: nathan at gcc dot gnu.org @ 2021-02-10 21:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99040
Nathan Sidwell <nathan at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Assignee|unassigned at gcc dot gnu.org |nathan at gcc dot gnu.org
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2021-02-10
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/99040] [modules] partitions & using declarations
2021-02-09 18:31 [Bug c++/99040] New: [modules] partitions & using declarations nathan at gcc dot gnu.org
2021-02-10 21:05 ` [Bug c++/99040] " nathan at gcc dot gnu.org
@ 2021-02-12 21:50 ` cvs-commit at gcc dot gnu.org
2021-02-12 21:50 ` cvs-commit at gcc dot gnu.org
2021-02-12 21:51 ` nathan at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-12 21:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99040
--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathan Sidwell <nathan@gcc.gnu.org>:
https://gcc.gnu.org/g:8f93e1b892850b00bf6b9cbc5711a7d5bc367967
commit r11-7228-g8f93e1b892850b00bf6b9cbc5711a7d5bc367967
Author: Nathan Sidwell <nathan@acm.org>
Date: Thu Feb 11 13:06:03 2021 -0800
Expunge namespace-scope IDENTIFIER_TYPE_VALUE & global_type_name [PR 99039]
IDENTIFIER_TYPE_VALUE and friends is a remnant of G++'s C origins. It
holds elaborated types on identifier-nodes. While this is fine for C
and for local and class-scopes in C++, it fails badly for namespaces.
In that case a marker 'global_type_node' was used, which essentially
signified 'this is a namespace-scope type *somewhere*', and you'd have
to do a regular name_lookup to find it. As the parser and
substitution machinery has avanced over the last 25 years or so,
there's not much outside of actual name-lookup that uses that.
Amusingly the IDENTIFIER_HAS_TYPE_VALUE predicate will do an actual
name-lookup and then users would repeat that lookup to find the
now-known to be there type.
Rather late I realized that this interferes with the lazy loading of
module entities, because we were setting IDENTIFIER_TYPE_VALUE to
global_type_node. But we could be inside some local scope where that
identifier is bound to some local type. Not good!
Rather than add more cruft to look at an identifier's shadow stack and
alter that as necessary, this takes the approach of removing the
existing cruft.
We nuke the few places outside of name lookup that use
IDENTIFIER_TYPE_VALUE. Replacing them with either proper name
lookups, alternative sequences, or in some cases asserting that they
(no longer) happen. Class template instantiation was calling pushtag
after setting IDENTIFIER_TYPE_VALUE in order to stop pushtag creating
an implicit typedef and pushing it, but to get the bookkeeping it
needed. Let's just do the bookkeeping directly.
Then we can stop having a 'bound at namespace-scope' marker at all,
which means lazy loading won't screw up local shadow stacks. Also, it
simplifies set_identifier_type_value_with_scope, as it never needs to
inspect the scope stack. When developing this patch, I discovered a
number of places we'd put an actual namespace-scope type on the
type_value slot, rather than global_type_node. You might notice this
is killing at least two 'why are we doing this?' comments.
While this doesn't fix the two PRs mentioned, it is a necessary step.
PR c++/99039
PR c++/99040
gcc/cp/
* cp-tree.h (CPTI_GLOBAL_TYPE): Delete.
(global_type_node): Delete.
(IDENTIFIER_TYPE_VALUE): Delete.
(IDENTIFIER_HAS_TYPE_VALUE): Delete.
(get_type_value): Delete.
* name-lookup.h (identifier_type_value): Delete.
* name-lookup.c (check_module_override): Don't
SET_IDENTIFIER_TYPE_VALUE here.
(do_pushdecl): Nor here.
(identifier_type_value_1, identifier_type_value): Delete.
(set_identifier_type_value_with_scope): Only
SET_IDENTIFIER_TYPE_VALUE for local and class scopes.
(pushdecl_nanmespace_level): Remove shadow stack nadgering.
(do_pushtag): Use REAL_IDENTIFIER_TYPE_VALUE.
* call.c (check_dtor_name): Use lookup_name.
* decl.c (cxx_init_decl_processing): Drop global_type_node.
* decl2.c (cplus_decl_attributes): Don't SET_IDENTIFIER_TYPE_VALUE
here.
* init.c (get_type_value): Delete.
* pt.c (instantiate_class_template_1): Don't call pushtag or
SET_IDENTIFIER_TYPE_VALUE here.
(tsubst): Assert never an identifier.
(dependent_type_p): Drop global_type_node assert.
* typeck.c (error_args_num): Don't use IDENTIFIER_HAS_TYPE_VALUE
to determine ctorness.
gcc/testsuite/
* g++.dg/lookup/pr99039.C: New.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/99040] [modules] partitions & using declarations
2021-02-09 18:31 [Bug c++/99040] New: [modules] partitions & using declarations nathan at gcc dot gnu.org
2021-02-10 21:05 ` [Bug c++/99040] " nathan at gcc dot gnu.org
2021-02-12 21:50 ` cvs-commit at gcc dot gnu.org
@ 2021-02-12 21:50 ` cvs-commit at gcc dot gnu.org
2021-02-12 21:51 ` nathan at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-12 21:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99040
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathan Sidwell <nathan@gcc.gnu.org>:
https://gcc.gnu.org/g:0c27fe96f812df76ca07272d3c68765bd1f9dc08
commit r11-7229-g0c27fe96f812df76ca07272d3c68765bd1f9dc08
Author: Nathan Sidwell <nathan@acm.org>
Date: Fri Feb 12 06:55:49 2021 -0800
c++: Register streamed-in decls when new [PR 99040]
With modules one can have using-decls refering to their own scope. This
is the way to export things from the GMF or from an import. The
problem was I was using current_ns == CP_DECL_CONTEXT (decl) to
determine whether a decl should be registered in a namespace level or
not. But that's an inadequate check and we ended up reregistering
decls and creating a circular list. We should be registering the decl
when first encountered -- whether we bind it is orthogonal to that.
PR c++/99040
gcc/cp/
* module.cc (trees_in::decl_value): Call add_module_namespace_decl
for new namespace-scope entities.
(module_state::read_cluster): Don't call add_module_decl here.
* name-lookup.h (add_module_decl): Rename to ...
(add_module_namespace_decl): ... this.
* name-lookup.c (newbinding_bookkeeping): Move into ...
(do_pushdecl): ... here. Its only remaining caller.
(add_module_decl): Rename to ...
(add_module_namespace_decl): ... here. Add checking-assert for
circularity. Don't call newbinding_bookkeeping, just extern_c
checking and incomplete var checking.
gcc/testsuite/
* g++.dg/modules/pr99040_a.C: New.
* g++.dg/modules/pr99040_b.C: New.
* g++.dg/modules/pr99040_c.C: New.
* g++.dg/modules/pr99040_d.C: New.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/99040] [modules] partitions & using declarations
2021-02-09 18:31 [Bug c++/99040] New: [modules] partitions & using declarations nathan at gcc dot gnu.org
` (2 preceding siblings ...)
2021-02-12 21:50 ` cvs-commit at gcc dot gnu.org
@ 2021-02-12 21:51 ` nathan at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: nathan at gcc dot gnu.org @ 2021-02-12 21:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99040
Nathan Sidwell <nathan at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #3 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
0c27fe96f81 2021-02-12 | c++: Register streamed-in decls when new [PR 99040]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-02-12 21:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-09 18:31 [Bug c++/99040] New: [modules] partitions & using declarations nathan at gcc dot gnu.org
2021-02-10 21:05 ` [Bug c++/99040] " nathan at gcc dot gnu.org
2021-02-12 21:50 ` cvs-commit at gcc dot gnu.org
2021-02-12 21:50 ` cvs-commit at gcc dot gnu.org
2021-02-12 21:51 ` nathan at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).