PR tree-optimization/86401
[official-gcc.git] / gcc / testsuite / c-c++-common / spellcheck-reserved.c
blob79b653241dcbba66cc5ab6369fe3603985f1b9a3
1 /* Verify that we don't offer names that are reserved for the
2 implementation (PR c/83236). */
3 /* { dg-options "-nostdinc" } */
5 /* Example of an identifier with a leading double-underscore.
6 We shouldn't offer '__ino_t' as a suggestion for an unknown 'ino_t'. */
8 typedef unsigned long int __ino_t;
9 ino_t inode; /* { dg-error "did you mean 'int'" } */
12 /* Example of a typedef with a leading double-underscore. */
14 typedef unsigned char __u_char;
15 u_char ch; /* { dg-error "did you mean 'char'" } */
18 /* Example of a macro with a leading double-underscore. */
20 # define __SOME_MACRO int
22 SOME_MACRO foo; /* { dg-bogus "__SOME_MACRO" } */
23 /* { dg-error "'SOME_MACRO'" "" { target *-*-* } .-1 } */
26 /* If the misspelled name itself matches the "reserved" pattern, then
27 it's OK to suggest such names. */
29 void test (const char *buf, char ch)
31 __builtin_strtchr (buf, ch); /* { dg-line misspelled_reserved } */
32 /* { dg-warning "did you mean '__builtin_strchr'" "" { target c } misspelled_reserved } */
33 /* { dg-error "not declared" "" { target c++ } misspelled_reserved } */
34 /* { dg-message "'__builtin_strrchr'" "" { target c++ } misspelled_reserved } */
37 /* Similarly for a name that begins with a single underscore. */
39 void test_2 (const char *buf, char ch)
41 _builtin_strchr (buf, ch); /* { dg-line misspelled_one_underscore } */
42 /* { dg-warning "did you mean '__builtin_strchr'" "" { target c } misspelled_one_underscore } */
43 /* { dg-error "not declared" "" { target c++ } misspelled_one_underscore } */
44 /* { dg-message "'__builtin_strchr'" "" { target c++ } misspelled_one_underscore } */
47 /* Verify that we can correct "__FILE_" to "__FILE__". */
49 const char * test_3 (void)
51 return __FILE_; /* { dg-line misspelled__FILE_ } */
52 /* { dg-error "did you mean '__FILE__'" "" { target c } misspelled__FILE_ } */
53 /* { dg-error "not declared" "" { target c++ } misspelled__FILE_ } */
54 /* { dg-message "'__FILE__'" "" { target c++ } misspelled__FILE_ } */