[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / dcl_ambig_res.cpp
blobc0f1e2e96a4d59854c0fd22fa4a8886b21382373
1 // RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
3 // PR13819
4 // REQUIRES: LP64
6 // [dcl.ambig.res]p1:
7 struct S {
8 S(int);
9 void bar();
10 };
12 int returns_an_int();
14 void foo(double a)
16 S w(int(a)); // expected-warning{{disambiguated as a function declaration}} expected-note{{add a pair of parentheses}}
17 w(17);
18 S x1(int()); // expected-warning{{disambiguated as a function declaration}} expected-note{{add a pair of parentheses}}
19 x1(&returns_an_int);
20 S y((int)a);
21 y.bar();
22 S z = int(a);
23 z.bar();
26 // [dcl.ambig.res]p3:
27 char *p;
28 void *operator new(__SIZE_TYPE__, int);
29 void foo3() {
30 const int x = 63;
31 new (int(*p)) int; //new-placement expression
32 new (int(*[x])); //new type-id
35 // [dcl.ambig.res]p4:
36 template <class T> // expected-note{{here}}
37 struct S4 {
38 T *p;
39 };
40 S4<int()> x; //type-id
41 S4<int(1)> y; // expected-error{{must be a type}}
43 // [dcl.ambig.res]p5:
44 void foo5()
46 (void)sizeof(int(1)); //expression
47 (void)sizeof(int()); // expected-error{{function type}}
50 // [dcl.ambig.res]p6:
51 void foo6()
53 (void)(int(1)); //expression
54 (void)(int())1; // expected-error{{to 'int ()'}}
57 // [dcl.ambig.res]p7:
58 class C7 { };
59 void f7(int(C7)) { } // expected-note{{candidate}}
60 int g7(C7);
61 void foo7() {
62 f7(1); // expected-error{{no matching function}}
63 f7(g7); //OK
66 void h7(int *(C7[10])) { } // expected-note{{previous}}
67 void h7(int *(*_fp)(C7 _parm[10])) { } // expected-error{{redefinition}}
69 struct S5 {
70 static bool const value = false;
72 int foo8() {
73 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}}
76 template<typename T>
77 void rdar8739801( void (T::*)( void ) __attribute__((unused)) );