[PATCH] D74103: Implement P1766R1: diagnose giving non-C-compatible classes a typedef name for linkage purposes.

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 6 15:02:20 PST 2020


rsmith added inline comments.


================
Comment at: clang/lib/Sema/SemaDecl.cpp:4394
+        isa<EnumDecl>(D))
+      continue;
+
----------------
rjmccall wrote:
> This is essentially part of the next paragraph.
> 
> I believe `friend` declarations also do not declare "members", under the same logic allowing `static_assert`.
I think you're right, but that's a defect in the wording -- a friend definition, at least, could use the class in a way that requires a linkage calculation, and the design intent as approved by the Evolution Working Group did not permit friend declarations. I'll take this back to the committee for some rewording, but I think it makes sense to proceed under the assumption that friends won't be allowed. In any case, I'm updating the diagnostic to treat friends as a special case, since they're not member declarations.


================
Comment at: clang/lib/Sema/SemaDecl.cpp:4404
+    if (MemberRD->isLambda())
+      return {NonCLikeKind::Lambda, MemberRD->getSourceRange()};
+
----------------
rjmccall wrote:
> Do lambdas in nested expressions really get added to the class's decls list?  I wouldn't have expected that, but it definitely makes this check a lot easier.
They end up in some enclosing `DeclContext`, which is either the class itself or something else that we also disallow.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74103/new/

https://reviews.llvm.org/D74103





More information about the cfe-commits mailing list