<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 should apply __declspec() to expression, not type, when it's written in front of the tag keyword" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24251&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=J02LpY0UV3WXEwLkmozoL4dE-bVtxqzicgYceOrTO0g&s=kJQRZRbnAEekt2m-Gsd9XjXL6GJIc-WYjcATLXjwmtI&e=">24251</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[ms] clang-cl should apply __declspec() to expression, not type, when it's written in front of the tag keyword
          </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>All
          </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>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>nicolasweber@gmx.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When building perl on Windows with clang-cl:

        cl -c -I. -nologo -GF -W3 -I..\lib\CORE -I.\include -I. -I.. -DWIN32
-D_CONSOLE -DNO_STRICT -DWIN64 -DCONSERVATIVE -D_CRT_SECURE_NO_DEPRECATE
-D_CRT_NONSTDC_NO_DEPRECATE -DPERLDLL -DPERL_CORE
  -O1 -MD -Zi -DNDEBUG -GL -fp:precise  -DPERL_TEXTMODE_SCRIPTS
-DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -TP -EHsc -Foperllib.obj perllib.c
clang-cl.exe: warning: argument unused during compilation: '-GL'
In file included from perllib.c:10:
In file included from ..\lib\CORE\perl.h:3060:
In file included from .\win32thread.h:4:
./win32.h(284,25) :  error: 'selectany' can only be applied to data items with
external linkage


That line is:

extern const __declspec(selectany) union { unsigned __int64 __q; double __d; }
__PL_nan_u = { 0x7FF8000000000000UI64 };


If it's written like so, clang-cl accepts it:

union U { unsigned __int64 __q; double __d; };
extern const __declspec(selectany) U __PL_nan_u = { 0x7FF8000000000000UI64 };


I guess cl.exe applies the declspec to __PL_nan_u while we try to apply it to
the type? (Even though it's written before "union", so according to
<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__msdn.microsoft.com_en-2Dus_library_dabb5z75.aspx&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=J02LpY0UV3WXEwLkmozoL4dE-bVtxqzicgYceOrTO0g&s=jOZyTEtGzI2Q474cYD0mIjC4Ex0gNer1GosU13eXCec&e=">https://msdn.microsoft.com/en-us/library/dabb5z75.aspx</a> it should apply to the
variable.)</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>