| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 |
|
| 3 |
// Member Test1 hides class Test1 |
| 4 |
class Test1 { |
| 5 |
static int Test1; // expected-error {{member 'Test1' has the same name as its class}} |
| 6 |
// expected-note@-1 {{class 'Test1' is hidden by a non-type declaration of 'Test1' here}} |
| 7 |
void fn1() { |
| 8 |
Test1 x; // expected-error {{must use 'class' tag to refer to type 'Test1' in this scope}} |
| 9 |
} |
| 10 |
int fn2() { |
| 11 |
return Test1; |
| 12 |
} |
| 13 |
}; |
| 14 |
|
| 15 |
// Member Test2 doesn't hide class Test2 as its declaration is invalid |
| 16 |
class Test2 { // expected-note {{declared here}} |
| 17 |
static NoSuchType Test2; // expected-error {{unknown type name 'NoSuchType'}} |
| 18 |
// expected-error@-1 {{member 'Test2' has the same name as its class}} |
| 19 |
void fn1() { |
| 20 |
Test2 x; |
| 21 |
} |
| 22 |
int fn2() { |
| 23 |
return Test2; // expected-error {{'Test2' does not refer to a value}} |
| 24 |
} |
| 25 |
}; |
| 26 |
|
| 27 |
// Test3a::x doesn't hide Test3b::x as its declaration is invalid |
| 28 |
namespace Test3a { |
| 29 |
NoSuchType x() { return 0; } // expected-error {{unknown type name 'NoSuchType'}} |
| 30 |
} |
| 31 |
namespace Test3b { |
| 32 |
class x; // expected-note {{declared here}} |
| 33 |
} |
| 34 |
using Test3a::x; |
| 35 |
using Test3b::x; |
| 36 |
int test3_fn() { |
| 37 |
return x; // expected-error {{'x' does not refer to a value}} |
| 38 |
} |
| 39 |
|
| 40 |
// Function Test4 hides class Test4, whose declaration is invalid |
| 41 |
class Test4 : public NoSuchType { // expected-error {{expected class name}} |
| 42 |
|
| 43 |
}; |
| 44 |
int Test4() { return 0; } |
| 45 |
|
| 46 |
int test4_fn() { |
| 47 |
return Test4(); |
| 48 |
} |
| 49 |
|
| 50 |
// Function Test5 doesn't hide class Test5 when both are invalid |
| 51 |
class Test5 : public NoSuchType { // expected-error {{expected class name}} |
| 52 |
|
| 53 |
}; |
| 54 |
NoSuchType Test5() { return 0; } // expected-error {{unknown type name 'NoSuchType'}} |
| 55 |
|
| 56 |
Test5 test5_fn() { |
| 57 |
Test5 x; |
| 58 |
return x; |
| 59 |
} |