| 1 |
// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify -Wreserved-identifier %s |
| 2 |
|
| 3 |
int foo__bar() { return 0; } // expected-warning {{identifier 'foo__bar' is reserved because it contains '__'}} |
| 4 |
static int _bar() { return 0; } // expected-warning {{identifier '_bar' is reserved because it starts with '_' at global scope}} |
| 5 |
static int _Bar() { return 0; } // expected-warning {{identifier '_Bar' is reserved because it starts with '_' followed by a capital letter}} |
| 6 |
int _barbouille() { return 0; } // expected-warning {{identifier '_barbouille' is reserved because it starts with '_' at global scope}} |
| 7 |
|
| 8 |
void foo(unsigned int _Reserved) { // expected-warning {{identifier '_Reserved' is reserved because it starts with '_' followed by a capital letter}} |
| 9 |
unsigned int __1 = // expected-warning {{identifier '__1' is reserved because it starts with '__'}} |
| 10 |
_Reserved; // no-warning |
| 11 |
} |
| 12 |
|
| 13 |
// This one is explicitly skipped by -Wreserved-identifier |
| 14 |
void *_; // no-warning |
| 15 |
|
| 16 |
template <class T> constexpr bool __toucan = true; // expected-warning {{identifier '__toucan' is reserved because it starts with '__'}} |
| 17 |
|
| 18 |
template <class T> |
| 19 |
concept _Barbotine = __toucan<T>; // expected-warning {{identifier '_Barbotine' is reserved because it starts with '_' followed by a capital letter}} |
| 20 |
|
| 21 |
template <class __> // expected-warning {{'__' is reserved because it starts with '__'}} |
| 22 |
struct BarbeNoire {}; |
| 23 |
|
| 24 |
template <class _not_reserved> // no-warning |
| 25 |
struct BarbeJaune {}; |
| 26 |
|
| 27 |
template <class __> // expected-warning {{'__' is reserved because it starts with '__'}} |
| 28 |
void BarbeRousse() {} |
| 29 |
|
| 30 |
namespace _Barbidur { // expected-warning {{identifier '_Barbidur' is reserved because it starts with '_' followed by a capital letter}} |
| 31 |
|
| 32 |
struct __barbidou {}; // expected-warning {{identifier '__barbidou' is reserved because it starts with '__'}} |
| 33 |
struct _barbidou {}; // no-warning |
| 34 |
|
| 35 |
int __barbouille; // expected-warning {{identifier '__barbouille' is reserved because it starts with '__'}} |
| 36 |
int _barbouille; // no-warning |
| 37 |
|
| 38 |
int __babar() { return 0; } // expected-warning {{identifier '__babar' is reserved because it starts with '__'}} |
| 39 |
int _babar() { return 0; } // no-warning |
| 40 |
|
| 41 |
} // namespace _Barbidur |
| 42 |
|
| 43 |
class __barbapapa { // expected-warning {{identifier '__barbapapa' is reserved because it starts with '__'}} |
| 44 |
void _barbabelle() {} // no-warning |
| 45 |
int _Barbalala; // expected-warning {{identifier '_Barbalala' is reserved because it starts with '_' followed by a capital letter}} |
| 46 |
}; |
| 47 |
|
| 48 |
enum class __menu { // expected-warning {{identifier '__menu' is reserved because it starts with '__'}} |
| 49 |
__some, // expected-warning {{identifier '__some' is reserved because it starts with '__'}} |
| 50 |
_Other, // expected-warning {{identifier '_Other' is reserved because it starts with '_' followed by a capital letter}} |
| 51 |
_other // no-warning |
| 52 |
}; |
| 53 |
|
| 54 |
enum _Menu { // expected-warning {{identifier '_Menu' is reserved because it starts with '_' followed by a capital letter}} |
| 55 |
_OtheR_, // expected-warning {{identifier '_OtheR_' is reserved because it starts with '_' followed by a capital letter}} |
| 56 |
_other_ // expected-warning {{identifier '_other_' is reserved because it starts with '_' at global scope}} |
| 57 |
}; |
| 58 |
|
| 59 |
enum { |
| 60 |
__some, // expected-warning {{identifier '__some' is reserved because it starts with '__'}} |
| 61 |
_Other, // expected-warning {{identifier '_Other' is reserved because it starts with '_' followed by a capital letter}} |
| 62 |
_other // expected-warning {{identifier '_other' is reserved because it starts with '_' at global scope}} |
| 63 |
}; |
| 64 |
|
| 65 |
static union { |
| 66 |
int _barbeFleurie; // no-warning |
| 67 |
}; |
| 68 |
|
| 69 |
using _Barbamama = __barbapapa; // expected-warning {{identifier '_Barbamama' is reserved because it starts with '_' followed by a capital letter}} |
| 70 |
|
| 71 |
int foobar() { |
| 72 |
return foo__bar(); // no-warning |
| 73 |
} |
| 74 |
|
| 75 |
namespace { |
| 76 |
int _barbatruc; // no-warning |
| 77 |
} |
| 78 |
|
| 79 |
long double operator"" _BarbeBleue(long double) // expected-warning {{identifier '_BarbeBleue' is reserved because it starts with '_' followed by a capital letter}}\ |
| 80 |
// expected-warning {{identifier '_BarbeBleue' preceded by whitespace in a literal operator declaration is deprecated}} |
| 81 |
{ |
| 82 |
return 0.; |
| 83 |
} |
| 84 |
|
| 85 |
long double operator""_SacreBleu(long double) // no-warning |
| 86 |
{ |
| 87 |
return 0.; |
| 88 |
} |
| 89 |
|
| 90 |
long double sacrebleu = operator"" _SacreBleu(1.2); // expected-warning {{identifier '_SacreBleu' is reserved because it starts with '_' followed by a capital letter}} \ |
| 91 |
// expected-warning {{identifier '_SacreBleu' preceded by whitespace in a literal operator declaration is deprecated}} |
| 92 |
long double sangbleu = operator""_SacreBleu(1.2); // no-warning |
| 93 |
|
| 94 |
void operator"" _lowercase(unsigned long long); // expected-warning {{identifier '_lowercase' preceded by whitespace in a literal operator declaration is deprecated}} |
| 95 |
void operator""_lowercase(unsigned long long); // no-warning |
| 96 |
|
| 97 |
struct _BarbeRouge { // expected-warning {{identifier '_BarbeRouge' is reserved because it starts with '_' followed by a capital letter}} |
| 98 |
} p; |
| 99 |
struct _BarbeNoire { // expected-warning {{identifier '_BarbeNoire' is reserved because it starts with '_' followed by a capital letter}} |
| 100 |
} * q; |
| 101 |
|
| 102 |
struct Any { |
| 103 |
friend void _barbegrise(); // expected-warning {{identifier '_barbegrise' is reserved because it starts with '_' at global scope}} |
| 104 |
}; |
| 105 |
|
| 106 |
#define _not_reserved |
| 107 |
#define _Reserved // expected-warning {{macro name is a reserved identifier}} |
| 108 |
#undef _not_reserved |
| 109 |
#undef _Reserved // expected-warning {{macro name is a reserved identifier}} |
| 110 |
|
| 111 |
namespace N { |
| 112 |
int _namespace_a; |
| 113 |
extern "C" int _namespace_b; // expected-warning {{identifier '_namespace_b' is reserved because it starts with '_' and has C language linkage}} |
| 114 |
void _namespace_c(); |
| 115 |
extern "C" void _namespace_d(); // expected-warning {{identifier '_namespace_d' is reserved because it starts with '_' and has C language linkage}} |
| 116 |
} |