LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 18443 - [ms-compatibility] Recover better from missing 'typename' in sizeof
Summary: [ms-compatibility] Recover better from missing 'typename' in sizeof
Status: NEW
Alias: None
Product: clang
Classification: Unclassified
Component: -New Bugs (show other bugs)
Version: trunk
Hardware: PC Windows XP
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-10 23:42 PST by Richard Smith
Modified: 2014-01-13 17:05 PST (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Smith 2014-01-10 23:42:01 PST
Consider:

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

Clang diagnoses this as:

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

... 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.
Comment 1 David Majnemer 2014-01-11 11:07:14 PST
If we implemented token substitution for template instantiation, would this be fixed?
Comment 2 Richard Smith 2014-01-13 17:05:10 PST
(In reply to comment #1)
> If we implemented token substitution for template instantiation, would this
> be fixed?

Yes, that'd do the trick.