[llvm-bugs] [Bug 34614] New: clang silently ignores visibility attributes after implicit instantiation

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 14 16:51:35 PDT 2017


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

            Bug ID: 34614
           Summary: clang silently ignores visibility attributes after
                    implicit instantiation
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: smeenai at fb.com
                CC: compnerd at compnerd.org, dgregor at apple.com,
                    eric at efcs.ca, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

% cat repro.cc
template <class> class c { void f() {} };
template <> void c<int>::f() {}
template class __attribute__((__visibility__("default"))) c<int>;

% clang++ -std=c++11 -fvisibility=hidden -fvisibility-inlines-hidden \
    -Wall -S -emit-llvm -o - | grep _ZN1cIiE1fEv
define hidden void @_ZN1cIiE1fEv(%class.c* %this) #0 align 2 {

The specialization on line 2 causes an implicit instantiation, which causes the
attributes on the explicit instantiation to be ignored. Ignoring the attributes
is a perfectly sane thing to do, but we should at least warn when we're doing
this, similar to gcc:

% g++ -std=c++11 -fsyntax-only repro.cc
repro.cc:3:59: warning: type attributes ignored after type is already defined
[-Wattributes]
 template class __attribute__((__visibility__("default"))) c<int>;

-- 
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/20170914/39d44bd8/attachment.html>


More information about the llvm-bugs mailing list