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]

[rfa] add gcc.dg/Wswitch.c; Was: [rfc] Wswitch test case (which fails)


The attached (fleshed out a bit from the original)

passes with egcs-1.1.2 but fails with a current GCC.

Per the below, this testcase identifies regressions in GCC.  I've also 
noted two PR's mentioning this problem (One C, one C++) although neither 
have a "high" priority.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=4475
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=3780

Ok?

Andrew

> On Sat, 2 Feb 2002, Andrew Cagney wrote:
> 
> 
>> I'm wondering what GCC's policy is on committing tests that fail, but 
>> illustrate regressions, is.
> 
> 
> They can go in the testsuite, and should not be marked XFAIL (whereas
> tests for non-regression bugs should be marked XFAIL unless there is a
> patch available or an immediate intention to fix them).  There should also
> be a priority "high" PR concerning the problem, and a comment in the
> testcase should reference the PR if pre-existing, or the PR mention the
> testcase if a new PR is submitted to accompany the addition of the
> testcase.


2002-02-02  Andrew Cagney  <ac131313@redhat.com>

	* gcc.dg/Wswitch.c: New test.
	PR gcc/4475. PR gcc/3780.

Index: gcc.dg/Wswitch.c
===================================================================
RCS file: Wswitch.c
diff -N Wswitch.c
*** /dev/null	Tue May  5 13:32:27 1998
--- Wswitch.c	Sat Feb  2 20:15:04 2002
***************
*** 0 ****
--- 1,63 ----
+ /* PR gcc/4475, PR gcc/3780 */
+ /* { dg-do compile } */
+ /* { dg-options "-Wswitch" } */
+ 
+ enum e { e1, e2 };
+ 
+ int
+ foo (int i, int j, enum e ei, enum e ej, enum e ek, enum e el,
+      enum e em, enum e en, enum e eo, enum e ep)
+ {
+   switch (i)
+     {
+     case 1: return 1;
+     case 2: return 2;
+     }
+   switch (j)
+     {
+     case 3: return 4;
+     case 4: return 3;
+     default: return 7;
+     }
+   switch (ei)
+     { /* { dg-warning "enumeration value `e1' not handled in switch" "enum e1" { target *-*-* } 24 } */
+     } /* { dg-warning "enumeration value `e2' not handled in switch" "enum e2" } */
+   switch (ej)
+     {
+     default: break;
+     }
+   switch (ek)
+     {
+     case e1: return 1;
+     } /* { dg-warning "enumeration value `e2' not handled in switch" "enum e1" } */
+   switch (el)
+     {
+     case e1: return 1;
+     default: break;
+     }
+   switch (em)
+     {
+     case e1: return 1;
+     case e2: return 2;
+     }
+   switch (en)
+     {
+     case e1: return 1;
+     case e2: return 2;
+     default: break;
+     }
+   switch (eo)
+     {
+     case e1: return 1;
+     case e2: return 2;
+     case 3: return 3;
+     } /* { dg-warning "case value `3' not in enumerated type `e'" "excess 3" } */
+   switch (ep)
+     {
+     case e1: return 1;
+     case e2: return 2;
+     case 3: return 3;
+     default: break;
+     } /* Since there is a default, no warning about ``case 3'' } */
+   return 0;
+ }

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