re PR c++/85208 (ICE with #pragma weak and structured binding)
authorJakub Jelinek <jakub@redhat.com>
Thu, 5 Apr 2018 21:29:51 +0000 (23:29 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 5 Apr 2018 21:29:51 +0000 (23:29 +0200)
PR c++/85208
* decl.c (start_decl): For DECL_DECOMPOSITION_P decls, don't call
maybe_apply_pragma_weak here...
(cp_maybe_mangle_decomp): ... but call it here instead.

* g++.dg/cpp1z/decomp41.C: New test.

From-SVN: r259155

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1z/decomp41.C [new file with mode: 0644]

index 2c5e1e25f40367941f6e4b7bd21d706795a594e3..59c11be6fc4768de46b39fce2d5b513f6adb4541 100644 (file)
@@ -1,3 +1,10 @@
+2018-04-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/85208
+       * decl.c (start_decl): For DECL_DECOMPOSITION_P decls, don't call
+       maybe_apply_pragma_weak here...
+       (cp_maybe_mangle_decomp): ... but call it here instead.
+
 2018-04-05  Jason Merrill  <jason@redhat.com>
 
        PR c++/85136 - ICE with designated init in template.
index 86251f51eb4bafb263e314c6a5fc05fe77ca2381..d55c2b70c0e3f71ebae237462ffd51c7162e306d 100644 (file)
@@ -5090,7 +5090,7 @@ start_decl (const cp_declarator *declarator,
     }
 
   /* If #pragma weak was used, mark the decl weak now.  */
-  if (!processing_template_decl)
+  if (!processing_template_decl && !DECL_DECOMPOSITION_P (decl))
     maybe_apply_pragma_weak (decl);
 
   if (TREE_CODE (decl) == FUNCTION_DECL
@@ -7510,6 +7510,7 @@ cp_maybe_mangle_decomp (tree decl, tree first, unsigned int count)
       for (unsigned int i = 0; i < count; i++, d = DECL_CHAIN (d))
        v[count - i - 1] = d;
       SET_DECL_ASSEMBLER_NAME (decl, mangle_decomp (decl, v));
+      maybe_apply_pragma_weak (decl);
     }
 }
 
index d6a9738a1777fe984ec665c12a336da737c65aa9..0a32f879906607afc625924fe19ecbc1262c08c9 100644 (file)
@@ -1,5 +1,8 @@
 2018-04-05  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/85208
+       * g++.dg/cpp1z/decomp41.C: New test.
+
        PR middle-end/85195
        * gcc.dg/pr85195.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp41.C b/gcc/testsuite/g++.dg/cpp1z/decomp41.C
new file mode 100644 (file)
index 0000000..3c8e150
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/85208
+// { dg-do compile { target c++11 } }
+// { dg-require-weak "" }
+// { dg-options "" }
+
+#pragma weak _ZDC1d1e1fE
+struct A { int i, j, k; };
+auto [a, b, c] = A (); // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+auto [d, e, f] = A (); // { dg-warning "structured bindings only available with" "" { target c++14_down } }