[cfe-commits] [patch] Disallow decltype in qualified declarator-ids
Eli Friedman
eli.friedman at gmail.com
Mon Dec 12 23:53:24 PST 2011
On Mon, Dec 12, 2011 at 11:18 PM, David Blaikie <dblaikie at gmail.com> wrote:
> 8.3\1 dcl.meaning states:
> "The nested-name-specifier of a qualified declarator-id shall not
> begin with a decltype-specifier."
>
> & this patch implements that, disallowing things like:
>
> struct foo {
> static int i;
> };
>
> int decltype(foo())::i;
>
> The source range in the error message isn't perfect (due to the
> unaddressed fixme in DecltypeTypeLoc - it doesn't have the full source
> range, just the location of the 'decltype' keyword. I'll address this
> separately) & I haven't provided a fixit for this at the moment (it'd
> be possible to suggest replacing the decltype with the actual
> qualified name, at least for now -I'm not sure what we'll be doing
> about unnameable types that come with lambdas, though).
I don't think lambdas are really relevant here: I can't think of a way
to write a legal declaration starting with a decltype of a lambda
type. That said, I don't think there's a reliable way to FIXME out of
this, short of inserting a typedef: what if the decltype is dependent,
or refers to a user-defined unnamed struct type?
The patch looks fine otherwise.
-Eli
More information about the cfe-commits
mailing list