-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Full name of submitter (unless configured in github; will be published with the issue): Ambrose T
Reference (section label): [temp.pre]
Issue description:
I ran into the following case while implementing variadic friends in Clang. Consider
template <typename>
friend class Foo, int;This is obviously nonsense, but the grammar currently seems to allow it. A friend-type-declaration ([class.mem.general]) is defined as
friend-type-declaration:
friend friend-type-specifier-list ;
friend-type-specifier-list:
friend-type-specifier ...[opt]
friend-type-specifier-list , friend-type-specifier ...[opt]
friend-type-specifier:
simple-type-specifier
elaborated-type-specifier
typename-specifier
In p3 of that same section, we find
A member-declaration does not declare new members of the class if it is
(3.1) a friend declaration ([class.friend]), [...]
(3.3) a template-declaration whose declaration is one of the above,
which tells us that a template-declaration whose declaration is a friend-type-declaration is valid, but that doesn’t exclude the case I listed above. [temp.pre] disallows this for declarators (p5):
In a template-declaration, explicit specialization, or explicit instantiation, the init-declarator-list in the declaration shall contain at most one declarator.
But the case above, while a template-declaration, doesn’t even have declarators. It seems this case needs to be disallowed separately, but I can’t seem to find any section that would do that.
Suggested resolution:
In [temp.pre], add this to p5 (or as a separate paragraph after that; I’m not sure which would be better):
In a template-declaration whose declaration is a friend-type-declaration, the friend-type-specifier-list shall contain exactly one friend-type-specifier.