From 37c1d7cd8b08fea9a1078e16410f787093e7440b Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 20 May 2013 12:28:49 +0000 Subject: [PATCH] PR c++/57317 * decl2.c (determine_visibility): Use PRIMARY_TEMPLATE_P to decide whether a template has its own args. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@199101 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/decl2.c | 5 +---- gcc/testsuite/g++.dg/warn/anonymous-namespace-4.C | 12 ++++++++++++ gcc/testsuite/g++.dg/warn/anonymous-namespace-4.h | 14 ++++++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/warn/anonymous-namespace-4.C create mode 100644 gcc/testsuite/g++.dg/warn/anonymous-namespace-4.h diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9d8ad50..0fee1b5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-05-20 Jason Merrill + + PR c++/57317 + * decl2.c (determine_visibility): Use PRIMARY_TEMPLATE_P to decide + whether a template has its own args. + 2013-05-20 Paolo Carlini PR c++/57327 diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 8d2385d..358a26f 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -2210,9 +2210,6 @@ determine_visibility (tree decl) && !lookup_attribute ("visibility", attribs)) { int depth = TMPL_ARGS_DEPTH (args); - int class_depth = 0; - if (class_type && CLASSTYPE_TEMPLATE_INFO (class_type)) - class_depth = TMPL_ARGS_DEPTH (CLASSTYPE_TI_ARGS (class_type)); if (DECL_VISIBILITY_SPECIFIED (decl)) { /* A class template member with explicit visibility @@ -2225,7 +2222,7 @@ determine_visibility (tree decl) constrain_visibility_for_template (decl, lev); } } - else if (depth > class_depth) + else if (PRIMARY_TEMPLATE_P (TI_TEMPLATE (tinfo))) /* Limit visibility based on its template arguments. */ constrain_visibility_for_template (decl, args); } diff --git a/gcc/testsuite/g++.dg/warn/anonymous-namespace-4.C b/gcc/testsuite/g++.dg/warn/anonymous-namespace-4.C new file mode 100644 index 0000000..7d1e89e --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/anonymous-namespace-4.C @@ -0,0 +1,12 @@ +// PR c++/57137 + +#include "anonymous-namespace-4.h" + +namespace +{ + class NonCloneable; + void fn1 () + { + is_function_impl < NonCloneable > i; + } +} diff --git a/gcc/testsuite/g++.dg/warn/anonymous-namespace-4.h b/gcc/testsuite/g++.dg/warn/anonymous-namespace-4.h new file mode 100644 index 0000000..e0b7d68 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/anonymous-namespace-4.h @@ -0,0 +1,14 @@ +template < typename T > struct integral_c { + static const T value = 0; +}; +struct is_reference:integral_c < bool > { }; +template < class > struct is_function_ptr_helper { }; +template < bool > struct is_function_chooser; + +template <> struct is_function_chooser <0 > +{ + template < typename T > struct result_:is_function_ptr_helper < T * > { }; +}; + +template < typename T > struct is_function_impl:is_function_chooser < + is_reference::value >::result_ < T > { }; -- 2.7.4