[PATCH] D90188: Add support for attribute 'using_if_exists'

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 6 14:26:43 PDT 2021


aaron.ballman added inline comments.


================
Comment at: clang/test/SemaCXX/using-if-exists.cpp:79
+  using B::mf UIE; // expected-note {{using declaration annotated with 'using_if_exists' here}}
+  using typename B::mt UIE; // expected-note 2 {{using declaration annotated with 'using_if_exists' here}}
+
----------------
erik.pilkington wrote:
> Quuxplusone wrote:
> > I notice there's a hard `error: 'using_if_exists' attribute cannot be applied to types` on
> > 
> >     using B::operator int UIE;
> > 
> > Any thoughts on how to disambiguate that grammar?
> Hmm, that's an interesting case. I'm not sure what the right approach is. I think it would be a bit awkward to decide where to attach the attribute depending on what kind of entities the attribute could potentially apply to. FWIW this isn't a semantic restriction, since you can always just use the prefix syntax: `UIE using B::operator int;`. Maybe @aaron.ballman has some thoughts here?
By my reading of the standard, an attribute in that position really does apply to the type `int` in that case.

https://eel.is/c++draft/namespace.udecl#nt:using-declarator
https://eel.is/c++draft/expr.prim.id.unqual#nt:unqualified-id
https://eel.is/c++draft/class.conv.fct#nt:conversion-function-id
https://eel.is/c++draft/class.conv.fct#nt:conversion-type-id
https://eel.is/c++draft/dcl.type.general#nt:type-specifier-seq
https://eel.is/c++draft/dcl.type.general#1.sentence-2

That said, I don't know if that's really *expected* behavior, so this might be a question for WG21.


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

https://reviews.llvm.org/D90188



More information about the cfe-commits mailing list