Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

note on locations where nodeclspec-function-declarator can appear seems to be incorrect #2276

Closed
zygoloid opened this issue Jul 23, 2018 · 4 comments
Assignees

Comments

@zygoloid
Copy link
Member

[dcl.dcl]p12 says:

A nodeclspec-function-declaration shall declare a constructor, destructor, or conversion function. [Footnote: The “implicit int” rule of C is no longer supported.] [Note: A nodeclspec-function-declaration can only be used in a template-declaration (Clause 12), explicit-instantiation (12.8.2), or explicit-specialization (12.8.3). — end note]

This is wrong in two ways.

  1. The footnote is wrong: the "implicit int" rule in C never permitted declarations without any specifiers-and-qualifiers, so implicit int has nothing to do with nodeclspec-function-declarations.
  2. The note is wrong: a nodeclspec-function-declaration can't be used in a template-declaration. An out-of-line declaration of a member function must be either a definition, a friend, an explicit instantiation, or an explicit specialization, and a non-defining template-declaration is none of those things. (See [class.mfct]p1, which would incidentally benefit from saying something about the friend and explicit instantiation cases, though the friend case is at least mentioned by p6.)
@jensmaurer
Copy link
Member

jensmaurer commented Jul 23, 2018

[dcl.type] p3 already has a footnote talking about the "implicit int rule". Let's remove the footnote.

@zygoloid, I don't understand the point on the note. I believe there are template-declaration s where we can, in fact, use a nodeclspec-function-declaration (admittedly, those are definitions, but declaration is not limited to non-defining declarations, I believe). And the note is correct in saying that a nodeclspec-function-declaration cannot appear outside of the listed contexts, although it is true that not all listed contexts will allow a nodeclspec-function-declaration in all cases. But I don't read the text of the note as attempting to say the latter.

@jensmaurer
Copy link
Member

@zygoloid: I get it now: The grammar for nodeclspec-function-declaration only allows a non-defining declaration.

@jensmaurer
Copy link
Member

@zygoloid: It seems to me that

struct S {
  template<class T> S(T);
};

recurses through member-declaration / template-declaration / declaration / nodeclspec-function-declaration and that's where the note applies. [temp] p2 says the declaration must declare a function, which it does, if [dcl.fct] is ever supposed to be applicable to constructors ("returning T"?)

@zygoloid
Copy link
Member Author

Ah, yes, OK then. So the note is subtle but correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants