]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Constructor streaming [PR105322]
authorNathan Sidwell <nathan@acm.org>
Fri, 20 Oct 2023 16:20:37 +0000 (12:20 -0400)
committerNathan Sidwell <nathan@acm.org>
Fri, 20 Oct 2023 20:24:49 +0000 (16:24 -0400)
commit084addf8a700fab9222d4127ab8524920d0ca481
tree1ce1f519ced10494d25476a8a194e7e2ed2d124a
parent7069ea909f5292a17d22e5e68218373186820d29
c++: Constructor streaming [PR105322]

An expresion node's type is streamed after the expression's operands,
because the type can come from some aspect of an operand (for instance
decltype and noexcept). There's a comment in the code explaining that.

But that doesn't work for constructors, which can directly reference
components of their type (eg FIELD_DECLS). If this is a
type-introducing CONSTRUCTOR, we need to ensure the type has been
streamed first. So move CONSTRUCTOR stream to after the type streaming.

The reason things like COMPONENT_REF work is that they stream their
first operand first, and that introduces the type that their second
operand looks up a field in.

gcc/cp/
PR c++/105322
* module.cc (trees_out::core_vals): Stream CONSTRUCTOR operands
after the type.
(trees_in::core_vals): Likewise.
gcc/testsuite/
* g++.dg/modules/decltype-1_a.C: New.
* g++.dg/modules/decltype-1_b.C: New.
* g++.dg/modules/lambda-5_a.C: New.
* g++.dg/modules/lambda-5_b.C: New.
gcc/cp/module.cc
gcc/testsuite/g++.dg/modules/decltype-1_a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/decltype-1_b.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/lambda-5_a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/lambda-5_b.C [new file with mode: 0644]