[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / SemaCXX / direct-initializer.cpp
blob947622c4e34c9137c588bc666c998c8aad933f9a
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
5 int x(1);
6 int (x2)(1);
8 void f() {
9 int x(1);
10 int (x2)(1);
11 for (int x(1);;) {}
14 class Y {
15 public: explicit Y(float);
18 class X { // expected-note{{candidate constructor (the implicit copy constructor)}}
19 #if __cplusplus >= 201103L // C++11 or later
20 // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}}
21 #endif
23 public:
24 explicit X(int); // expected-note{{candidate constructor}}
25 X(float, float, float); // expected-note{{candidate constructor}}
26 X(float, Y); // expected-note{{candidate constructor}}
29 class Z { // expected-note{{candidate constructor (the implicit copy constructor)}}
30 #if __cplusplus >= 201103L // C++11 or later
31 // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}}
32 #endif
34 public:
35 Z(int); // expected-note{{candidate constructor}}
38 void g() {
39 X x1(5);
40 X x2(1.0, 3, 4.2);
41 X x3(1.0, 1.0); // expected-error{{no matching constructor for initialization of 'X'}}
42 Y y(1.0);
43 X x4(3.14, y);
45 Z z; // expected-error{{no matching constructor for initialization of 'Z'}}
48 struct Base {
49 operator int*() const;
52 struct Derived : Base {
53 operator int*(); // expected-note {{candidate function}}
56 void foo(const Derived cd, Derived d) {
57 int *pi = cd; // expected-error {{no viable conversion from 'const Derived' to 'int *'}}
58 int *ppi = d;