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

[dcl.spec.auto.general] Definition of _generic parameter type placeholder_ can be simplified #4904

Closed
JohelEGP opened this issue Sep 14, 2021 · 4 comments

Comments

@JohelEGP
Copy link
Contributor

JohelEGP commented Sep 14, 2021

The paragraph in question, p2, lists two places in the grammar where a placeholder-type-specifier of the form type-constraintopt auto can appear. It leaves one unused and defines a name for the other.

The two are mutually exclusive:

  • a decl-specifier of the decl-specifier-seq of a parameter-declaration of a function declaration or lambda-expression (the grammar for parameters), and
  • the auto type-specifier introducing a trailing-return-type (the grammar for the return type).

All the paragraph does is define a name for the former. The latter, redundantly excluded, also complicates the surrounding wording which could otherwise read simpler.

Note that this might be concurrently modified, as the paragraph or its subclause seem to have more problems as pointed out at https://bugs.llvm.org/show_bug.cgi?id=51856#c3.

@xmh0511
Copy link
Contributor

xmh0511 commented Sep 15, 2021

[dcl.spec.auto.general] p2 is basically discussing the placeholder types of the parameters of a function or lambda. It simply says "auto type-specifier introducing a trailing-return-type" is not considered as a generic parameter type placeholder. I think they are not redundant and it is significant to clarify which placeholder types can be a generic parameter type placeholders.

@JohelEGP
Copy link
Contributor Author

But can the "auto type-specifier introducing a trailing-return-type" be "a decl-specifier of the decl-specifier-seq of a parameter-declaration of a function declaration or lambda-expression"? It reads to me as if "the auto in 'auto f() -> T' appears in the declaration of a parameter". Could it be to account for a case like

auto f(auto(*)()->int) -> int;

@xmh0511
Copy link
Contributor

xmh0511 commented Sep 15, 2021

"auto type-specifier introducing a trailing-return-type" be "a decl-specifier of the decl-specifier-seq of a parameter-declaration of a function declaration or lambda-expression"

Yes, it is permitted by the grammar of the parameter-declaration defined at [dcl.fct] p3. Hence,

auto f(auto(*)()->int) -> int;

It is valid but the parameter is not considered to have a generic parameter type placeholder, it does not form the abbreviate function template.

Paragraph 2 can be read as

A placeholder-type-specifier of the form type-constraint auto auto can be used as a decl-specifier in

  • the decl-specifier-seq of a parameter-declaration of a function declaration, or
  • the decl-specifier-seq of a parameter-declaration of a lambda-expression

if it is not the auto type-specifier introducing a trailing-return-type

  • the placeholder type is a generic parameter type placeholder of the parameter of a function or lambda

Otherwise

  • the placeholder type is not a generic parameter type placeholder

@JohelEGP
Copy link
Contributor Author

Thank you. So the intention is to prevent g in auto f(auto(*g)()->int) -> int; from being a generic parameter type placeholder.

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

Successfully merging a pull request may close this issue.

2 participants