]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/56614 (error: default argument 'std::vector<E>(std::initializer_list<E...
authorJason Merrill <jason@redhat.com>
Thu, 14 Mar 2013 17:34:55 +0000 (13:34 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 14 Mar 2013 17:34:55 +0000 (13:34 -0400)
PR c++/56614
* decl.c (local_variable_p_walkfn): Check DECL_ARTIFICIAL again.

From-SVN: r196662

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/cpp0x/initlist-defarg1.C [new file with mode: 0644]

index af8859f4bcf4b0f89358a7153747a62a1fdb8dcd..acecb5add443cf0473b8ecbeeec56c892224757a 100644 (file)
@@ -1,3 +1,8 @@
+2013-03-14  Jason Merrill  <jason@redhat.com>
+
+       PR c++/56614
+       * decl.c (local_variable_p_walkfn): Check DECL_ARTIFICIAL again.
+
 2013-03-14  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/56403
index dd6f7fbf465488be9ce978ce85c0d2efd23bdb46..db0c233b8e173441649b561bf1f1dfc5612fa41c 100644 (file)
@@ -10536,9 +10536,8 @@ static tree
 local_variable_p_walkfn (tree *tp, int *walk_subtrees,
                         void *data ATTRIBUTE_UNUSED)
 {
-  /* Check DECL_NAME to avoid including temporaries.  We don't check
-     DECL_ARTIFICIAL because we do want to complain about 'this'.  */
-  if (local_variable_p (*tp) && DECL_NAME (*tp))
+  if (local_variable_p (*tp)
+      && (!DECL_ARTIFICIAL (*tp) || DECL_NAME (*tp) == this_identifier))
     return *tp;
   else if (TYPE_P (*tp))
     *walk_subtrees = 0;
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-defarg1.C b/gcc/testsuite/g++.dg/cpp0x/initlist-defarg1.C
new file mode 100644 (file)
index 0000000..45eb2d5
--- /dev/null
@@ -0,0 +1,36 @@
+// PR c++/56614
+// { dg-require-effective-target c++11 }
+
+#include <initializer_list>
+
+namespace std
+{
+    template<typename T>
+        struct allocator
+        { };
+
+    template<typename T, typename Alloc = std::allocator<T> >
+        struct vector
+        {
+            vector(std::initializer_list<T>, const Alloc& = Alloc()) { }
+        };
+}
+
+void func() { }
+
+enum E { ee };
+
+struct C
+{
+    template<typename T>
+        C(T, std::vector<E> = std::vector<E>({ ee }))
+        { }
+};
+
+struct G
+{
+    void gen()
+    {
+        C c(&func);
+    }
+};