blob: 1321d734d98fac2839821ede98e3a05b36e11172 [file] [log] [blame]
Douglas Gregor44b43212008-12-11 16:49:14 +00001// RUN: clang -fsyntax-only -verify %s
2
3namespace Ns {
4 int f(); // expected-note{{previous declaration is here}}
Douglas Gregor074149e2009-01-05 19:45:36 +00005
6 enum E {
7 Enumerator
8 };
Douglas Gregor44b43212008-12-11 16:49:14 +00009}
10namespace Ns {
11 double f(); // expected-error{{functions that differ only in their return type cannot be overloaded}}
Douglas Gregor074149e2009-01-05 19:45:36 +000012
13 int x = Enumerator;
Douglas Gregor44b43212008-12-11 16:49:14 +000014}
15
16namespace Ns2 {
17 float f();
18}
19
Douglas Gregor074149e2009-01-05 19:45:36 +000020int y = Ns::Enumerator;
21
Douglas Gregor44b43212008-12-11 16:49:14 +000022namespace Ns2 {
23 float f(int); // expected-note{{previous declaration is here}}
24}
25
26namespace Ns2 {
27 double f(int); // expected-error{{functions that differ only in their return type cannot be overloaded}}
28}
29
30namespace N {
31 int& f1();
32}
33
34namespace N {
35 struct f1 {
36 static int member;
37 };
38
39 void test_f1() {
40 int &i1 = f1();
41 }
42}
43
44namespace N {
45 float& f1(int);
46
47 struct f2 {
48 static int member;
49 };
50 void f2();
51}
52
53int i1 = N::f1::member;
54typedef struct N::f1 type1;
55int i2 = N::f2::member;
56typedef struct N::f2 type2;
57
58void test_f1(int i) {
59 int &v1 = N::f1();
60 float &v2 = N::f1(i);
Chris Lattnera67865c2009-01-05 00:59:08 +000061 int v3 = ::i1;
Douglas Gregor44b43212008-12-11 16:49:14 +000062}
Chris Lattnera67865c2009-01-05 00:59:08 +000063
Chris Lattner83cf05a2009-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
73
74