[patch] Fix pr18141

Rafael EspĂ­ndola rafael.espindola at gmail.com
Fri Dec 6 19:17:04 PST 2013


On 5 December 2013 17:23, Reid Kleckner <rnk at google.com> wrote:
> What happens for an invalid test case like:
>
> template <typename T>
> struct S {
>   void f(T t) {
>     t = 42;
>   }
> };
> template<> void __cdecl S<void*>::f(void*);
> void g(S<void*> s, void* p) {
>   s.f(p);
> }
>
> MSVC rejects this with "error C2373: 'S<T>::f' : redefinition; different
> type modifiers".  Do we just paper that over and adjust to __thiscall?

With the previous patch we would still produce an error:

/Users/respindola/llvm/test.cpp:7:35: error: function declared 'cdecl'
here was previously declared 'thiscall'
template<> void __cdecl S<void*>::f(void*);
                                  ^
/Users/respindola/llvm/test.cpp:7:35: note: previous declaration is here

but clang was clearly getting confused as show by the note on the same
line as the error.

> Maybe the right thing is to use a comparison that knows how to overlook
> implicit CC differences, but knows about explicit CC differences.

The attached patch does that. With it clang prints an error about the
__cdecl, ignores the broken specialization and continues.

Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: application/octet-stream
Size: 1969 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131206/5b004b0b/attachment.obj>


More information about the cfe-commits mailing list