[llvm-bugs] [Bug 39118] New: Visibility attribute ignored on static data member explicit instantiation

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 28 12:15:43 PDT 2018


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

            Bug ID: 39118
           Summary: Visibility attribute ignored on static data member
                    explicit instantiation
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ldionne at apple.com
                CC: llvm-bugs at lists.llvm.org

Visibility attributes applied to explicit instantiations of non-static data
members appear to be ignored by Clang. In the following example, I apply hidden
visibility to everything in the namespace, but I explicitly instantiate
Bar<int>::foo with default visibility. The expected behavior is that
Bar<int>::foo is given default visibility, but the actual behavior is that is
has hidden visibility.

-----------------------------------------------------------
// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s

#define HIDDEN __attribute__((__visibility__("hidden")))
#define VISIBLE __attribute__((__visibility__("default")))

namespace ns HIDDEN {
    struct Foo { };

    template <typename T>
    struct Bar {
        static Foo foo;
    };

    template <typename T>
    Foo Bar<T>::foo;

    // CHECK: @_ZN2ns3BarIiE3fooE = weak_odr global
    // CHECK-NOT: hidden
    template VISIBLE Foo Bar<int>::foo;
}
-----------------------------------------------------------

This test case should work inside the llvm-lit test suite. It can also be run
as `clang++ t.cpp -shared | nm`, and then you can notice that `Bar<int>::foo`
is not exported from the generated executable:

0000000000001000 d __ZN2ns3BarIiE3fooE
                 U dyld_stub_binder

-- 
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/20180928/841aa42e/attachment.html>


More information about the llvm-bugs mailing list