blob: c0d1ca370d13178dcabf6e0152a01702b08889e9 [file] [log] [blame]
Douglas Gregor8acb7272008-12-11 16:49:14 +00001// RUN: clang -fsyntax-only -verify %s
Douglas Gregor8acb7272008-12-11 16:49:14 +00002namespace Ns {
3 int f(); // expected-note{{previous declaration is here}}
Douglas Gregord8028382009-01-05 19:45:36 +00004
5 enum E {
6 Enumerator
7 };
Douglas Gregor8acb7272008-12-11 16:49:14 +00008}
9namespace Ns {
10 double f(); // expected-error{{functions that differ only in their return type cannot be overloaded}}
Douglas Gregord8028382009-01-05 19:45:36 +000011
12 int x = Enumerator;
Douglas Gregor8acb7272008-12-11 16:49:14 +000013}
14
15namespace Ns2 {
16 float f();
17}
18
Douglas Gregord8028382009-01-05 19:45:36 +000019int y = Ns::Enumerator;
20
Douglas Gregor8acb7272008-12-11 16:49:14 +000021namespace Ns2 {
22 float f(int); // expected-note{{previous declaration is here}}
23}
24
25namespace Ns2 {
26 double f(int); // expected-error{{functions that differ only in their return type cannot be overloaded}}
27}
28
29namespace N {
30 int& f1();
31}
32
33namespace N {
34 struct f1 {
35 static int member;
36 };
37
38 void test_f1() {
39 int &i1 = f1();
40 }
41}
42
43namespace N {
44 float& f1(int);
45
46 struct f2 {
47 static int member;
48 };
49 void f2();
50}
51
52int i1 = N::f1::member;
53typedef struct N::f1 type1;
54int i2 = N::f2::member;
55typedef struct N::f2 type2;
56
57void test_f1(int i) {
58 int &v1 = N::f1();
59 float &v2 = N::f1(i);
Chris Lattner7d9d4132009-01-05 00:59:08 +000060 int v3 = ::i1;
Douglas Gregor566782a2009-01-06 05:10:23 +000061 int v4 = N::f1::member;
Douglas Gregor8acb7272008-12-11 16:49:14 +000062}
Chris Lattner7d9d4132009-01-05 00:59:08 +000063
Chris Lattner4899a752009-01-05 01:42:04 +000064typedef int f2_type;
65namespace a {
66 typedef int f2_type(int, int);
67
68 void test_f2() {
69 ::f2_type(1, 2); // expected-error {{function-style cast to a builtin type can only take one argument}}
70 }
71}
72
Douglas Gregor1ae27702009-01-07 21:36:02 +000073// PR clang/3291
74namespace a {
75 namespace a { // A1
76 namespace a { // A2
77 int i;
78 }
79 }
80}
Chris Lattner4899a752009-01-05 01:42:04 +000081
Douglas Gregor1ae27702009-01-07 21:36:02 +000082void test_a() {
83 a::a::i = 3; // expected-error{{no member named 'i'}}
84 a::a::a::i = 4;
85}
86
Chris Lattner4899a752009-01-05 01:42:04 +000087