In this testcase we hit an error and then a warning while trying to
print the name of the function, because the warning wasn't properly
respecting complain.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 559a9aac40a5eb421948cd939637e4fe1c919843
Author: Jason Merrill <ja...@redhat.com>
Date:   Fri Jul 22 15:11:55 2016 -0400

        PR c++/71350 - error recursion with initializer-list
    
        * decl.c (reshape_init_r): Check complain for missing braces warning.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index e5e1121..08fa95d 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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
index 0000000..76ff1e2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/decltype66.C
@@ -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>;

Reply via email to