OSDN Git Service

2012-01-30 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / overflow-warn-4.c
index acf2c87..464533a 100644 (file)
@@ -12,26 +12,27 @@ enum e {
   /* Overflow in an unevaluated part of an expression is OK (example
      in the standard).  */
   E2 = 2 || 1 / 0,
-  E3 = 1 / 0, /* { dg-warning "warning: division by zero" } */
-  /* { dg-error "error: enumerator value for 'E3' is not an integer constant" "enum error" { target *-*-* } 15 } */
+  E3 = 1 / 0, /* { dg-warning "division by zero" } */
+  /* { dg-error "enumerator value for 'E3' is not an integer constant" "enum error" { target *-*-* } 15 } */
   /* But as in DR#031, the 1/0 in an evaluated subexpression means the
      whole expression violates the constraints.  */
-  E4 = 0 * (1 / 0), /* { dg-warning "warning: division by zero" } */
-  /* { dg-error "error: enumerator value for 'E4' is not an integer constant" "enum error" { xfail *-*-* } 19 } */
-  E5 = INT_MAX + 1, /* { dg-warning "warning: integer overflow in expression" } */
-  /* { dg-error "error: overflow in constant expression" "constant" { target *-*-* } 21 } */
+  E4 = 0 * (1 / 0), /* { dg-warning "division by zero" } */
+  /* { dg-error "enumerator value for 'E4' is not an integer constant" "enum error" { target *-*-* } 19 } */
+  E5 = INT_MAX + 1, /* { dg-warning "integer overflow in expression" } */
+  /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 21 } */
   /* Again, overflow in evaluated subexpression.  */
-  E6 = 0 * (INT_MAX + 1), /* { dg-warning "warning: integer overflow in expression" } */
-  /* { dg-error "error: overflow in constant expression" "constant" { target *-*-* } 24 } */
+  E6 = 0 * (INT_MAX + 1), /* { dg-warning "integer overflow in expression" } */
+  /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 24 } */
   /* A cast does not constitute overflow in conversion.  */
   E7 = (char) INT_MAX
 };
 
 struct s {
   int a;
-  int : 0 * (1 / 0); /* { dg-warning "warning: division by zero" } */
-  int : 0 * (INT_MAX + 1); /* { dg-warning "warning: integer overflow in expression" } */
-  /* { dg-error "error: overflow in constant expression" "constant" { target *-*-* } 33 } */
+  int : 0 * (1 / 0); /* { dg-warning "division by zero" } */
+  /* { dg-error "not an integer constant" "integer constant" { target *-*-* } 32 } */
+  int : 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */
+  /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 34 } */
 };
 
 void
@@ -39,22 +40,23 @@ f (void)
 {
   /* This expression is not required to be a constant expression, so
      it should just involve undefined behavior at runtime.  */
-  int c = INT_MAX + 1; /* { dg-warning "warning: integer overflow in expression" } */
-  /* { dg-bogus "error: overflow in constant expression" "constant" { xfail *-*-* } 42 } */
+  int c = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */
+
 }
 
 /* But this expression does need to be constant.  */
-static int sc = INT_MAX + 1; /* { dg-warning "warning: integer overflow in expression" } */
-/* { dg-error "error: overflow in constant expression" "constant" { target *-*-* } 47 } */
+static int sc = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */
+/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 48 } */
 
 /* The first two of these involve overflow, so are not null pointer
    constants.  The third has the overflow in an unevaluated
    subexpression, so is a null pointer constant.  */
-void *p = 0 * (INT_MAX + 1); /* { dg-warning "warning: integer overflow in expression" } */
-/* { dg-error "error: overflow in constant expression" "constant" { target *-*-* } 53 } */
-/* { dg-error "error: initialization makes pointer from integer without a cast" "null" { target *-*-* } 53 } */
-void *q = 0 * (1 / 0); /* { dg-warning "warning: division by zero" } */
-/* { dg-error "error: initialization makes pointer from integer without a cast" "null" { xfail *-*-* } 56 } */
+void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */
+/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 54 } */
+/* { dg-error "initialization makes pointer from integer without a cast" "null" { target *-*-* } 54 } */
+void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */
+/* { dg-error "initializer element is not computable at load time" "constant" { target *-*-* } 57 } */
+/* { dg-error "initialization makes pointer from integer without a cast" "null" { target *-*-* } 57 } */
 void *r = (1 ? 0 : INT_MAX+1);
 
 void
@@ -62,10 +64,11 @@ g (int i)
 {
   switch (i)
     {
-    case 0 * (1/0): /* { dg-warning "warning: division by zero" } */
+    case 0 * (1/0): /* { dg-warning "division by zero" } */
+      /* { dg-error "case label does not reduce to an integer constant" "constant" { target *-*-* } 67 } */
       ;
-    case 1 + 0 * (INT_MAX + 1): /* { dg-warning "warning: integer overflow in expression" } */
-      /* { dg-error "error: overflow in constant expression" "constant" { target *-*-* } 67 } */
+    case 1 + 0 * (INT_MAX + 1): /* { dg-warning "integer overflow in expression" } */
+      /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 70 } */
       ;
     }
 }
@@ -73,13 +76,13 @@ g (int i)
 int
 h (void)
 {
-  return INT_MAX + 1; /* { dg-warning "warning: integer overflow in expression" } */
+  return INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */
 }
 
 int
 h1 (void)
 {
-  return INT_MAX + 1 - INT_MAX; /* { dg-warning "warning: integer overflow in expression" } */
+  return INT_MAX + 1 - INT_MAX; /* { dg-warning "integer overflow in expression" } */
 }
 
 void fuc (unsigned char);
@@ -88,15 +91,15 @@ void fsc (signed char);
 void
 h2 (void)
 {
-  fsc (SCHAR_MAX + 1); /* { dg-warning "warning: overflow in implicit constant conversion" } */
-  fsc (SCHAR_MIN - 1); /* { dg-warning "warning: overflow in implicit constant conversion" } */
-  fsc (UCHAR_MAX); /* { dg-warning "warning: overflow in implicit constant conversion" } */
-  fsc (UCHAR_MAX + 1); /* { dg-warning "warning: overflow in implicit constant conversion" } */
+  fsc (SCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */
+  fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in implicit constant conversion" } */
+  fsc (UCHAR_MAX); /* { dg-warning "overflow in implicit constant conversion" } */
+  fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */
   fuc (-1);
-  fuc (UCHAR_MAX + 1); /* { dg-warning "warning: large integer implicitly truncated to unsigned type" } */
+  fuc (UCHAR_MAX + 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
   fuc (SCHAR_MIN);
-  fuc (SCHAR_MIN - 1); /* { dg-warning "warning: large integer implicitly truncated to unsigned type" } */
-  fuc (-UCHAR_MAX); /* { dg-warning "warning: large integer implicitly truncated to unsigned type" } */
+  fuc (SCHAR_MIN - 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
+  fuc (-UCHAR_MAX); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
 }
 
 void fui (unsigned int);