3
3
#define MACRO_A " defining macros outside namespace is valid"
4
4
5
5
class ClassB ;
6
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration must be declared within the '__llvm_libc ' namespace
6
+ // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration must be enclosed within the 'LIBC_NAMESPACE ' namespace
7
7
struct StructC {};
8
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: declaration must be declared within the '__llvm_libc ' namespace
8
+ // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: declaration must be enclosed within the 'LIBC_NAMESPACE ' namespace
9
9
char *VarD = MACRO_A;
10
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration must be declared within the '__llvm_libc ' namespace
10
+ // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: declaration must be enclosed within the 'LIBC_NAMESPACE ' namespace
11
11
typedef int typeE;
12
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: declaration must be declared within the '__llvm_libc ' namespace
12
+ // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: declaration must be enclosed within the 'LIBC_NAMESPACE ' namespace
13
13
void funcF () {}
14
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: declaration must be declared within the '__llvm_libc' namespace
14
+ // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: declaration must be enclosed within the 'LIBC_NAMESPACE' namespace
15
+
16
+ namespace outer_most {
17
+ // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: the outermost namespace should be the 'LIBC_NAMESPACE' macro
18
+ class A {};
19
+ }
20
+
21
+ // Wrapped in anonymous namespace.
22
+ namespace {
23
+ // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: declaration must be enclosed within the 'LIBC_NAMESPACE' namespace
24
+ class A {};
25
+ }
15
26
16
27
namespace namespaceG {
17
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: '__llvm_libc' needs to be the outermost namespace
18
- namespace __llvm_libc {
28
+ // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: the outermost namespace should be the 'LIBC_NAMESPACE' macro
29
+ namespace __llvm_libc {
19
30
namespace namespaceH {
20
31
class ClassB ;
21
32
} // namespace namespaceH
@@ -26,9 +37,20 @@ typedef int typeE;
26
37
void funcF () {}
27
38
} // namespace namespaceG
28
39
29
- // Wrapped in correct namespace.
30
- namespace __llvm_libc {
31
- // Namespaces within __llvim_libc namespace allowed.
40
+ // Wrapped in macro namespace but with an incorrect name
41
+ #define LIBC_NAMESPACE custom_namespace
42
+ namespace LIBC_NAMESPACE {
43
+ // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: the 'LIBC_NAMESPACE' macro should start with '__llvm_libc'
44
+ namespace namespaceH {
45
+ class ClassB ;
46
+ } // namespace namespaceH
47
+ } // namespace LIBC_NAMESPACE
48
+
49
+
50
+ // Wrapped in macro namespace with a valid name, LIBC_NAMESPACE starts with '__llvm_libc'
51
+ #undef LIBC_NAMESPACE
52
+ #define LIBC_NAMESPACE __llvm_libc_xyz
53
+ namespace LIBC_NAMESPACE {
32
54
namespace namespaceI {
33
55
class ClassB ;
34
56
} // namespace namespaceI
@@ -37,4 +59,4 @@ char *VarD = MACRO_A;
37
59
typedef int typeE;
38
60
void funcF () {}
39
61
extern " C" void extern_funcJ () {}
40
- } // namespace __llvm_libc
62
+ } // namespace LIBC_NAMESPACE
0 commit comments