1 /* Missing <cstddef>. */
3 void *ptr = NULL; // { dg-error "'NULL' was not declared" }
4 // { dg-message "'NULL' is defined in header '<cstddef>'; did you forget to '#include <cstddef>'?" "" { target *-*-* } .-1 }
6 ptrdiff_t pd; // { dg-error "'ptrdiff_t' does not name a type" }
7 // { dg-message "'ptrdiff_t' is defined in header '<cstddef>'; did you forget to '#include <cstddef>'?" "" { target *-*-* } .-1 }
9 size_t sz; // { dg-error "'size_t' does not name a type" }
10 // { dg-message "'size_t' is defined in header '<cstddef>'; did you forget to '#include <cstddef>'?" "" { target *-*-* } .-1 }
12 /* Missing <cstdio>. */
14 void test_cstdio (void)
16 FILE *f; // { dg-error "'FILE' was not declared in this scope" }
17 // { dg-message "'FILE' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?" "" { target *-*-* } .-1 }
18 // { dg-error "'f' was not declared in this scope" "" { target *-*-* } .-2 }
19 // { dg-bogus "suggested alternative: 'if'" "PR c++/80567" { xfail *-*-* } .-3 }
21 char buf[BUFSIZ]; // { dg-error "'BUFSIZ' was not declared" }
22 // { dg-message "'BUFSIZ' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?" "" { target *-*-* } .-1 }
24 char buf2[FILENAME_MAX]; // { dg-error "'FILENAME_MAX' was not declared" }
25 // { dg-message "'FILENAME_MAX' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?" "" { target *-*-* } .-1 }
27 stderr; // { dg-error "'stderr' was not declared" }
28 // { dg-message "'stderr' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?" "" { target *-*-* } .-1 }
30 stdin; // { dg-error "'stdin' was not declared" }
31 // { dg-message "'stdin' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?" "" { target *-*-* } .-1 }
33 stdout; // { dg-error "'stdout' was not declared" }
34 // { dg-message "'stdout' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?" "" { target *-*-* } .-1 }
36 EOF; // { dg-error "'EOF' was not declared" }
37 // { dg-message "'EOF' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?" "" { target *-*-* } .-1 }
40 /* Missing <cerrno>. */
42 int test_cerrno (void)
44 return errno; // { dg-error "'errno' was not declared" }
45 // { dg-message "'errno' is defined in header '<cerrno>'; did you forget to '#include <cerrno>'?" "" { target *-*-* } .-1 }
48 /* Missing <cstdarg>. */
50 void test_cstdarg (void)
52 va_list ap; // { dg-error "'va_list'" }
53 // { dg-message "'va_list' is defined in header '<cstdarg>'; did you forget to '#include <cstdarg>'?" "" { target *-*-* } .-1 }
56 /* Missing <climits>. */
57 int test_INT_MAX (void)
59 return INT_MAX; // { dg-line INT_MAX_line }
60 // { dg-error "'INT_MAX' was not declared" "" { target *-*-* } INT_MAX_line }
61 // { dg-bogus "__INT_MAX__" "" { target *-*-* } INT_MAX_line }
62 // { dg-message "'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?" "" { target *-*-* } INT_MAX_line }
65 /* Verify that we don't offer suggestions to stdlib globals names when
66 there's an explicit namespace. */
70 int not_within_namespace (void)
72 return some_ns::stdout; // { dg-error "'stdout' is not a member of 'some_ns'" }
73 // { dg-bogus "is defined in header" "" { target *-*-* } .-1 }
76 /* Similarly for when there's an explicit class scope. */
80 int not_within_class (void)
82 return some_class::stdout; // { dg-error "'stdout' is not a member of 'some_class'" }
83 // { dg-bogus "is defined in header" "" { target *-*-* } .-1 }