| 1 |
/* Verify that we don't offer names that are reserved for the |
| 2 |
implementation (PR c/83236). */ |
| 3 |
/* { dg-options "-nostdinc" } */ |
| 4 |
|
| 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'. */ |
| 7 |
|
| 8 |
typedef unsigned long int __ino_t; |
| 9 |
ino_t inode; /* { dg-error "did you mean 'int'" } */ |
| 10 |
|
| 11 |
|
| 12 |
/* Example of a typedef with a leading double-underscore. */ |
| 13 |
|
| 14 |
typedef unsigned char __u_char; |
| 15 |
u_char ch; /* { dg-error "did you mean 'char'" } */ |
| 16 |
|
| 17 |
|
| 18 |
/* Example of a macro with a leading double-underscore. */ |
| 19 |
|
| 20 |
# define __SOME_MACRO int |
| 21 |
|
| 22 |
SOME_MACRO foo; /* { dg-bogus "__SOME_MACRO" } */ |
| 23 |
/* { dg-error "'SOME_MACRO'" "" { target *-*-* } .-1 } */ |
| 24 |
|
| 25 |
|
| 26 |
/* If the misspelled name itself matches the "reserved" pattern, then |
| 27 |
it's OK to suggest such names. */ |
| 28 |
|
| 29 |
void test (const char *buf, char ch) |
| 30 |
{ |
| 31 |
__builtin_strtchr (buf, ch); /* { dg-line misspelled_reserved } */ |
| 32 |
/* { dg-error "did you mean '__builtin_strchr'" "" { target c } misspelled_reserved } */ |
| 33 |
/* { dg-error "'__builtin_strtchr' was not declared in this scope; did you mean '__builtin_strrchr'\\?" "" { target c++ } misspelled_reserved } */ |
| 34 |
} |
| 35 |
|
| 36 |
/* Similarly for a name that begins with a single underscore. */ |
| 37 |
|
| 38 |
void test_2 (const char *buf, char ch) |
| 39 |
{ |
| 40 |
_builtin_strchr (buf, ch); /* { dg-line misspelled_one_underscore } */ |
| 41 |
/* { dg-error "did you mean '__builtin_strchr'" "" { target c } misspelled_one_underscore } */ |
| 42 |
/* { dg-error "'_builtin_strchr' was not declared in this scope; did you mean '__builtin_strchr'\\?" "" { target c++ } misspelled_one_underscore } */ |
| 43 |
} |
| 44 |
|
| 45 |
/* Verify that we can correct "__FILE_" to "__FILE__". */ |
| 46 |
|
| 47 |
const char * test_3 (void) |
| 48 |
{ |
| 49 |
return __FILE_; /* { dg-line misspelled__FILE_ } */ |
| 50 |
/* { dg-error "did you mean '__FILE__'" "" { target c } misspelled__FILE_ } */ |
| 51 |
/* { dg-error "'__FILE_' was not declared in this scope; did you mean '__FILE__'\\?" "" { target c++ } misspelled__FILE_ } */ |
| 52 |
} |
| 53 |
|
| 54 |
/* Verify that we can correct "__FILE_NAME_" to "__FILE_NAME__". */ |
| 55 |
|
| 56 |
const char * test_4 (void) |
| 57 |
{ |
| 58 |
return __FILE_NAME_; /* { dg-line misspelled__FILE_NAME_ } */ |
| 59 |
/* { dg-error "did you mean '__FILE_NAME__'" "" { target c } misspelled__FILE_NAME_ } */ |
| 60 |
/* { dg-error "'__FILE_NAME_' was not declared in this scope; did you mean '__FILE_NAME__'\\?" "" { target c++ } misspelled__FILE_NAME_ } */ |
| 61 |
} |
| 62 |
|
| 63 |
/* Verify that we can correct "__FILENAME__" to "__FILE_NAME__". */ |
| 64 |
|
| 65 |
const char * test_5 (void) |
| 66 |
{ |
| 67 |
return __FILENAME__; /* { dg-line misspelled__FILENAME__ } */ |
| 68 |
/* { dg-error "did you mean '__FILE_NAME__'" "" { target c } misspelled__FILENAME__ } */ |
| 69 |
/* { dg-error "'__FILENAME__' was not declared in this scope; did you mean '__FILE_NAME__'\\?" "" { target c++ } misspelled__FILENAME__ } */ |
| 70 |
} |