c++: Allow exporting a typedef redeclaration [PR102341]
commit9dd8be6fc2debc4fbd0950386d4e98878af27a45
authorNathaniel Shead <nathanieloshead@gmail.com>
Mon, 13 Nov 2023 05:48:36 +0000 (13 16:48 +1100)
committerNathaniel Shead <nathanieloshead@gmail.com>
Sat, 25 Nov 2023 01:44:17 +0000 (25 12:44 +1100)
tree73c796cfdef8fced6012cba8ab5fa9da5c139f9b
parent77cf1dba78b25f2e57bdbcffd6499a288772e700
c++: Allow exporting a typedef redeclaration [PR102341]

A typedef doesn't create a new entity, and thus should be allowed to be
exported even if it has been previously declared un-exported. See the
example in [module.interface] p6:

  export module M;
  struct S { int n; };
  typedef S S;
  export typedef S S;             // OK, does not redeclare an entity

PR c++/102341

gcc/cp/ChangeLog:

* decl.cc (duplicate_decls): Allow exporting a redeclaration of
a typedef.

gcc/testsuite/ChangeLog:

* g++.dg/modules/export-1.C: Adjust test.
* g++.dg/modules/export-2_a.C: New test.
* g++.dg/modules/export-2_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
gcc/cp/decl.cc
gcc/testsuite/g++.dg/modules/export-1.C
gcc/testsuite/g++.dg/modules/export-2_a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/export-2_b.C [new file with mode: 0644]