aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2005-07-28 18:06:47 +0000
committerMike Stump <mrs@gcc.gnu.org>2005-07-28 18:06:47 +0000
commit8d039470f6ddd258edc714519a25a39b270c09d3 (patch)
treea9c4159958e86a9067086f3ae21d9b874a0042be /gcc
parentfacc20ee9b776ac4829a49a0bc1be1267b8358f4 (diff)
downloadgcc-8d039470f6ddd258edc714519a25a39b270c09d3.zip
gcc-8d039470f6ddd258edc714519a25a39b270c09d3.tar.gz
gcc-8d039470f6ddd258edc714519a25a39b270c09d3.tar.bz2
pt.c (check_explicit_specialization): Add visibility logic.
* pt.c (check_explicit_specialization): Add visibility logic. (lookup_template_class): Likewise. (instantiate_class_template): Likewise. * g++.old-deja/g++.mike/visibility-1.C: New test. Radar 4182971. From-SVN: r102499
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c18
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.mike/visibility-1.C22
4 files changed, 50 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index da39c84..31e3d97 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2005-07-28 Mike Stump <mrs@apple.com>
+
+ * pt.c (check_explicit_specialization): Add visibility logic.
+ (lookup_template_class): Likewise.
+ (instantiate_class_template): Likewise.
+
2005-07-27 Devang Patel <dpatel@apple.com>
* name-lookup.c (pushtag): Do no set DECL_IGNORED_P bit.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 2ab89b2..3403e8b 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -2087,6 +2087,14 @@ check_explicit_specialization (tree declarator,
TREE_PRIVATE (decl) = TREE_PRIVATE (gen_tmpl);
TREE_PROTECTED (decl) = TREE_PROTECTED (gen_tmpl);
+ /* The specialization has the same visibility as the
+ template it specializes. */
+ if (DECL_VISIBILITY_SPECIFIED (gen_tmpl))
+ {
+ DECL_VISIBILITY_SPECIFIED (decl) = 1;
+ DECL_VISIBILITY (decl) = DECL_VISIBILITY (gen_tmpl);
+ }
+
if (is_friend && !have_def)
/* This is not really a declaration of a specialization.
It's just the name of an instantiation. But, it's not
@@ -4606,6 +4614,11 @@ lookup_template_class (tree d1,
= TREE_PROTECTED (TYPE_STUB_DECL (template_type));
DECL_IN_SYSTEM_HEADER (type_decl)
= DECL_IN_SYSTEM_HEADER (template);
+ if (CLASSTYPE_VISIBILITY_SPECIFIED (template_type))
+ {
+ DECL_VISIBILITY_SPECIFIED (type_decl) = 1;
+ DECL_VISIBILITY (type_decl) = CLASSTYPE_VISIBILITY (template_type);
+ }
/* Set up the template information. We have to figure out which
template is the immediate parent if this is a full
@@ -5525,6 +5538,11 @@ instantiate_class_template (tree type)
TYPE_FOR_JAVA (type) = TYPE_FOR_JAVA (pattern); /* For libjava's JArray<T> */
if (ANON_AGGR_TYPE_P (pattern))
SET_ANON_AGGR_TYPE_P (type);
+ if (CLASSTYPE_VISIBILITY_SPECIFIED (pattern))
+ {
+ CLASSTYPE_VISIBILITY_SPECIFIED (type) = 1;
+ CLASSTYPE_VISIBILITY (type) = CLASSTYPE_VISIBILITY (pattern);
+ }
pbinfo = TYPE_BINFO (pattern);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b52b92e..64fa8fe 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2005-07-28 Mike Stump <mrs@apple.com>
+
+ * g++.old-deja/g++.mike/visibility-1.C: New test.
+
2005-07-28 Richard Sandiford <richard@codesourcery.com>
PR c/20187
diff --git a/gcc/testsuite/g++.old-deja/g++.mike/visibility-1.C b/gcc/testsuite/g++.old-deja/g++.mike/visibility-1.C
new file mode 100644
index 0000000..40e7427
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.mike/visibility-1.C
@@ -0,0 +1,22 @@
+/* Test visibility attribute on template member function
+ instantiations. */
+
+/* { dg-do compile } */
+/* { dg-options "-fvisibility=hidden" } */
+/* { dg-require-visibility "" } */
+/* { dg-final { scan-not-hidden "_ZN7myClassIiE3maxEii" } } */
+
+#define EXPORT __attribute__((visibility("default")))
+
+template <class T>
+class EXPORT myClass {
+public:
+ T max (T t1, T t2);
+};
+
+template <class T>
+T myClass<T>::max (T t1, T t2) {
+ return (t1 > t2 ? t1 : t2);
+}
+
+template class myClass<int>;