This is the mail archive of the gcc@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]

[rfc] Wswitch test case (which fails)


The -Wswitch flag is currently broken in GCC.  The attached testcase is 
intended to check that functionality.  Consequently, it fails.  (I'm 
currently wiggling things to see it works with an old GCC).

I'm wondering what GCC's policy is on committing tests that fail, but 
illustrate regressions, is.

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

	* gcc.dg/Wswitch.c: New test.

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 16:53:11 2002
***************
*** 0 ****
--- 1,49 ----
+ /* { 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)
+ {
+   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" "enumeration value `e2' not handled in switch" } */
+   switch (ej)
+     {
+     default: break;
+     }
+   switch (ek)
+     {
+     case e1: return 1;
+     }  /* { dg-warning "enumeration value `e2' not handled in switch" } */
+   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;
+     }
+   return 0;
+ }

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