/* Fall through. */
case VAR_DECL:
case FUNCTION_DECL:
- if (! TREE_PUBLIC (t))
+ if (decl_constant_var_p (t))
+ /* The ODR allows definitions in different TUs to refer to distinct
+ constant variables with internal or no linkage, so such a reference
+ shouldn't affect visibility (PR110323). FIXME but only if the
+ lvalue-rvalue conversion is applied. */;
+ else if (! TREE_PUBLIC (t))
tpvis = VISIBILITY_ANON;
else
tpvis = DECL_VISIBILITY (t);
--- /dev/null
+// PR c++/110323
+// { dg-do compile { target c++14 } }
+
+template<bool B, class T, class F>
+struct conditional { using type = T; };
+
+template<class T, class F>
+struct conditional<false, T, F> { using type = F; };
+
+constexpr int VAL = 1;
+
+static constexpr int getval () { return 1; }
+
+template<typename>
+constexpr int TVAL = 1;
+
+static struct S {
+ constexpr operator bool() { return true; }
+} s;
+
+struct foo {
+ template <int B>
+ void bar(typename conditional<B == VAL, int, float>::type arg) { }
+
+ template <int B>
+ void qux(typename conditional<B == TVAL<int>, int, float>::type arg) { }
+
+ template <int B>
+ void sox(typename conditional<B == noexcept (VAL), int, float>::type arg) { }
+
+ template <int B>
+ void nim(typename conditional<B != sizeof (VAL), int, float>::type arg) { }
+};
+
+template void foo::bar<1>(int arg);
+template void foo::qux<1>(int arg);
+template void foo::sox<1>(int arg);
+template void foo::nim<1>(int arg);
+
+// { dg-final { scan-assembler "_ZN3foo3barILi1EEEvN11conditionalIXeqT_L_ZL3VALEEifE4typeE" } }
+// { dg-final { scan-assembler "_ZN3foo3quxILi1EEEvN11conditionalIXeqT_L_Z4TVALIiEEEifE4typeE" } }
+// { dg-final { scan-assembler "_ZN3foo3soxILi1EEEvN11conditionalIXeqT_nxL_ZL3VALEEifE4typeE" } }
+// { dg-final { scan-assembler "_ZN3foo3nimILi1EEEvN11conditionalIXneT_szL_ZL3VALEEifE4typeE" } }
--- /dev/null
+// PR c++/110323
+// { dg-do compile { target c++11 } }
+
+using P = struct { }*;
+using N = struct A { }*;
+
+template<bool B, class T, class F>
+struct conditional { using type = T; };
+
+struct foo {
+ template <int B>
+ void bar(typename conditional<((P) 0, B), int, float>::type arg) { }
+
+ template <int B>
+ void baz(typename conditional<((N) 0, B), int, float>::type arg) { }
+};
+
+template void foo::bar<1>(int arg);
+template void foo::baz<1>(int arg);
+
+// { dg-final { scan-assembler-not "_ZN3foo3barILi1EEEvN11conditionalIXcmcvP1XLi0EneT_Li0EEifE4typeE" } }
+// { dg-final { scan-assembler "_ZN3foo3bazILi1EEEvN11conditionalIXcmcvP1ALi0EneT_Li0EEifE4typeE" } }