xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/dcl_ambig_res.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc // PR13819
4*f4a2713aSLionel Sambuc // REQUIRES: LP64
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc // [dcl.ambig.res]p1:
7*f4a2713aSLionel Sambuc struct S {
8*f4a2713aSLionel Sambuc   S(int);
9*f4a2713aSLionel Sambuc   void bar();
10*f4a2713aSLionel Sambuc };
11*f4a2713aSLionel Sambuc 
12*f4a2713aSLionel Sambuc int returns_an_int();
13*f4a2713aSLionel Sambuc 
foo(double a)14*f4a2713aSLionel Sambuc void foo(double a)
15*f4a2713aSLionel Sambuc {
16*f4a2713aSLionel Sambuc   S w(int(a)); // expected-warning{{disambiguated as a function declaration}} expected-note{{add a pair of parentheses}}
17*f4a2713aSLionel Sambuc   w(17);
18*f4a2713aSLionel Sambuc   S x1(int()); // expected-warning{{disambiguated as a function declaration}} expected-note{{add a pair of parentheses}}
19*f4a2713aSLionel Sambuc   x1(&returns_an_int);
20*f4a2713aSLionel Sambuc   S y((int)a);
21*f4a2713aSLionel Sambuc   y.bar();
22*f4a2713aSLionel Sambuc   S z = int(a);
23*f4a2713aSLionel Sambuc   z.bar();
24*f4a2713aSLionel Sambuc }
25*f4a2713aSLionel Sambuc 
26*f4a2713aSLionel Sambuc // [dcl.ambig.res]p3:
27*f4a2713aSLionel Sambuc char *p;
28*f4a2713aSLionel Sambuc void *operator new(__SIZE_TYPE__, int);
foo3()29*f4a2713aSLionel Sambuc void foo3() {
30*f4a2713aSLionel Sambuc   const int x = 63;
31*f4a2713aSLionel Sambuc   new (int(*p)) int; //new-placement expression
32*f4a2713aSLionel Sambuc   new (int(*[x])); //new type-id
33*f4a2713aSLionel Sambuc }
34*f4a2713aSLionel Sambuc 
35*f4a2713aSLionel Sambuc // [dcl.ambig.res]p4:
36*f4a2713aSLionel Sambuc template <class T>  // expected-note{{here}}
37*f4a2713aSLionel Sambuc struct S4 {
38*f4a2713aSLionel Sambuc   T *p;
39*f4a2713aSLionel Sambuc };
40*f4a2713aSLionel Sambuc S4<int()> x; //type-id
41*f4a2713aSLionel Sambuc S4<int(1)> y; // expected-error{{must be a type}}
42*f4a2713aSLionel Sambuc 
43*f4a2713aSLionel Sambuc // [dcl.ambig.res]p5:
foo5()44*f4a2713aSLionel Sambuc void foo5()
45*f4a2713aSLionel Sambuc {
46*f4a2713aSLionel Sambuc   (void)sizeof(int(1)); //expression
47*f4a2713aSLionel Sambuc   (void)sizeof(int()); // expected-error{{function type}}
48*f4a2713aSLionel Sambuc }
49*f4a2713aSLionel Sambuc 
50*f4a2713aSLionel Sambuc // [dcl.ambig.res]p6:
foo6()51*f4a2713aSLionel Sambuc void foo6()
52*f4a2713aSLionel Sambuc {
53*f4a2713aSLionel Sambuc   (void)(int(1)); //expression
54*f4a2713aSLionel Sambuc   (void)(int())1; // expected-error{{to 'int ()'}}
55*f4a2713aSLionel Sambuc }
56*f4a2713aSLionel Sambuc 
57*f4a2713aSLionel Sambuc // [dcl.ambig.res]p7:
58*f4a2713aSLionel Sambuc class C7 { };
f7(int (C7))59*f4a2713aSLionel Sambuc void f7(int(C7)) { } // expected-note{{candidate}}
60*f4a2713aSLionel Sambuc int g7(C7);
foo7()61*f4a2713aSLionel Sambuc void foo7() {
62*f4a2713aSLionel Sambuc   f7(1); // expected-error{{no matching function}}
63*f4a2713aSLionel Sambuc   f7(g7); //OK
64*f4a2713aSLionel Sambuc }
65*f4a2713aSLionel Sambuc 
h7(int * (C7[10]))66*f4a2713aSLionel Sambuc void h7(int *(C7[10])) { } // expected-note{{previous}}
h7(int * (* _fp)(C7 _parm[10]))67*f4a2713aSLionel Sambuc void h7(int *(*_fp)(C7 _parm[10])) { } // expected-error{{redefinition}}
68*f4a2713aSLionel Sambuc 
69*f4a2713aSLionel Sambuc struct S5 {
70*f4a2713aSLionel Sambuc   static bool const value = false;
71*f4a2713aSLionel Sambuc };
foo8()72*f4a2713aSLionel Sambuc int foo8() {
73*f4a2713aSLionel Sambuc   int v(int(S5::value)); // expected-warning{{disambiguated as a function declaration}} expected-note{{add a pair of parentheses}} expected-error{{parameter declarator cannot be qualified}}
74*f4a2713aSLionel Sambuc }
75*f4a2713aSLionel Sambuc 
76*f4a2713aSLionel Sambuc template<typename T>
77*f4a2713aSLionel Sambuc void rdar8739801( void (T::*)( void ) __attribute__((unused)) );
78