<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - [ms] clang-cl fails to compile WTL header "atlctrlx.h" and several related samples"
   href="https://llvm.org/bugs/show_bug.cgi?id=27733">27733</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[ms] clang-cl fails to compile WTL header "atlctrlx.h" and several related samples
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>kul92@list.ru
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>!- 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===========
<span class="quote">>>></span >
1) Download WTL from here: <a href="https://sourceforge.net/projects/wtl/">https://sourceforge.net/projects/wtl/</a> to [WTL_HOME] 
2) Goto [WTL_HOME]/Samples/TabBrowser
3) clang-cl -c -D "_UNICODE" -D "UNICODE" -I ../../include  -w TabBrowser.cpp 

<span class="quote">>>></span >
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==================
<span class="quote">>>>clang-cl:</span >
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);

<span class="quote">>>>msvc: no diagnostics</span >



Andrey Kuleshov
======
Software Engineer
Intel Compiler Team</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>