This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH: PR 19755


This patch fixes PR c++/19755; during a rewrite of aggregate
initialization we lost support for -Wmissing-braces.

Tested on x86_64-unknown-linux-gnu, applied on the mainline and on the
3.4 branch.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2005-02-10  Mark Mitchell  <mark@codesourcery.com>

	PR c++/19755
	* decl.c (reshape_init): Issue warnings about missing braces.

2005-02-11  Mark Mitchell  <mark@codesourcery.com>

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

Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1361
diff -c -5 -p -r1.1361 decl.c
*** cp/decl.c	10 Feb 2005 00:34:28 -0000	1.1361
--- cp/decl.c	11 Feb 2005 16:35:12 -0000
*************** reshape_init (tree type, tree *initp)
*** 4350,4363 ****
  
        if (TREE_CODE (old_init) == TREE_LIST)
  	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);
  
    return new_init;
  }
  
  /* Verify INIT (the initializer for DECL), and record the
--- 4350,4368 ----
  
        if (TREE_CODE (old_init) == TREE_LIST)
  	new_init = build_tree_list (TREE_PURPOSE (old_init), new_init);
      }
  
!   /* 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;
  }
  
  /* Verify INIT (the initializer for DECL), and record the
Index: testsuite/g++.dg/warn/Wbraces1.C
===================================================================
RCS file: testsuite/g++.dg/warn/Wbraces1.C
diff -N testsuite/g++.dg/warn/Wbraces1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/warn/Wbraces1.C	11 Feb 2005 16:35:44 -0000
***************
*** 0 ****
--- 1,3 ----
+ // PR c++/19755
+ // { dg-options "-Wmissing-braces" }
+ int a[2][2] = { 0, 1 , 2, 3 }; // { dg-warning "" }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]