1 /* PR c/94040 - ICE on a call to an invalid redeclaration of strftime
2 { dg-do compile }
3 { dg-options "-Wall -Wextra" } */
4
5 typedef __SIZE_TYPE__ size_t;
6
7 struct tm;
8
9 size_t strftime (const char *, size_t, char *, struct tm *);
10 // { dg-warning "-Wbuiltin-declaration-mismatch" "arg 1" { target *-*-* } .-1 }
11
12 // Verify that missing/extra qualifiers are diagnosed with -Wextra.
13
14 int strcmp (char*, const char*);
15 // { dg-warning "-Wbuiltin-declaration-mismatch" "arg 1" { target *-*-* } .-1 }
16
17 int strncmp (const char*, volatile char*, size_t);
18 // { dg-warning "-Wbuiltin-declaration-mismatch" "arg 2" { target *-*-* } .-1 }
19
20 size_t strlen (char*);
21 // { dg-warning "-Wbuiltin-declaration-mismatch" "arg 1" { target *-*-* } .-1 }
22
23
24 // Verify that calls to built-ins declared with missing/extra qualifiers
25 // are still treated as those to built-ins by the front-end.
26
27 int test_builtin_calls_fe (size_t n)
28 {
29 int r = 0;
30 r += strcmp ((char*)0, ""); // { dg-warning "\\\[-Wnonnull]" }
31 r += strcmp ("", (char*)0); // { dg-warning "\\\[-Wnonnull]" }
32
33 r += strncmp ((char*)0, "", n); // { dg-warning "\\\[-Wnonnull]" }
34 r += strncmp ("", (char*)0, n); // { dg-warning "\\\[-Wnonnull]" }
35
36 r += strlen ((char*)0); // { dg-warning "\\\[-Wnonnull]" }
37 return r;
38 }
39
40
41 // Ditto but by the middle-end.
42
43 #pragma GCC optimize "2"
44
45 int test_builtin_calls_me (void)
46 {
47 char *null1 = 0;
48 char *null2 = null1;
49 char *null3 = null2;
50
51 int r = 0;
52 r += strcmp (null1, "123"); // { dg-warning "\\\[-Wnonnull]" }
53 r += strncmp ("2345", null2, 4); // { dg-warning "\\\[-Wnonnull]" }
54 r += strlen (null3); // { dg-warning "\\\[-Wnonnull]" }
55 return r;
56 }