xref: /aosp_15_r20/external/clang/test/CXX/drs/dr16xx.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
2*67e74705SXin Li // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
3*67e74705SXin Li // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
4*67e74705SXin Li // RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
5*67e74705SXin Li 
6*67e74705SXin Li #if __cplusplus < 201103L
7*67e74705SXin Li // expected-no-diagnostics
8*67e74705SXin Li #endif
9*67e74705SXin Li 
10*67e74705SXin Li namespace dr1684 { // dr1684: 3.6
11*67e74705SXin Li #if __cplusplus >= 201103L
12*67e74705SXin Li   struct NonLiteral { // expected-note {{because}}
13*67e74705SXin Li     NonLiteral();
fdr1684::NonLiteral14*67e74705SXin Li     constexpr int f() { return 0; } // expected-warning 0-1{{will not be implicitly 'const'}}
15*67e74705SXin Li   };
f(NonLiteral &)16*67e74705SXin Li   constexpr int f(NonLiteral &) { return 0; }
f(NonLiteral)17*67e74705SXin Li   constexpr int f(NonLiteral) { return 0; } // expected-error {{not a literal type}}
18*67e74705SXin Li #endif
19*67e74705SXin Li }
20*67e74705SXin Li 
21*67e74705SXin Li namespace dr1631 {  // dr1631: 3.7
22*67e74705SXin Li #if __cplusplus >= 201103L
23*67e74705SXin Li   // Incorrect overload resolution for single-element initializer-list
24*67e74705SXin Li 
25*67e74705SXin Li   struct A { int a[1]; };
26*67e74705SXin Li   struct B { B(int); };
27*67e74705SXin Li   void f(B, int);
28*67e74705SXin Li   void f(B, int, int = 0);
29*67e74705SXin Li   void f(int, A);
30*67e74705SXin Li 
test()31*67e74705SXin Li   void test() {
32*67e74705SXin Li     f({0}, {{1}}); // expected-warning {{braces around scalar init}}
33*67e74705SXin Li   }
34*67e74705SXin Li 
35*67e74705SXin Li   namespace with_error {
36*67e74705SXin Li     void f(B, int);           // TODO: expected- note {{candidate function}}
37*67e74705SXin Li     void f(int, A);           // expected-note {{candidate function}}
38*67e74705SXin Li     void f(int, A, int = 0);  // expected-note {{candidate function}}
39*67e74705SXin Li 
test()40*67e74705SXin Li     void test() {
41*67e74705SXin Li       f({0}, {{1}});        // expected-error{{call to 'f' is ambiguous}}
42*67e74705SXin Li     }
43*67e74705SXin Li   }
44*67e74705SXin Li #endif
45*67e74705SXin Li }
46*67e74705SXin Li 
47*67e74705SXin Li namespace dr1645 { // dr1645: 3.9
48*67e74705SXin Li #if __cplusplus >= 201103L
49*67e74705SXin Li   struct A { // expected-note 2{{candidate}}
50*67e74705SXin Li     constexpr A(int, float = 0); // expected-note 2{{candidate}}
51*67e74705SXin Li     explicit A(int, int = 0); // expected-note 2{{candidate}}
52*67e74705SXin Li     A(int, int, int = 0) = delete; // expected-note {{candidate}}
53*67e74705SXin Li   };
54*67e74705SXin Li 
55*67e74705SXin Li   struct B : A { // expected-note 2{{candidate}}
56*67e74705SXin Li     using A::A; // expected-note 7{{inherited here}}
57*67e74705SXin Li   };
58*67e74705SXin Li 
59*67e74705SXin Li   constexpr B a(0); // expected-error {{ambiguous}}
60*67e74705SXin Li   constexpr B b(0, 0); // expected-error {{ambiguous}}
61*67e74705SXin Li #endif
62*67e74705SXin Li }
63