summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2015-03-04 18:13:44 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2015-03-04 18:13:44 +0000
commit6d0453641b10ed9ac506194166aa88c0beaa533a (patch)
tree48690f46a2b20e412ca1c61af5d55eacd772064c
parentb0ec7b6b126f30ed03e73a47eb41fbd551b1c1b6 (diff)
downloadgcc-6d0453641b10ed9ac506194166aa88c0beaa533a.tar.gz
PR c++/65209
PR c++/65309 * decl2.c (constrain_visibility_for_template): Handle reference arguments. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@221192 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/decl2.c7
-rw-r--r--gcc/testsuite/g++.dg/abi/anon4.C41
3 files changed, 53 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 44f5c0d746d..bdea7d5737e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2015-03-04 Jason Merrill <jason@redhat.com>
+
+ PR c++/65209
+ PR c++/65309
+ * decl2.c (constrain_visibility_for_template): Handle reference
+ arguments.
+
2015-02-25 Jason Merrill <jason@redhat.com>
PR c++/62255
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 78c1124e277..808c94f2715 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -2122,9 +2122,12 @@ constrain_visibility_for_template (tree decl, tree targs)
tree arg = TREE_VEC_ELT (args, i-1);
if (TYPE_P (arg))
vis = type_visibility (arg);
- else if (TREE_TYPE (arg) && POINTER_TYPE_P (TREE_TYPE (arg)))
+ else
{
- STRIP_NOPS (arg);
+ if (REFERENCE_REF_P (arg))
+ arg = TREE_OPERAND (arg, 0);
+ if (TREE_TYPE (arg))
+ STRIP_NOPS (arg);
if (TREE_CODE (arg) == ADDR_EXPR)
arg = TREE_OPERAND (arg, 0);
if (VAR_OR_FUNCTION_DECL_P (arg))
diff --git a/gcc/testsuite/g++.dg/abi/anon4.C b/gcc/testsuite/g++.dg/abi/anon4.C
new file mode 100644
index 00000000000..088ba994019
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/anon4.C
@@ -0,0 +1,41 @@
+// PR c++/65209
+// { dg-final { scan-assembler-not "comdat" } }
+
+// Everything involving the anonymous namespace bits should be private, not
+// COMDAT.
+
+struct Bar
+{
+ static Bar *self();
+ char pad[24];
+};
+
+template <Bar *(&holderFunction)()>
+struct BarGlobalStatic
+{
+ Bar *operator()() { return holderFunction(); }
+};
+
+namespace {
+ namespace Q_QGS_s_self {
+ inline Bar *innerFunction() {
+ static struct Holder {
+ Bar value;
+ ~Holder() {}
+ } holder;
+ return &holder.value;
+ }
+ }
+}
+static BarGlobalStatic<Q_QGS_s_self::innerFunction> s_self;
+
+Bar *Bar::self()
+{
+ return s_self();
+}
+
+int main(int argc, char *argv[])
+{
+ Bar* bar = Bar::self();
+ return 0;
+}