int *vis_p = (int *)data;
int tpvis = VISIBILITY_DEFAULT;
- switch (TREE_CODE (*tp))
+ tree t = *tp;
+ if (TREE_CODE (t) == PTRMEM_CST)
+ t = PTRMEM_CST_MEMBER (t);
+ switch (TREE_CODE (t))
{
case CAST_EXPR:
case IMPLICIT_CONV_EXPR:
case NEW_EXPR:
case CONSTRUCTOR:
case LAMBDA_EXPR:
- tpvis = type_visibility (TREE_TYPE (*tp));
+ tpvis = type_visibility (TREE_TYPE (t));
break;
+ case TEMPLATE_DECL:
+ if (DECL_ALIAS_TEMPLATE_P (t))
+ /* FIXME: We don't maintain TREE_PUBLIC / DECL_VISIBILITY for
+ alias templates so we can't trust it here (PR107906). */
+ break;
+ t = DECL_TEMPLATE_RESULT (t);
+ /* Fall through. */
case VAR_DECL:
case FUNCTION_DECL:
- if (! TREE_PUBLIC (*tp))
+ if (! TREE_PUBLIC (t))
tpvis = VISIBILITY_ANON;
else
- tpvis = DECL_VISIBILITY (*tp);
+ tpvis = DECL_VISIBILITY (t);
+ break;
+
+ case FIELD_DECL:
+ tpvis = type_visibility (DECL_CONTEXT (t));
break;
default:
--- /dev/null
+// PR c++/70413
+// { dg-do compile { target c++11 } }
+// { dg-final { scan-assembler-not "(weak|glob)\[^\n\]*_Z" } }
+
+namespace {
+ template<class> struct A;
+}
+
+template<template<class> class Q> void f() { }
+
+int main() {
+ f<A>();
+}
--- /dev/null
+// PR c++/70413
+// { dg-final { scan-assembler-not "(weak|glob)\[^\n\]*_Z" } }
+
+namespace {
+ struct A {
+ void f();
+ int m;
+ };
+}
+
+template<void(A::*)()> void g() { }
+template<int A::*> void h() { }
+
+int main() {
+ g<&A::f>();
+ h<&A::m>();
+}
--- /dev/null
+// PR c++/107906
+// { dg-do compile { target c++11 } }
+// { dg-final { scan-assembler-not "(weak|glob)\[^\n\]*_Z" { xfail *-*-* } } }
+
+namespace {
+ template<class> using X = int;
+ struct A {
+ template<class> using X = int;
+ };
+}
+template<template<class> class Q> void f() { }
+
+int main() {
+ f<X>();
+ f<A::X>();
+}
--- /dev/null
+// { dg-do compile { target c++11 } }
+// { dg-final { scan-assembler "(weak|glob)\[^\n\]*_Z1fI1XEvv" } }
+// { dg-final { scan-assembler "(weak|glob)\[^\n\]*_Z1fIN1A1XEEvv" } }
+
+template<class> using X = int;
+struct A {
+ template<class> using X = int;
+};
+template<template<class> class Q> void f() { }
+
+int main() {
+ f<X>();
+ f<A::X>();
+}