blob: 19f15ebe0f0b04c30290048821aec33b013636ef [file] [log] [blame]
Richard Smith9ca5c422011-10-13 22:29:44 +00001// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
Richard Smith5179eb72016-06-28 19:03:57 +00002//
3// Note: [class.inhctor] was removed by P0136R1. This tests the new behavior
4// for the wording that used to be there.
Sebastian Redl08905022011-02-05 19:23:19 +00005
6struct B1 {
Richard Smith5179eb72016-06-28 19:03:57 +00007 B1(int); // expected-note 3{{target of using}}
8 B1(int, int); // expected-note 3{{target of using}}
Sebastian Redl08905022011-02-05 19:23:19 +00009};
10struct D1 : B1 {
Richard Smithc2bc61b2013-03-18 21:12:30 +000011 using B1::B1;
Sebastian Redl08905022011-02-05 19:23:19 +000012};
13D1 d1a(1), d1b(1, 1);
14
15D1 fd1() { return 1; }
16
Richard Smith836a3b42017-01-13 20:46:54 +000017struct B2 {
Sebastian Redl08905022011-02-05 19:23:19 +000018 explicit B2(int, int = 0, int = 0);
19};
Richard Smith5179eb72016-06-28 19:03:57 +000020struct D2 : B2 { // expected-note 2{{candidate constructor}}
Richard Smith836a3b42017-01-13 20:46:54 +000021 using B2::B2;
Sebastian Redl08905022011-02-05 19:23:19 +000022};
23D2 d2a(1), d2b(1, 1), d2c(1, 1, 1);
24
25D2 fd2() { return 1; } // expected-error {{no viable conversion}}
26
Richard Smith836a3b42017-01-13 20:46:54 +000027struct B3 {
Richard Smith5179eb72016-06-28 19:03:57 +000028 B3(void*); // expected-note {{candidate}}
Sebastian Redl08905022011-02-05 19:23:19 +000029};
Richard Smith5179eb72016-06-28 19:03:57 +000030struct D3 : B3 { // expected-note 2{{candidate constructor}}
Richard Smith836a3b42017-01-13 20:46:54 +000031 using B3::B3; // expected-note {{inherited here}}
Sebastian Redl08905022011-02-05 19:23:19 +000032};
33D3 fd3() { return 1; } // expected-error {{no viable conversion}}
Richard Smith23d55872012-04-02 01:30:27 +000034
35template<typename T> struct T1 : B1 {
Richard Smith5179eb72016-06-28 19:03:57 +000036 using B1::B1; // expected-note 2{{using declaration}}
Richard Smith23d55872012-04-02 01:30:27 +000037};
38template<typename T> struct T2 : T1<T> {
Richard Smith5179eb72016-06-28 19:03:57 +000039 using T1<int>::T1; // expected-note 2{{using declaration}}
Richard Smith23d55872012-04-02 01:30:27 +000040};
41template<typename T> struct T3 : T1<int> {
Richard Smith5179eb72016-06-28 19:03:57 +000042 using T1<T>::T1; // expected-note 2{{using declaration}}
Richard Smith23d55872012-04-02 01:30:27 +000043};
44struct U {
Richard Smith5179eb72016-06-28 19:03:57 +000045 // [dcl.meaning]p1: "the member shall not merely hav ebeen introduced by a
46 // using-declaration in the scope of the class [...] nominated by the
47 // nested-name-specifier of the declarator-id"
48 friend T1<int>::T1(int); // expected-error {{cannot befriend target of using declaration}}
49 friend T1<int>::T1(int, int); // expected-error {{cannot befriend target of using declaration}}
50 friend T2<int>::T2(int); // expected-error {{cannot befriend target of using declaration}}
51 friend T2<int>::T2(int, int); // expected-error {{cannot befriend target of using declaration}}
52 friend T3<int>::T3(int); // expected-error {{cannot befriend target of using declaration}}
53 friend T3<int>::T3(int, int); // expected-error {{cannot befriend target of using declaration}}
Richard Smith23d55872012-04-02 01:30:27 +000054};
Richard Smith185be182013-04-10 05:48:59 +000055
56struct B4 {
Richard Smith5179eb72016-06-28 19:03:57 +000057 template<typename T> explicit B4(T, int = 0); // expected-note 2{{here}}
Richard Smith185be182013-04-10 05:48:59 +000058};
59template<typename T> struct T4 : B4 {
Richard Smith5179eb72016-06-28 19:03:57 +000060 using B4::B4;
Richard Smith185be182013-04-10 05:48:59 +000061 template<typename U> T4(U);
62};
Richard Smith5179eb72016-06-28 19:03:57 +000063template<typename T> struct U4 : T4<T> {
64 using T4<T>::T4;
65};
Richard Smith185be182013-04-10 05:48:59 +000066T4<void> t4a = {0};
67T4<void> t4b = {0, 0}; // expected-error {{chosen constructor is explicit}}
Richard Smith5179eb72016-06-28 19:03:57 +000068U4<void> u4a = {0};
69U4<void> u4b = {0, 0}; // expected-error {{chosen constructor is explicit}}