]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CXX/drs/dr10xx.cpp
Vendor import of clang trunk r290819:
[FreeBSD/FreeBSD.git] / test / CXX / drs / dr10xx.cpp
1 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
2 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
3 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
4 // RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
5
6 namespace std {
7   __extension__ typedef __SIZE_TYPE__ size_t;
8
9   template<typename T> struct initializer_list {
10     const T *p; size_t n;
11     initializer_list(const T *p, size_t n);
12   };
13 }
14
15 namespace dr1048 { // dr1048: 3.6
16   struct A {};
17   const A f();
18   A g();
19   typedef const A CA;
20 #if __cplusplus >= 201103L
21   // ok: we deduce non-const A in each case.
22   A &&a = [] (int n) {
23     while (1) switch (n) {
24       case 0: return f();
25       case 1: return g();
26       case 2: return A();
27       case 3: return CA();
28     }
29   } (0);
30 #endif
31 }
32
33 namespace dr1054 { // dr1054: no
34   // FIXME: Test is incomplete.
35   struct A {} volatile a;
36   void f() {
37     // FIXME: This is wrong: an lvalue-to-rvalue conversion is applied here,
38     // which copy-initializes a temporary from 'a'. Therefore this is
39     // ill-formed because A does not have a volatile copy constructor.
40     // (We might want to track this aspect under dr1383 instead?)
41     a; // expected-warning {{assign into a variable to force a volatile load}}
42   }
43 }
44
45 namespace dr1070 { // dr1070: 3.5
46 #if __cplusplus >= 201103L
47   struct A {
48     A(std::initializer_list<int>);
49   };
50   struct B {
51     int i;
52     A a;
53   };
54   B b = {1};
55   struct C {
56     std::initializer_list<int> a;
57     B b;
58     std::initializer_list<double> c;
59   };
60   C c = {};
61 #endif
62 }