[llvm-bugs] [Bug 27733] New: [ms] clang-cl fails to compile WTL header "atlctrlx.h" and several related samples

via llvm-bugs llvm-bugs at lists.llvm.org
Fri May 13 06:32:31 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=27733

            Bug ID: 27733
           Summary: [ms] clang-cl fails to compile WTL header "atlctrlx.h"
                    and several related samples
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kul92 at list.ru
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

!- This problem was found in WTL Sample TabBrowser but affects most all
samples. 
It also affects a compilation of WTL header atlctrlx.h, microsoft correctly
compiles such code. Seems that clang incorrectly parses this header.
In small reproducer section you can see a code that is reduced and is using
only headers from VS (including ATL) without using any headers from WTL -!

===========Environment===============
OS: Win
Language: c++
Version: trunk [3.8] 

===========How To Reproduce===========
>>>
1) Download WTL from here: https://sourceforge.net/projects/wtl/ to [WTL_HOME] 
2) Goto [WTL_HOME]/Samples/TabBrowser
3) clang-cl -c -D "_UNICODE" -D "UNICODE" -I ../../include  -w TabBrowser.cpp 

>>>
or download and compile code below ( includes were reduced a lot - see small
reproducer):
//these headers are from WTL library (they are not included inside VS package)
    #include <atlbase.h>
    #include <atlapp.h>
    #include <atlctl.h>
    #include <atlctrls.h>
    #include <atlctrlx.h>
using:
    clang-cl -c -D "_UNICODE" -D "UNICODE" -I ../include  -w test.cpp


==========Small Reproducer=============
//no need to download anything - these headers are from MSVS
#include <basetsd.h>
#include <atlbase.h>
#include <atlwin.h>

class CPaintDC{
public:
       HWND m_hWnd; // this name is unknown in OnPaint function
       CPaintDC(HWND hWnd){}
};

template <class TBase>
class CButtonT : public TBase{
public:
       CButtonT() {}
};

typedef CButtonT<ATL::CWindow> CButton;

template <class T, class TBase = CButton>
class CBitmapButtonImpl : public ATL::CWindowImpl < T >{
       public:
             CBitmapButtonImpl() {}

            int ProcessWindowMessage(HWND hWnd, unsigned int uMsg, UINT_PTR
wParam, LONG_PTR lParam, LRESULT& lResult, DWORD dwMsgMapID = 0){
                         OnPaint(uMsg, wParam, lParam); 
                         return 0;
            }

            void OnPaint(unsigned int, WPARAM wParam, LPARAM){
                           CPaintDC dc(m_hWnd); // ERROR appears here, note
also, that compiler incorrectly parse a statement and thinks that m_hWnd is a
type <<<
            }

};

class CBitmapButton : public CBitmapButtonImpl < CBitmapButton >{
       public:
             CBitmapButton() : CBitmapButtonImpl<CBitmapButton>() {}
};

===============Error==================
>>>clang-cl:
test.cpp(30,40) :  error: unknown type name 'm_hWnd'
                           CPaintDC dc(m_hWnd);
                                       ^
test.cpp(37,14) :  note: in instantiation of member function
'CBitmapButtonImpl<CBitmapButton,
      CButtonT<ATL::CWindow> >::ProcessWindowMessage' requested here
             CBitmapButton() : CBitmapButtonImpl<CBitmapButton>() {}
             ^
test.cpp(30,39) :  warning: parentheses were disambiguated as a function
declaration [-Wvexing-parse]
                           CPaintDC dc(m_hWnd);
                                      ^~~~~~~~
test.cpp(30,40) :  note: add a pair of parentheses to declare a variable
                           CPaintDC dc(m_hWnd);

>>>msvc: no diagnostics



Andrey Kuleshov
======
Software Engineer
Intel Compiler Team

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160513/7ef5cb8e/attachment.html>


More information about the llvm-bugs mailing list