2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2008-12-12 00:49:14 +08:00
|
|
|
namespace Ns {
|
|
|
|
int f(); // expected-note{{previous declaration is here}}
|
2009-01-06 03:45:36 +08:00
|
|
|
|
|
|
|
enum E {
|
|
|
|
Enumerator
|
|
|
|
};
|
2008-12-12 00:49:14 +08:00
|
|
|
}
|
|
|
|
namespace Ns {
|
|
|
|
double f(); // expected-error{{functions that differ only in their return type cannot be overloaded}}
|
2009-01-06 03:45:36 +08:00
|
|
|
|
|
|
|
int x = Enumerator;
|
2008-12-12 00:49:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace Ns2 {
|
|
|
|
float f();
|
|
|
|
}
|
|
|
|
|
2009-01-06 03:45:36 +08:00
|
|
|
int y = Ns::Enumerator;
|
|
|
|
|
2008-12-12 00:49:14 +08:00
|
|
|
namespace Ns2 {
|
|
|
|
float f(int); // expected-note{{previous declaration is here}}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Ns2 {
|
|
|
|
double f(int); // expected-error{{functions that differ only in their return type cannot be overloaded}}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace N {
|
|
|
|
int& f1();
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace N {
|
|
|
|
struct f1 {
|
|
|
|
static int member;
|
2009-01-13 13:10:00 +08:00
|
|
|
|
|
|
|
typedef int type;
|
|
|
|
|
|
|
|
void foo(type);
|
2008-12-12 00:49:14 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
void test_f1() {
|
|
|
|
int &i1 = f1();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-17 08:42:38 +08:00
|
|
|
void N::f1::foo(int i) {
|
|
|
|
f1::member = i;
|
|
|
|
f1::type &ir = i;
|
|
|
|
}
|
2009-01-13 13:10:00 +08:00
|
|
|
|
2008-12-12 00:49:14 +08:00
|
|
|
namespace N {
|
2009-01-13 13:10:00 +08:00
|
|
|
float& f1(int x) {
|
|
|
|
N::f1::type& i1 = x;
|
2009-01-15 06:20:51 +08:00
|
|
|
f1::type& i2 = x;
|
2009-01-13 13:10:00 +08:00
|
|
|
}
|
2008-12-12 00:49:14 +08:00
|
|
|
|
|
|
|
struct f2 {
|
|
|
|
static int member;
|
|
|
|
};
|
|
|
|
void f2();
|
|
|
|
}
|
|
|
|
|
|
|
|
int i1 = N::f1::member;
|
|
|
|
typedef struct N::f1 type1;
|
|
|
|
int i2 = N::f2::member;
|
|
|
|
typedef struct N::f2 type2;
|
|
|
|
|
|
|
|
void test_f1(int i) {
|
|
|
|
int &v1 = N::f1();
|
|
|
|
float &v2 = N::f1(i);
|
2009-01-05 08:59:08 +08:00
|
|
|
int v3 = ::i1;
|
2009-01-06 13:10:23 +08:00
|
|
|
int v4 = N::f1::member;
|
2008-12-12 00:49:14 +08:00
|
|
|
}
|
2009-01-05 08:59:08 +08:00
|
|
|
|
2009-01-05 09:42:04 +08:00
|
|
|
typedef int f2_type;
|
|
|
|
namespace a {
|
|
|
|
typedef int f2_type(int, int);
|
|
|
|
|
|
|
|
void test_f2() {
|
2010-09-09 05:40:08 +08:00
|
|
|
::f2_type(1, 2); // expected-error {{excess elements in scalar initializer}}
|
2009-01-05 09:42:04 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-08 05:36:02 +08:00
|
|
|
// PR clang/3291
|
|
|
|
namespace a {
|
|
|
|
namespace a { // A1
|
|
|
|
namespace a { // A2
|
2013-10-19 08:04:52 +08:00
|
|
|
int i; // expected-note{{'a::a::a::i' declared here}}
|
2009-01-08 05:36:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-01-05 09:42:04 +08:00
|
|
|
|
2009-01-08 05:36:02 +08:00
|
|
|
void test_a() {
|
2013-10-19 08:04:52 +08:00
|
|
|
a::a::i = 3; // expected-error{{no member named 'i' in namespace 'a::a'; did you mean 'a::a::a::i'?}}
|
2009-01-08 05:36:02 +08:00
|
|
|
a::a::a::i = 4;
|
2013-12-14 09:07:05 +08:00
|
|
|
a::a::j = 3; // expected-error-re{{no member named 'j' in namespace 'a::a'{{$}}}}
|
2009-01-08 05:36:02 +08:00
|
|
|
}
|
|
|
|
|
2010-03-10 19:27:22 +08:00
|
|
|
struct Undef { // expected-note{{definition of 'Undef' is not complete until the closing '}'}}
|
2009-01-17 08:42:38 +08:00
|
|
|
typedef int type;
|
|
|
|
|
|
|
|
Undef::type member;
|
|
|
|
|
2010-03-10 19:27:22 +08:00
|
|
|
static int size = sizeof(Undef); // expected-error{{invalid application of 'sizeof' to an incomplete type 'Undef'}}
|
2009-01-17 08:42:38 +08:00
|
|
|
|
|
|
|
int f();
|
|
|
|
};
|
|
|
|
|
|
|
|
int Undef::f() {
|
|
|
|
return sizeof(Undef);
|
|
|
|
}
|
2009-12-03 03:59:55 +08:00
|
|
|
|
|
|
|
// PR clang/5667
|
|
|
|
namespace test1 {
|
|
|
|
template <typename T> struct is_class {
|
|
|
|
enum { value = 0 };
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T> class ClassChecker {
|
|
|
|
bool isClass() {
|
|
|
|
return is_class<T>::value;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template class ClassChecker<int>;
|
|
|
|
}
|
2010-04-23 10:08:13 +08:00
|
|
|
|
|
|
|
namespace PR6830 {
|
|
|
|
namespace foo {
|
|
|
|
|
|
|
|
class X {
|
|
|
|
public:
|
|
|
|
X() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace foo
|
|
|
|
|
|
|
|
class Z {
|
|
|
|
public:
|
|
|
|
explicit Z(const foo::X& x) {}
|
|
|
|
|
|
|
|
void Work() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
void Test() {
|
|
|
|
Z(foo::X()).Work();
|
|
|
|
}
|
|
|
|
}
|
2012-04-04 05:44:08 +08:00
|
|
|
|
|
|
|
namespace pr12339 {
|
2013-05-29 08:56:45 +08:00
|
|
|
extern "C" void i; // expected-error{{variable has incomplete type 'void'}}
|
2012-04-04 05:44:08 +08:00
|
|
|
pr12339::FOO // expected-error{{no type named 'FOO' in namespace 'pr12339'}}
|
|
|
|
} // expected-error{{expected unqualified-id}}
|