[llvm-bugs] [Bug 40704] New: Attributes accepted with linkage spec declarations

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Feb 12 07:18:26 PST 2019


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

            Bug ID: 40704
           Summary: Attributes accepted with linkage spec declarations
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: aaron at aaronballman.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

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();

-- 
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/20190212/a97c7869/attachment-0001.html>


More information about the llvm-bugs mailing list