annotate gcc/testsuite/gcc.dg/tree-ssa/pr78622.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* PR middle-end/78622 - [7 Regression] -Wformat-overflow/-fprintf-return-value
kono
parents:
diff changeset
2 incorrect with overflow/wrapping
kono
parents:
diff changeset
3 { dg-do compile }
kono
parents:
diff changeset
4 { dg-options "-Wformat-overflow=2" }
kono
parents:
diff changeset
5 The h and hh length modifiers are a C99 feature (see PR 78959).
kono
parents:
diff changeset
6 { dg-require-effective-target c99_runtime } */
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 char buf[1];
kono
parents:
diff changeset
9
kono
parents:
diff changeset
10 int test_uchar_hhd (unsigned char x)
kono
parents:
diff changeset
11 {
kono
parents:
diff changeset
12 if (x < 64 || x > 2U * __SCHAR_MAX__ - 10)
kono
parents:
diff changeset
13 return -1;
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 return __builtin_sprintf (buf, "%hhd", x + 1); /* { dg-warning "directive writing between 1 and 4 bytes into a region of size 1" "int32plus" { target { int32plus } } } */
kono
parents:
diff changeset
16 }
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 int test_uint_hhd (unsigned x)
kono
parents:
diff changeset
19 {
kono
parents:
diff changeset
20 if (x < 64 || x > 2U * __INT_MAX__ - 10)
kono
parents:
diff changeset
21 return -1;
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 return __builtin_sprintf (buf, "%hhd", x + 1); /* { dg-warning "directive writing between 1 and 4 bytes into a region of size 1" "int32plus" { target { int32plus } } } */
kono
parents:
diff changeset
24 }
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 int test_schar_hhu (signed char x)
kono
parents:
diff changeset
27 {
kono
parents:
diff changeset
28 if (x < -9 || x > 9)
kono
parents:
diff changeset
29 return -1;
kono
parents:
diff changeset
30
kono
parents:
diff changeset
31 return __builtin_sprintf (buf, "%hhu", x + 1); /* { dg-warning "directive writing between 1 and 3 bytes into a region of size 1" "int32plus" { target { int32plus } } } */
kono
parents:
diff changeset
32 }
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 int test_ushort_hd (unsigned short x)
kono
parents:
diff changeset
35 {
kono
parents:
diff changeset
36 if (x < 64 || x > 2U * __SHRT_MAX__ - 10)
kono
parents:
diff changeset
37 return -1;
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 return __builtin_sprintf (buf, "%hd", x + 1); /* { dg-warning "directive writing between 1 and 6 bytes into a region of size 1" "int32plus" { target { int32plus } } } */
kono
parents:
diff changeset
40 }
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 int test_uint_d (unsigned x)
kono
parents:
diff changeset
43 {
kono
parents:
diff changeset
44 if (x < 64 || x > 2U * __INT_MAX__ - 10)
kono
parents:
diff changeset
45 return -1;
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 return __builtin_sprintf (buf, "%d", x + 1); /* { dg-warning "directive writing between 1 and 11 bytes into a region of size 1" "int32plus" { target { int32plus } } } */
kono
parents:
diff changeset
48 }
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 int test_ulong_ld (unsigned long x)
kono
parents:
diff changeset
51 {
kono
parents:
diff changeset
52 if (x < 64 || x > 2LU * __LONG_MAX__ - 10)
kono
parents:
diff changeset
53 return -1;
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 return __builtin_sprintf (buf, "%ld", x + 1); /* { dg-warning "directive writing between 1 and 11 bytes into a region of size 1" "ilp32" { target { ilp32 } } } */
kono
parents:
diff changeset
56 /* { dg-warning "directive writing between 1 and 20 bytes into a region of size 1" "lp64" { target { lp64 } } .-1 } */
kono
parents:
diff changeset
57 }
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 int test_ullong_lld (unsigned long long x)
kono
parents:
diff changeset
60 {
kono
parents:
diff changeset
61 if (x < 64 || x > 2LLU * __LONG_LONG_MAX__ - 10)
kono
parents:
diff changeset
62 return -1;
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 return __builtin_sprintf (buf, "%lld", x + 1); /* { dg-warning "directive writing between 1 and 20 bytes into a region of size 1" "int32plus" { target { int32plus } } } */
kono
parents:
diff changeset
65 }