[llvm-bugs] [Bug 29094] New: C++11 attributes not accepted in template explicit instantiation

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 22 10:51:21 PDT 2016


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

            Bug ID: 29094
           Summary: C++11 attributes not accepted in template explicit
                    instantiation
           Product: clang
           Version: 3.8
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: matthew.woehlke at kitware.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

Clang rejects the following code, with the error "an attribute list cannot
appear here":

  template <typename T>
  T foo(T) { return 0; }

  template [[gnu::visibility("default")]]
  int foo<int>(int);

Live example:
https://gcc.godbolt.org/#compilers:!((compiler:clang380,options:'-std%3Dc%2B%2B11',source:'template+%3Ctypename+T%3E%0AT+foo(T)+%7B+return+0%3B+%7D%0A%0Atemplate+%5B%5Bgnu::visibility(%22default%22)%5D%5D%0Aint+foo%3Cint%3E(int)%3B%0A')),filterAsm:(commentOnly:!t,directives:!t,labels:!t),version:3

GCC accepts this code. As I read N4606 [A.6] and [A.12], this should be
accepted as:

  <explicit-instantiation> -->
  [extern] template <declaration> -->
  [extern] template <nodeclspec-function-declaration> -->
  [extern] template [<attribute-specifier-seq>] <declarator> ;

Moreover, there doesn't seem to be any manner in which Clang accepts an
attribute on an explicit instantiation, which seems surely not intended. Also,
the old style attribute, `__attribute__((visibility("default")))`, is accepted.

-- 
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/20160822/79641ff5/attachment.html>


More information about the llvm-bugs mailing list