Skip to content

Diagnostics for template keywords showing up inside local classes aren't good #17959

Closed
@majnemer

Description

@majnemer
Bugzilla Link 17585
Version unspecified
OS Linux
CC @DougGregor,@zygoloid

Extended Description

consider:

void foo() {
  template <typename> int i;
}

we issue:

error: expected expression

gcc provides a better error:

error: a template declaration cannot appear at block scope

another case:

void foo() {
  struct S { template <typename> int i; };
}

we issue:

error: member 'i' declared as a template

gcc provides:

invalid declaration of member template in local class

These plain english messages are very nice, we should do something similar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions