Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / drs / dr10xx.cpp
blobf30ed1cb3e49673be0d1db66130620ccc459c4d3
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++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
5 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
6 // RUN: %clang_cc1 -std=c++23 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
8 namespace std {
9 __extension__ typedef __SIZE_TYPE__ size_t;
11 template<typename T> struct initializer_list {
12 const T *p; size_t n;
13 initializer_list(const T *p, size_t n);
17 namespace dr1004 { // dr1004: 5
18 template<typename> struct A {};
19 template<typename> struct B1 {};
20 template<template<typename> class> struct B2 {};
21 template<typename X> void f(); // expected-note {{[with X = dr1004::A<int>]}}
22 template<template<typename> class X> void f(); // expected-note {{[with X = dr1004::A]}}
23 template<template<typename> class X> void g(); // expected-note {{[with X = dr1004::A]}}
24 template<typename X> void g(); // expected-note {{[with X = dr1004::A<int>]}}
25 struct C : A<int> {
26 B1<A> b1a;
27 B2<A> b2a;
28 void h() {
29 f<A>(); // expected-error {{ambiguous}}
30 g<A>(); // expected-error {{ambiguous}}
34 // This example (from the standard) is actually ill-formed, because
35 // name lookup of "T::template A" names the constructor.
36 template<class T, template<class> class U = T::template A> struct Third { }; // expected-error {{is a constructor name}}
37 Third<A<int> > t; // expected-note {{in instantiation of default argument}}
40 namespace dr1042 { // dr1042: 3.5
41 #if __cplusplus >= 201402L
42 // C++14 added an attribute that we can test the semantics of.
43 using foo [[deprecated]] = int; // expected-note {{'foo' has been explicitly marked deprecated here}}
44 foo f = 12; // expected-warning {{'foo' is deprecated}}
45 #elif __cplusplus >= 201103L
46 // C++11 did not have any attributes that could be applied to an alias
47 // declaration, so the best we can test is that we accept an empty attribute
48 // list in this mode.
49 using foo [[]] = int;
50 #endif
53 namespace dr1048 { // dr1048: 3.6
54 struct A {};
55 const A f();
56 A g();
57 typedef const A CA;
58 #if __cplusplus >= 201103L
59 // ok: we deduce non-const A in each case.
60 A &&a = [] (int n) {
61 while (1) switch (n) {
62 case 0: return f();
63 case 1: return g();
64 case 2: return A();
65 case 3: return CA();
67 } (0);
68 #endif
71 namespace dr1054 { // dr1054: no
72 // FIXME: Test is incomplete.
73 struct A {} volatile a;
74 void f() {
75 // FIXME: This is wrong: an lvalue-to-rvalue conversion is applied here,
76 // which copy-initializes a temporary from 'a'. Therefore this is
77 // ill-formed because A does not have a volatile copy constructor.
78 // (We might want to track this aspect under dr1383 instead?)
79 a; // expected-warning {{assign into a variable to force a volatile load}}
83 namespace dr1070 { // dr1070: 3.5
84 #if __cplusplus >= 201103L
85 struct A {
86 A(std::initializer_list<int>);
88 struct B {
89 int i;
90 A a;
92 B b = {1};
93 struct C {
94 std::initializer_list<int> a;
95 B b;
96 std::initializer_list<double> c;
98 C c = {};
99 #endif