[PATCH] D153542: [C++20][Modules] Implement P2615R1 exported specialization diagnostics.
Iain Sandoe via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 26 23:36:29 PDT 2023
iains planned changes to this revision.
iains added a comment.
need to re-check that the intention of the paper is covered (since we currently treat bare 'export' and 'export {}' in a similar manner).
================
Comment at: clang/lib/Sema/SemaModule.cpp:848-849
+ if (auto *FD = dyn_cast<FunctionDecl>(D)) {
+ if (FD->getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
+ BadExport = true;
+ } else if (auto *VD = dyn_cast<VarDecl>(D)) {
----------------
ChuanqiXu wrote:
> ChuanqiXu wrote:
> > iains wrote:
> > > ChuanqiXu wrote:
> > > > Given P2615R1 doesn't allow explicit-instantiation in export block too.
> > > I think I must be missing something - I do not see that in the paper - please could you expand your comment?
> > See the proposed change in #[module.interface]p1 in the paper, it changed:
> >
> > ```
> > export declaration
> > ```
> >
> > to
> >
> >
> > ```
> > export named-declaration
> > ```
> >
> > And the change between the old declaration and the new named declaration is in the proposed change in #[dcl.pre]p1. So it shows the special declarations shouldn't be allowed after `export`.
> >
> > Also I noted it is allowed to write `export { declaration-seq_opt }` where the `declaration-seq` may contain special declarations. It looks weird to me. I'll try to check it and ask WG21 when necessary.
> I checked the record. And it shows that the current wording reflects the intention. I mean
>
> ```
> export template<> class A<int>;
> ```
>
> is not allowed. But,
>
> ```
> export { template<> class A<int> };
> ```
>
> is allowed.
>
> See the proposed change in #[module.interface]p1 in the paper, it changed:
...
> And the change between the old declaration and the new named declaration is in the proposed change in #[dcl.pre]p1. So it shows the special declarations shouldn't be allowed after `export`.
>
> Also I noted it is allowed to write `export { declaration-seq_opt }` where the `declaration-seq` may contain special declarations. It looks weird to me. I'll try to check it and ask WG21 when necessary.
Indeed that does seem to be a strange mismatch - but you are right the introduction does mention this:
"This paper addresses CWG2443 by forbidding applying export directly to certain meaningless declarations. Conversely, it also allows all kinds to appear with export {}. For consistency extern "C" is given the same restrictions when used directly."
so I think I need to recheck this patch.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153542/new/
https://reviews.llvm.org/D153542
More information about the cfe-commits
mailing list