PR c++/71350 - error recursion with initializer-list
authorJason Merrill <jason@redhat.com>
Sun, 24 Jul 2016 02:35:37 +0000 (22:35 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 24 Jul 2016 02:35:37 +0000 (22:35 -0400)
* decl.c (reshape_init_r): Check complain for missing braces warning.

From-SVN: r238684

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

index 34ebcb818bf5c6c1c8043332df41ab7c21963d39..e1e4506690e1179c70b161998a5d623cc1d101ec 100644 (file)
@@ -1,3 +1,8 @@
+2016-07-23  Jason Merrill  <jason@redhat.com>
+
+       PR c++/71350
+       * decl.c (reshape_init_r): Check complain for missing braces warning.
+
 2016-07-22  Jason Merrill  <jason@redhat.com>
 
        PR c++/71576
index e5e1121b1d425f9ea0107bfedbb082aacb1fcf29..08fa95dc0e6d13ee59b0847fcc8830340425d589 100644 (file)
@@ -5894,8 +5894,10 @@ reshape_init_r (tree type, reshape_iter *d, bool first_initializer_p,
            }
        }
 
-      warning (OPT_Wmissing_braces, "missing braces around initializer for %qT",
-              type);
+      if (complain & tf_warning)
+       warning (OPT_Wmissing_braces,
+                "missing braces around initializer for %qT",
+                type);
     }
 
   /* Dispatch to specialized routines.  */
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype66.C b/gcc/testsuite/g++.dg/cpp0x/decltype66.C
new file mode 100644 (file)
index 0000000..76ff1e2
--- /dev/null
@@ -0,0 +1,19 @@
+// PR c++/71350
+// { dg-do compile { target c++11 } }
+
+template<typename T, unsigned int N>
+struct Array
+{
+    T data[N];
+};
+
+template<typename T>
+struct Foo
+{
+    int operator[](const Array<int, 2>& i) const { return 0; }
+    auto bar() -> decltype((*this)[{1,2}] * 0) {
+      return *this;            // { dg-error "cannot convert" }
+    }
+};
+
+template struct Foo<int>;