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

diagnostic improvement: missing-typename diagnostic #91337

Open
hokein opened this issue May 7, 2024 · 0 comments
Open

diagnostic improvement: missing-typename diagnostic #91337

hokein opened this issue May 7, 2024 · 0 comments
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer

Comments

@hokein
Copy link
Collaborator

hokein commented May 7, 2024

Given the following code:

template<typename T1>
struct A1 {
  template<typename T2>
  struct A2 { T2 t; };
};

template <typename K>
void s(K k) {
   A1<K>::A2 a(2); // missing a `typename` at head!
}

void s() {
  s<double>(1.0);
}

Diagnostics emitted by clang are not quite useful, it would be nice to emit a "missing typename" diagnostic (both gcc and msvc do it for this case).

<source>:15:13: error: expected ';' after expression
   15 |    A1<K>::A2 a(2); // missing a typenamea at head!
      |             ^
      |             ;
<source>:15:14: error: use of undeclared identifier 'a'
   15 |    A1<K>::A2 a(2); // missing a typename at head!
      |              ^
<source>:15:11: error: use of class template 'A2' requires template arguments
   15 |    A1<K>::A2 a(2); // missing a typename at head!
      |           ^
<source>:19:3: note: in instantiation of function template specialization 's<double>' requested here
   19 |   s<double>(1.0);
      |   ^
<source>:10:10: note: template is declared here
    9 |   template<typename T2>
      |   ~~~~~~~~~~~~~~~~~~~~~
   10 |   struct A2 { T2 t; };
      |          ^
@hokein hokein added the clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Projects
None yet
Development

No branches or pull requests

1 participant