re PR c++/19755 (-Wmissing-braces doesn't warn anymore)
authorMark Mitchell <mark@codesourcery.com>
Fri, 11 Feb 2005 17:15:50 +0000 (17:15 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 11 Feb 2005 17:15:50 +0000 (17:15 +0000)
PR c++/19755
* decl.c (reshape_init): Issue warnings about missing braces.

PR c++/19755
* g++.dg/warn/Wbraces1.C: New test.

From-SVN: r94882

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

index 490a54eadfebaaf3abc55fd29224f82f94f35752..971bacafc7e6f55f601cf97cdbd4cca3a1911898 100644 (file)
@@ -1,3 +1,8 @@
+2005-02-10  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/19755
+       * decl.c (reshape_init): Issue warnings about missing braces.
+
 2005-02-11  Kazu Hirata  <kazu@cs.umass.edu>
 
        * cp-tree.def, except.c, ptree.c: Update copyright.
index 05918f553f97fb880afe5c255ef50799a0d27f21..a93cdf8f4c1cac3d100296286dbe197243a55a9b 100644 (file)
@@ -4352,10 +4352,15 @@ reshape_init (tree type, tree *initp)
        new_init = build_tree_list (TREE_PURPOSE (old_init), new_init);
     }
 
-  /* If this was a brace-enclosed initializer and all of the
-     initializers were not used up, there is a problem.  */
-  if (brace_enclosed_p && *initp)
-    error ("too many initializers for %qT", type);
+  /* If there are more initializers than necessary, issue a
+     diagnostic.  */  
+  if (*initp)
+    {
+      if (brace_enclosed_p)
+       error ("too many initializers for %qT", type);
+      else if (warn_missing_braces)
+       warning ("missing braces around initializer");
+    }
 
   return new_init;
 }
index 6e7dc97e434194bead0651281642d4dce51aa61e..1064f44346ecb835cf09653729f953d1a00dfc7e 100644 (file)
@@ -1,3 +1,8 @@
+2005-02-11  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/19755
+       * g++.dg/warn/Wbraces1.C: New test.
+
 2005-02-10  Richard Guenther  <rguenth@gcc.gnu.org>
 
        * gcc.dg/builtins-52.c: New testcase.
diff --git a/gcc/testsuite/g++.dg/warn/Wbraces1.C b/gcc/testsuite/g++.dg/warn/Wbraces1.C
new file mode 100644 (file)
index 0000000..0efce7b
--- /dev/null
@@ -0,0 +1,3 @@
+// PR c++/19755
+// { dg-options "-Wmissing-braces" }
+int a[2][2] = { 0, 1 , 2, 3 }; // { dg-warning "" }