1 // RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify -Wreserved-identifier %s
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}}
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
13 // This one is explicitly skipped by -Wreserved-identifier
14 void *_
; // no-warning
16 template <class T
> constexpr bool __toucan
= true; // expected-warning {{identifier '__toucan' is reserved because it starts with '__'}}
19 concept _Barbotine
= __toucan
<T
>; // expected-warning {{identifier '_Barbotine' is reserved because it starts with '_' followed by a capital letter}}
21 template <class __
> // expected-warning {{'__' is reserved because it starts with '__'}}
24 template <class _not_reserved
> // no-warning
27 template <class __
> // expected-warning {{'__' is reserved because it starts with '__'}}
30 namespace _Barbidur
{ // expected-warning {{identifier '_Barbidur' is reserved because it starts with '_' followed by a capital letter}}
32 struct __barbidou
{}; // expected-warning {{identifier '__barbidou' is reserved because it starts with '__'}}
33 struct _barbidou
{}; // no-warning
35 int __barbouille
; // expected-warning {{identifier '__barbouille' is reserved because it starts with '__'}}
36 int _barbouille
; // no-warning
38 int __babar() { return 0; } // expected-warning {{identifier '__babar' is reserved because it starts with '__'}}
39 int _babar() { return 0; } // no-warning
41 } // namespace _Barbidur
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}}
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}}
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}}
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}}
66 int _barbeFleurie
; // no-warning
69 using _Barbamama
= __barbapapa
; // expected-warning {{identifier '_Barbamama' is reserved because it starts with '_' followed by a capital letter}}
72 return foo__bar(); // no-warning
76 int _barbatruc
; // no-warning
79 long double operator"" _BarbeBleue(long double) // expected-warning {{identifier '_BarbeBleue' is reserved because it starts with '_' followed by a capital letter}}
84 long double operator""_SacreBleu(long double) // no-warning
89 long double sacrebleu
= operator"" _SacreBleu(1.2); // expected-warning {{identifier '_SacreBleu' is reserved because it starts with '_' followed by a capital letter}}
90 long double sangbleu
= operator""_SacreBleu(1.2); // no-warning
92 void operator"" _lowercase(unsigned long long); // no-warning
93 void operator""_lowercase(unsigned long long); // no-warning
95 struct _BarbeRouge
{ // expected-warning {{identifier '_BarbeRouge' is reserved because it starts with '_' followed by a capital letter}}
97 struct _BarbeNoire
{ // expected-warning {{identifier '_BarbeNoire' is reserved because it starts with '_' followed by a capital letter}}
101 friend void _barbegrise(); // expected-warning {{identifier '_barbegrise' is reserved because it starts with '_' at global scope}}
104 #define _not_reserved
105 #define _Reserved // expected-warning {{macro name is a reserved identifier}}
107 #undef _Reserved // expected-warning {{macro name is a reserved identifier}}
111 extern "C" int _namespace_b
; // expected-warning {{identifier '_namespace_b' is reserved because it starts with '_' and has C language linkage}}
113 extern "C" void _namespace_d(); // expected-warning {{identifier '_namespace_d' is reserved because it starts with '_' and has C language linkage}}