<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - Attributes accepted with linkage spec declarations"
   href="https://bugs.llvm.org/show_bug.cgi?id=40704">40704</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Attributes accepted with linkage spec declarations
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>aaron@aaronballman.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Clang currently accepts all kinds of attributes before a linkage specification
declaration. e.g. (with -fdeclspec and GNU extensions enabled),


__attribute__(()) extern "C" void bar();
__declspec() extern "C" void baz();
[[]] extern "C" void foo();

__attribute__(()) extern "C" { void quux(); }
__declspec() extern "C" { void meow(); }
[[]] extern "C" { void woof(); }

GCC does not accept GNU-style attributes in that position, C++ does not allow
C++-style attributes in that position, but Microsoft *does* allow __declspec
attributes in that position.

We parse attributes before we determine we're parsing a linkage specification
because it makes the design of the parser easier. Unfortunately, the
declaration specifiers parsing construct does not track a
ParsedAttributesWithRange for the attributes, so there is not an easy way to
determine whether the declaration specifiers have attributes applied to them or
not. For instance, the empty attribute lists above are problematic because the
DS does not think there are any attributes applied to it. Further, we do not
track disjoint ranges of attributes particularly well, so declarations like
this could be tricky to diagnose:

__attribute__(()) __declspec() [[]] extern "C" void foo();</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>