[PATCH] D102241: [clang] p1099 4/5: using enum EnumTag

David Rector via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat May 22 12:46:52 PDT 2021


davrec added inline comments.


================
Comment at: clang/include/clang/AST/ASTContext.h:520-523
+  /// Like InstantiatedFromUsingDecl, but for using-enum declarations. Maps
+  /// from the instantiated using-enum to the templated decl from whence it
+  /// came.
+  llvm::DenseMap<NamedDecl *, NamedDecl *> InstantiatedFromUsingEnumDecl;
----------------
davrec wrote:
> We need a detailed example in the documentation, since IIUC P1099 does not allow a using-enum-declaration to name "dependent" enums and thus is distinguished from using-declarations. Specifically the wording is:
> > using-enum-declaration:
> >      using elaborated-enum-specifier ;
> > 1. The elaborated-enum-specifier shall not name a dependent type and the type shall have a reachable enum-specifier.
> > ...
> (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1099r5.html)
> 
> Now I'm not 100% clear on what that wording permits, but we need an example of how a UsingEnumDecl can be an instantiation.  Something like this maybe?  
> ```
> template<unsigned N>
> struct Foo {
>   enum E { e = N };
> };
> template<unsigned N>
> struct Bar : Foo<N> {
>   using enum Foo<N>::E; //Allowed per P1099?
> };
> Bar<1>;
> ```
> 
> We can also clarify the types here to
> ```
> llvm::DenseMap<UsingEnumDecl *, UsingEnumDecl *>
> ```
> since there are no UnresolvedUsing*Decl` versions to account for, as there were with using decls.
It occurs to me that, duh, non-dependent declarations in a template still need to be instantiated.
So in summary I would just change these lines to this:
```
  /// Like InstantiatedFromUsingDecl, but for using-enum-declarations. Maps
  /// from the instantiated using-enum to the templated decl from whence it
  /// came.
  /// Note that using-enum-declarations cannot be dependent and
  /// thus will never be instantiated from an "unresolved"
  /// version thereof (as with using-declarations), so each mapping is from
  /// a (resolved) UsingEnumDecl to a (resolved) UsingEnumDecl.
  llvm::DenseMap<UsingEnumDecl *, UsingEnumDecl *> InstantiatedFromUsingEnumDecl;  
```


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

https://reviews.llvm.org/D102241



More information about the cfe-commits mailing list