brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · 6fbf980 Raw
83 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s 2// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s3// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s4 5class X {6public:7  explicit X(const X&); // expected-note 2{{not a candidate}}8  X(int*); // expected-note 3{{candidate constructor}}9  explicit X(float*); // expected-note {{candidate constructor}} expected-note 2{{not a candidate}}10};11 12class Y : public X { };13 14void f(Y y, int *ip, float *fp) {15  X x1 = y; // expected-error{{no matching constructor for initialization of 'X'}}16  X x2 = 0;17  X x3 = ip;18  X x4 = fp; // expected-error{{no viable conversion}}19  X x2a(0); // expected-error{{call to constructor of 'X' is ambiguous}}20  X x3a(ip);21  X x4a(fp);22}23 24struct foo {25 void bar(); // expected-note{{declared here}}26};27 28// PR360029void test(const foo *P) { P->bar(); } // expected-error{{'this' argument to member function 'bar' has type 'const foo', but function is not marked const}}30 31namespace PR6757 {32  struct Foo {33    Foo(); // expected-note{{not viable}}34    Foo(Foo&); // expected-note{{candidate constructor not viable}}35  };36 37  struct Bar {38    operator const Foo&() const;39  };40 41  void f(Foo);42 43  void g(Foo foo) {44    f(Bar()); // expected-error{{no viable constructor copying parameter of type 'const Foo'}}45    f(foo);46  }47}48 49namespace DR5 {50  // Core issue 5: if a temporary is created in copy-initialization, it is of51  // the cv-unqualified version of the destination type.52  namespace Ex1 {53    struct C { };54    C c;55    struct A {56        A(const A&);57        A(const C&);58    };59    const volatile A a = c; // ok60  }61 62  namespace Ex2 {63    struct S {64      S(S&&);65#if __cplusplus <= 199711L // C++03 or earlier modes66      // expected-warning@-2 {{rvalue references are a C++11 extension}}67#endif68      S(int);69    };70    const S a(0);71    const S b = 0;72  }73}74 75struct A {};76struct B : A {77  B();78  B(B&);79  B(A);80  B(int);81};82B b = 0; // ok, calls B(int) then A(const A&) then B(A).83