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]: Fix switch2.C


I've installed this patch to fix the failure of a new testcase I added. I suspect a separate patch fixed the overflow warning elsewhere, making clearing the overflow flags unneccessary.

tested on i686-pc-linux-gnu.

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2005-10-17  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/22551
	* c-common.c (c_add_case_label): Revert my 2005-10-14 clearing of
	overflow flags.

2005-10-17  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/22551
	* g++.dg/other/switch2.C: Remove expected warnings.

Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.656
diff -c -3 -p -r1.656 c-common.c
*** c-common.c	14 Oct 2005 12:55:32 -0000	1.656
--- c-common.c	17 Oct 2005 13:32:46 -0000
*************** c_add_case_label (splay_tree cases, tree
*** 3590,3599 ****
        low_value = convert_and_check (type, low_value);
        if (low_value == error_mark_node)
  	goto error_out;
-       /* Do not propagate any overflow information past this point.
- 	 It is safe to just clear the flags, as any constants with
- 	 them set will not be shared.  */
-       TREE_CONSTANT_OVERFLOW (low_value) = TREE_OVERFLOW (low_value) = 0;
      }
    if (high_value)
      {
--- 3590,3595 ----
*************** c_add_case_label (splay_tree cases, tree
*** 3601,3607 ****
        high_value = convert_and_check (type, high_value);
        if (high_value == error_mark_node)
  	goto error_out;
-       TREE_CONSTANT_OVERFLOW (high_value) = TREE_OVERFLOW (high_value) = 0;
      }
  
    if (low_value && high_value)
--- 3597,3602 ----
Index: testsuite/g++.dg/other/switch2.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/other/switch2.C,v
retrieving revision 1.1
diff -c -3 -p -r1.1 switch2.C
*** testsuite/g++.dg/other/switch2.C	14 Oct 2005 12:55:33 -0000	1.1
--- testsuite/g++.dg/other/switch2.C	17 Oct 2005 13:50:24 -0000
***************
*** 4,10 ****
  // PR 22551:ICE
  // Origin:  Johnny Casey <emailwastefilter-bugzillagccorg@yahoo.com>
  
! const int B = 0x80000000;
  
  #define b(x) (B + x)
  
--- 4,10 ----
  // PR 22551:ICE
  // Origin:  Johnny Casey <emailwastefilter-bugzillagccorg@yahoo.com>
  
! const int B = ~(~0u >> 1);
  
  #define b(x) (B + x)
  
*************** int Foo (int error)
*** 13,22 ****
  {
    switch (error)
    {
!   case b (1): return 0; // { dg-error "overflow" "" }
!   case b (2): return 0; // { dg-error "overflow" "" }
!   case b (3): return 0; // { dg-error "overflow" "" }
!   case b (4): return 0; // { dg-error "overflow" "" }
!   case b (5): return 0; // { dg-error "overflow" "" }
!  }
  }
--- 13,23 ----
  {
    switch (error)
    {
!   case b (1): return 0;
!   case b (2): return 0;
!   case b (3): return 0;
!   case b (4): return 0;
!   case b (5): return 0;
!   }
!   return 0;
  }

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