brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.8 KiB · a3e6d8e Raw
117 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify -Wreserved-identifier %s2 3int foo__bar() { return 0; }    // expected-warning {{identifier 'foo__bar' is reserved because it contains '__'}}4static int _bar() { return 0; } // expected-warning {{identifier '_bar' is reserved because it starts with '_' at global scope}}5static int _Bar() { return 0; } // expected-warning {{identifier '_Bar' is reserved because it starts with '_' followed by a capital letter}}6int _barbouille() { return 0; } // expected-warning {{identifier '_barbouille' is reserved because it starts with '_' at global scope}}7 8void 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-warning11}12 13// This one is explicitly skipped by -Wreserved-identifier14void *_; // no-warning15 16template <class T> constexpr bool __toucan = true; // expected-warning {{identifier '__toucan' is reserved because it starts with '__'}}17 18template <class T>19concept _Barbotine = __toucan<T>; // expected-warning {{identifier '_Barbotine' is reserved because it starts with '_' followed by a capital letter}}20 21template <class __> // expected-warning {{'__' is reserved because it starts with '__'}}22struct BarbeNoire {};23 24template <class _not_reserved> // no-warning25struct BarbeJaune {};26 27template <class __> // expected-warning {{'__' is reserved because it starts with '__'}}28void BarbeRousse() {}29 30namespace _Barbidur { // expected-warning {{identifier '_Barbidur' is reserved because it starts with '_' followed by a capital letter}}31 32struct __barbidou {}; // expected-warning {{identifier '__barbidou' is reserved because it starts with '__'}}33struct _barbidou {};  // no-warning34 35int __barbouille; // expected-warning {{identifier '__barbouille' is reserved because it starts with '__'}}36int _barbouille;  // no-warning37 38int __babar() { return 0; } // expected-warning {{identifier '__babar' is reserved because it starts with '__'}}39int _babar() { return 0; }  // no-warning40 41} // namespace _Barbidur42 43class __barbapapa {     // expected-warning {{identifier '__barbapapa' is reserved because it starts with '__'}}44  void _barbabelle() {} // no-warning45  int _Barbalala;       // expected-warning {{identifier '_Barbalala' is reserved because it starts with '_' followed by a capital letter}}46};47 48enum 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-warning52};53 54enum _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 59enum {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 65static union {66  int _barbeFleurie; // no-warning67};68 69using _Barbamama = __barbapapa; // expected-warning {{identifier '_Barbamama' is reserved because it starts with '_' followed by a capital letter}}70 71int foobar() {72  return foo__bar(); // no-warning73}74 75namespace {76int _barbatruc; // no-warning77}78 79long 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 85long double operator""_SacreBleu(long double) // no-warning86{87  return 0.;88}89 90long 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}}92long double sangbleu = operator""_SacreBleu(1.2);   // no-warning93 94void operator"" _lowercase(unsigned long long); // expected-warning {{identifier '_lowercase' preceded by whitespace in a literal operator declaration is deprecated}}95void operator""_lowercase(unsigned long long); // no-warning96 97struct _BarbeRouge { // expected-warning {{identifier '_BarbeRouge' is reserved because it starts with '_' followed by a capital letter}}98} p;99struct _BarbeNoire { // expected-warning {{identifier '_BarbeNoire' is reserved because it starts with '_' followed by a capital letter}}100} * q;101 102struct Any {103  friend void _barbegrise(); // expected-warning {{identifier '_barbegrise' is reserved because it starts with '_' at global scope}}104};105 106#define _not_reserved107#define _Reserved // expected-warning {{macro name is a reserved identifier}}108#undef _not_reserved109#undef _Reserved // expected-warning {{macro name is a reserved identifier}}110 111namespace 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}117