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

[ms-compatibility] Recover better from missing 'typename' in sizeof #18817

Closed
zygoloid mannequin opened this issue Jan 11, 2014 · 4 comments
Closed

[ms-compatibility] Recover better from missing 'typename' in sizeof #18817

zygoloid mannequin opened this issue Jan 11, 2014 · 4 comments
Labels
bugzilla Issues migrated from bugzilla clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer

Comments

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented Jan 11, 2014

Bugzilla Link 18443
Version trunk
OS Windows XP
CC @majnemer,@rnk

Extended Description

Consider:

struct X { typedef int type; };
template void f() { sizeof(T::type); }
template void f();

Clang diagnoses this as:

:2:43: error: unexpected type name 'type': expected expression
template void f() { sizeof(T::type); }
^
:3:15: note: in instantiation of function template specialization 'f' requested here
template void f();
^

... but this sort of thing apparently happens inside MS system headers. We should support this case of missing 'typename' more elegantly -- perhaps we can teach TreeTransform to cope with this during instantiation.

@majnemer
Copy link
Mannequin

majnemer mannequin commented Jan 11, 2014

If we implemented token substitution for template instantiation, would this be fixed?

@zygoloid
Copy link
Mannequin Author

zygoloid mannequin commented Jan 14, 2014

If we implemented token substitution for template instantiation, would this
be fixed?

Yes, that'd do the trick.

@rnk
Copy link
Collaborator

rnk commented Nov 26, 2021

mentioned in issue llvm/llvm-bugzilla-archive#18714

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
@AaronBallman
Copy link
Collaborator

We currently issue this warning:

<source>:2:40: error: missing 'typename' prior to dependent type name 'X::type'
template<typename T> void f() { sizeof(T::type); }
                                       ^~~~~~~
                                       typename 

so I'm closing this as being implemented.

@EugeneZelenko EugeneZelenko added clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer and removed clang Clang issues not falling into any other category labels Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla 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

3 participants