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: [email protected]
          Reporter: [email protected]
                CC: [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to