1 // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
2 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
3 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
4 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
6 namespace dr100 { // dr100: yes
7 template<const char *> struct A {}; // expected-note 0-1{{declared here}}
8 template<const char (&)[4]> struct B {}; // expected-note 0-1{{declared here}}
9 A<"foo"> a; // expected-error {{does not refer to any declaration}}
10 B<"bar"> b; // expected-error {{does not refer to any declaration}}
13 namespace dr101 { // dr101: 3.5
14 extern "C" void dr101_f();
15 typedef unsigned size_t;
17 extern "C" void dr101_f();
18 typedef unsigned size_t;
22 extern "C" void dr101_f();
23 typedef unsigned size_t;
26 namespace dr102 { // dr102: yes
28 template<typename T> T f(T a, T b) { return a + b; } // expected-error {{neither visible in the template definition nor found by argument-dependent lookup}}
33 B::S operator+(B::S, B::S); // expected-note {{should be declared prior to the call site or in namespace 'dr102::B'}}
34 template B::S A::f(B::S, B::S); // expected-note {{in instantiation of}}
41 namespace dr106 { // dr106: sup 540
44 typedef const r1 r1; // expected-warning {{has no effect}}
45 typedef const r1 &r1; // expected-warning {{has no effect}}
47 typedef const int &r2;
49 typedef const r2 r2; // expected-warning {{has no effect}}
50 typedef const r2 &r2; // expected-warning {{has no effect}}
53 namespace dr107 { // dr107: yes
55 extern "C" S operator+(S, S) { return S(); }
58 namespace dr108 { // dr108: yes
59 template<typename T> struct A {
60 struct B { typedef int X; };
61 B::X x; // expected-error {{missing 'typename'}}
62 struct C : B { X x; }; // expected-error {{unknown type name}}
64 template<> struct A<int>::B { int X; };
67 namespace dr109 { // dr109: yes
68 struct A { template<typename T> void f(T); };
69 template<typename T> struct B : T {
70 using T::template f; // expected-error {{'template' keyword not permitted here}}
71 using T::template f<int>; // expected-error {{'template' keyword not permitted here}} expected-error {{using declaration cannot refer to a template specialization}}
72 // FIXME: We shouldn't suggest using the 'template' keyword in a location where it's not valid.
73 using T::f<int>; // expected-error {{use 'template' keyword}} expected-error {{using declaration cannot refer to a template specialization}}
74 void g() { this->f<int>(123); } // expected-error {{use 'template' keyword}}
78 namespace dr111 { // dr111: dup 535
79 struct A { A(); A(volatile A&, int = 0); A(A&, const char * = "foo"); };
80 struct B : A { B(); }; // expected-note +{{would lose const qualifier}} expected-note {{requires 0 arguments}}
82 B b2(b1); // expected-error {{no matching constructor}}
85 namespace dr112 { // dr112: yes
90 volatile T a2[1] = {};
93 template<const volatile T*> struct X {};
98 #if __cplusplus < 201103L
99 // expected-error@-5 {{internal linkage}} expected-note@-10 {{here}}
100 // expected-error@-4 {{internal linkage}} expected-note@-9 {{here}}
102 // FIXME: Test this somehow.
106 namespace dr113 { // dr113: yes
109 no_such_function(); // expected-error {{undeclared}}
116 namespace dr114 { // dr114: yes
118 virtual void f(int) = 0; // expected-note {{unimplemented}}
121 template<typename T> void f(T);
123 } b; // expected-error {{abstract}}
126 namespace dr115 { // dr115: yes
127 template<typename T> int f(T); // expected-note +{{}}
128 template<typename T> int g(T); // expected-note +{{}}
129 template<typename T> int g(T, int); // expected-note +{{}}
131 int k1 = f(&f); // expected-error {{no match}}
133 int k3 = f(&g<int>); // expected-error {{no match}}
136 (void)&f; // expected-error {{address of overloaded function 'f' cannot be cast to type 'void'}}
138 (void)&g<int>; // expected-error {{address of overloaded function 'g' cannot be cast to type 'void'}}
140 &f; // expected-error {{reference to overloaded function could not be resolved}}
141 &f<int>; // expected-warning {{unused}}
142 &g<int>; // expected-error {{reference to overloaded function could not be resolved}}
146 template<typename T> static int f(T);
147 template<typename T> static int g(T);
148 template<typename T> static int g(T, int);
151 int k4 = f(&s.f); // expected-error {{non-constant pointer to member}}
152 int k5 = f(&s.f<int>);
153 int k6 = f(&s.g<int>); // expected-error {{non-constant pointer to member}}
156 (void)&s.f; // expected-error {{non-constant pointer to member}}
158 (void)&s.g<int>; // expected-error {{non-constant pointer to member}}
160 &s.f; // expected-error {{non-constant pointer to member}}
161 &s.f<int>; // expected-warning {{unused}}
162 &s.g<int>; // expected-error {{non-constant pointer to member}}
166 template<typename T> int f(T);
167 template<typename T> int g(T);
168 template<typename T> int g(T, int);
171 int k7 = f(&s.f); // expected-error {{non-constant pointer to member}}
172 int k8 = f(&s.f<int>);
173 int k9 = f(&s.g<int>); // expected-error {{non-constant pointer to member}}
176 (void)&s.f; // expected-error {{non-constant pointer to member}}
178 (void)&s.g<int>; // expected-error {{non-constant pointer to member}}
180 &s.f; // expected-error {{non-constant pointer to member}}
181 &s.f<int>; // expected-warning {{unused}}
182 &s.g<int>; // expected-error {{non-constant pointer to member}}
185 #if __cplusplus >= 201103L
186 // Special case kicks in only if a template argument list is specified.
187 template<typename T=int> void with_default(); // expected-note +{{}}
188 int k10 = f(&with_default); // expected-error {{no matching function}}
189 int k11 = f(&with_default<>);
191 (void)&with_default; // expected-error {{overloaded function}}
192 (void)&with_default<>;
193 &with_default; // expected-error {{overloaded function}}
194 &with_default<>; // expected-warning {{unused}}
199 namespace dr116 { // dr116: yes
200 template<int> struct A {};
201 template<int N> void f(A<N>) {} // expected-note {{previous}}
202 template<int M> void f(A<M>) {} // expected-error {{redefinition}}
203 template<typename T> void f(A<sizeof(T)>) {} // expected-note {{previous}}
204 template<typename U> void f(A<sizeof(U)>) {} // expected-error {{redefinition}}
208 // dr118 is in its own file.
212 namespace dr121 { // dr121: yes
214 template<typename T> struct Y {};
216 template<typename T> struct Z {
218 T::Y<T> y; // expected-error +{{}}
223 namespace dr122 { // dr122: yes
224 template<typename T> void f();
225 void g() { f<int>(); }
232 struct dr125_A { struct dr125_B {}; }; // expected-note {{here}}
233 dr125_A::dr125_B dr125_C();
234 namespace dr125_B { dr125_A dr125_C(); }
237 friend dr125_A::dr125_B (::dr125_C)(); // ok
238 friend dr125_A (::dr125_B::dr125_C)(); // ok
239 friend dr125_A::dr125_B::dr125_C(); // expected-error {{did you mean the constructor name 'dr125_B'?}}
240 // expected-error@-1 {{missing exception specification}}
244 namespace dr126 { // dr126: partial
245 // FIXME: We do not yet generate correct code for this change:
247 // catch (void*&) should catch void* but not int*
248 // catch (void*) and catch (void*const&) should catch both
250 // catch (Base *&) should catch Base* but not Derived*
251 // catch (Base *) should catch both
252 // In each case, we emit the same code for both catches.
254 // The ABI does not let us represent the language rule in the unwind tables.
255 // So, when catching by non-const (or volatile) reference to pointer, we
256 // should compare the exception type to the caught type and only accept an
258 #if __cplusplus <= 201402L
261 struct E : private C { friend class A; friend class B; };
262 struct F : protected C {};
267 virtual void cp() throw(C*);
268 virtual void dp() throw(C*);
269 virtual void ep() throw(C*); // expected-note {{overridden}}
270 virtual void fp() throw(C*); // expected-note {{overridden}}
271 virtual void gp() throw(C*);
272 virtual void hp() throw(C*); // expected-note {{overridden}}
274 virtual void cr() throw(C&);
275 virtual void dr() throw(C&);
276 virtual void er() throw(C&); // expected-note {{overridden}}
277 virtual void fr() throw(C&); // expected-note {{overridden}}
278 virtual void gr() throw(C&);
279 virtual void hr() throw(C&); // expected-note {{overridden}}
281 virtual void pv() throw(void*);
283 #if __cplusplus >= 201103L
284 virtual void np() throw(C*);
285 virtual void npm() throw(int C::*);
286 virtual void nr() throw(C*&); // expected-note {{overridden}}
287 virtual void ncr() throw(C*const&);
290 virtual void ref1() throw(C *const&);
291 virtual void ref2() throw(C *);
293 virtual void v() throw(int);
294 virtual void w() throw(const int);
295 virtual void x() throw(int*); // expected-note {{overridden}}
296 virtual void y() throw(const int*);
297 virtual void z() throw(int); // expected-note {{overridden}}
300 virtual void cp() throw(C*);
301 virtual void dp() throw(D*);
302 virtual void ep() throw(E*); // expected-error {{more lax}}
303 virtual void fp() throw(F*); // expected-error {{more lax}}
304 virtual void gp() throw(G*);
305 virtual void hp() throw(H*); // expected-error {{more lax}}
307 virtual void cr() throw(C&);
308 virtual void dr() throw(D&);
309 virtual void er() throw(E&); // expected-error {{more lax}}
310 virtual void fr() throw(F&); // expected-error {{more lax}}
311 virtual void gr() throw(G&);
312 virtual void hr() throw(H&); // expected-error {{more lax}}
314 virtual void pv() throw(C*);
316 #if __cplusplus >= 201103L
317 using nullptr_t = decltype(nullptr);
318 virtual void np() throw(nullptr_t);
319 virtual void npm() throw(nullptr_t&);
320 virtual void nr() throw(nullptr_t); // expected-error {{more lax}}
321 virtual void ncr() throw(nullptr_t);
324 virtual void ref1() throw(D *const &);
325 virtual void ref2() throw(D *);
327 virtual void v() throw(const int);
328 virtual void w() throw(int);
329 virtual void x() throw(const int*); // expected-error {{more lax}}
330 virtual void y() throw(int*); // ok
331 virtual void z() throw(long); // expected-error {{more lax}}
334 void f() throw(int); // expected-error {{ISO C++17 does not allow}} expected-note {{use 'noexcept}}
338 namespace dr127 { // dr127: yes
339 __extension__ typedef __decltype(sizeof(0)) size_t;
340 template<typename T> struct A {
342 void *operator new(size_t, const char * = 0);
343 void operator delete(void *, const char *) { T::error; } // expected-error 2{{no members}}
344 void operator delete(void *) { T::error; }
346 A<void> *p = new A<void>; // expected-note {{instantiat}}
347 A<int> *q = new ("") A<int>; // expected-note {{instantiat}}
350 namespace dr128 { // dr128: yes
351 enum E1 { e1 } x = e1;
352 enum E2 { e2 } y = static_cast<E2>(x), z = static_cast<E2>(e1);
358 namespace dr131 { // dr131: yes
359 const char *a_with_\u0e8c = "\u0e8c";
360 const char *b_with_\u0e8d = "\u0e8d";
361 const char *c_with_\u0e8e = "\u0e8e";
362 #if __cplusplus < 201103L
363 // expected-error@-4 {{expected ';'}} expected-error@-2 {{expected ';'}}
367 namespace dr132 { // dr132: no
369 extern struct {} x; // ok
370 extern struct S {} y; // FIXME: This is invalid.
378 namespace dr135 { // dr135: yes
380 A f(A a) { return a; }
381 friend A g(A a) { return a; }
382 static A h(A a) { return a; }
386 namespace dr136 { // dr136: 3.4
387 void f(int, int, int = 0); // expected-note {{previous declaration is here}}
388 void g(int, int, int); // expected-note {{previous declaration is here}}
390 friend void f(int, int = 0, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
391 friend void g(int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
392 friend void h(int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be a definition}}
393 friend void i(int, int, int = 0) {} // expected-note {{previous declaration is here}}
394 friend void j(int, int, int = 0) {}
397 void i(int, int, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
399 j(A(), A()); // ok, has default argument
401 extern "C" void k(int, int, int, int); // expected-note {{previous declaration is here}}
404 friend void dr136::k(int, int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}} \
405 // expected-note {{previous declaration is here}}
410 friend void dr136::k(int, int, int = 0, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
414 void f(int); // expected-note {{previous declaration is here}}
417 friend void B::f(int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
421 namespace dr137 { // dr137: yes
423 extern const void *cp;
424 extern volatile void *vp;
425 extern const volatile void *cvp;
426 int *q = static_cast<int*>(p);
427 int *qc = static_cast<int*>(cp); // expected-error {{casts away qualifiers}}
428 int *qv = static_cast<int*>(vp); // expected-error {{casts away qualifiers}}
429 int *qcv = static_cast<int*>(cvp); // expected-error {{casts away qualifiers}}
430 const int *cq = static_cast<const int*>(p);
431 const int *cqc = static_cast<const int*>(cp);
432 const int *cqv = static_cast<const int*>(vp); // expected-error {{casts away qualifiers}}
433 const int *cqcv = static_cast<const int*>(cvp); // expected-error {{casts away qualifiers}}
434 const volatile int *cvq = static_cast<const volatile int*>(p);
435 const volatile int *cvqc = static_cast<const volatile int*>(cp);
436 const volatile int *cvqv = static_cast<const volatile int*>(vp);
437 const volatile int *cvqcv = static_cast<const volatile int*>(cvp);
440 namespace dr139 { // dr139: yes
442 typedef int f; // expected-note {{previous}}
444 friend void f(A &); // expected-error {{different kind of symbol}}
454 void g(A a) { int i = f(a); } // ok, f is typedef not friend function
460 namespace dr140 { // dr140: yes
461 void f(int *const) {} // expected-note {{previous}}
462 void f(int[3]) {} // expected-error {{redefinition}}
464 void g(int n) { n = 2; }
467 namespace dr141 { // dr141: yes
468 template<typename T> void f();
469 template<typename T> struct S { int n; };
471 template<typename T> void f();
472 template<typename T> struct S {};
474 struct B : S<int> {} b;
477 (void)a.S<int>::n; // expected-error {{no member named 'n'}}
478 #if __cplusplus < 201103L
479 // expected-error@-2 {{ambiguous}}
480 // expected-note@-11 {{lookup from the current scope}}
481 // expected-note@-9 {{lookup in the object type}}
483 b.f<int>(); // expected-error {{no member}} expected-error +{{}}
486 template<typename T> struct C {
489 t.f<int>(); // expected-error {{use 'template'}}
492 (void)t.S<int>::n; // ok
495 (void)t.S<int>(); // ok!
498 void h() { C<B>().h(); } // ok
500 template<typename T> void S();
502 void i() { C<X>().i(); } // ok!!
505 namespace dr142 { // dr142: yes
506 class B { // expected-note +{{here}}
508 int mi; // expected-note +{{here}}
509 static int si; // expected-note +{{here}}
511 class D : private B { // expected-note +{{here}}
513 class DD : public D {
517 mi = 3; // expected-error {{private base class}} expected-error {{private member}}
518 si = 3; // expected-error {{private member}}
519 B b_old; // expected-error {{private member}}
523 B::si = 3; // expected-error {{private member}}
525 B *bp1_old = this; // expected-error {{private member}} expected-error {{private base class}}
526 dr142::B *bp1 = this; // expected-error {{private base class}}
527 B *bp2_old = (B*)this; // expected-error 2{{private member}}
528 dr142::B *bp2 = (dr142::B*)this;
533 namespace dr143 { // dr143: yes
534 namespace A { struct X; }
535 namespace B { void f(A::X); }
537 struct X { friend void B::f(X); };
540 f(x); // expected-error {{undeclared identifier 'f'}}
544 namespace dr145 { // dr145: yes
546 #if __cplusplus <= 201402L
547 ++b; // expected-warning {{deprecated}}
548 b++; // expected-warning {{deprecated}}
550 ++b; // expected-error {{increment}}
551 b++; // expected-error {{increment}}
556 namespace dr147 { // dr147: yes
558 template<typename> struct A {
559 template<typename T> A(T);
561 // Per core issue 1435, this is ill-formed because A<int>::A<int> does not
562 // name the injected-class-name. (A<int>::A does, though.)
563 template<> template<> A<int>::A<int>(int) {} // expected-error {{out-of-line constructor for 'A' cannot have template arguments}}
564 template<> template<> A<float>::A(float) {}
568 struct B : A { B(); };
569 A::A a1; // expected-error {{is a constructor}}
573 template<typename> struct A {
574 template<typename T> A(T);
577 template<> A<int>::A<int>(A<int>::a); // expected-error {{is a constructor}}
581 namespace dr148 { // dr148: yes
582 struct A { int A::*p; };
583 int check1[__is_pod(int(A::*)) ? 1 : -1];
584 int check2[__is_pod(A) ? 1 : -1];
589 namespace dr151 { // dr151: yes
592 #if __cplusplus < 201103L
593 #define fold(x) (__builtin_constant_p(0) ? (x) : (x))
597 int check[fold(p() == 0) ? 1 : -1];
601 namespace dr152 { // dr152: yes
603 A(); // expected-note 0-2{{not viable}}
604 explicit A(const A&);
607 #if __cplusplus <= 201402L
608 // expected-error@-2 {{no matching constructor}}
613 A a3 = f(); // expected-error {{no matching constructor}}
619 namespace dr154 { // dr154: yes
620 union { int a; }; // expected-error {{must be declared 'static'}}
624 static union { int c; };
627 namespace dr155 { // dr155: dup 632
628 struct S { int n; } s = { { 1 } }; // expected-warning {{braces around scalar initializer}}
631 // dr158 is in its own file.
633 namespace dr159 { // dr159: 3.5
634 namespace X { void f(); }
636 void dr159::f() {} // expected-warning {{extra qualification}}
637 void dr159::X::f() {}
642 namespace dr161 { // dr161: yes
645 struct B { int n; } b; // expected-note 2{{here}}
647 void f(); // expected-note {{here}}
655 C::B b2; // ok, accessible as a member of A
656 (void)&C::b; // expected-error {{protected}}
658 (void)c.b; // expected-error {{protected}}
662 c.f(); // expected-error {{protected}}
673 namespace dr162 { // dr162: no
679 int &a = (&A::f)(0); // FIXME: expected-error {{could not be resolved}}
680 char &b = (&A::f)('0'); // expected-error {{could not be resolved}}
684 int &c = (&A::f)(0); // FIXME: expected-error {{could not be resolved}}
685 char &d = (&A::f)('0'); // expected-error {{could not be resolved}}
690 namespace dr164 { // dr164: yes
692 template <class T> int g(T t) { return f(t); }
700 namespace dr165 { // dr165: no
702 struct A { friend struct B; };
703 void f() { void g(); }
705 // FIXME: dr1477 says this is ok, dr165 says it's ill-formed
707 // FIXME: dr165 says this is ill-formed, but the argument in dr1477 says it's ok
711 namespace dr166 { // dr166: yes
712 namespace A { class X; }
714 template<typename T> int f(T t) { return t.n; }
716 template<typename T> int h(T t) { return t.n; } // expected-error {{private}}
722 friend int dr166::g(X);
725 int n; // expected-note 2{{here}}
728 int h(X x) { return x.n; }
729 int i(X x) { return x.n; }
732 template int f(A::X);
733 int g(A::X x) { return x.n; }
734 template int h(A::X); // expected-note {{instantiation}}
735 int i(A::X x) { return x.n; } // expected-error {{private}}
740 namespace dr168 { // dr168: no
741 extern "C" typedef int (*p)();
742 extern "C++" typedef int (*q)();
746 p a = &S::f; // FIXME: this should fail.
750 namespace dr169 { // dr169: yes
751 template<typename> struct A { int n; };
753 template<typename> struct C;
754 template<typename> void f();
755 template<typename> static int n; // expected-error 0-1{{extension}}
757 struct D : A<int>, B {
759 using B::C<int>; // expected-error {{using declaration cannot refer to a template specialization}}
760 using B::f<int>; // expected-error {{using declaration cannot refer to a template specialization}}
761 using B::n<int>; // expected-error {{using declaration cannot refer to a template specialization}}
765 namespace { // dr171: yes
768 int dr171b; // expected-note {{here}}
770 extern "C" void dr171a();
771 extern "C" void dr171b(); // expected-error {{conflicts}}
774 namespace dr172 { // dr172: yes
776 int check1[-1 < zero ? 1 : -1];
778 enum { x = -1, y = (unsigned int)-1 };
779 int check2[sizeof(x) > sizeof(int) ? 1 : -1];
781 enum { a = (unsigned int)-1 / 2 };
782 int check3a[sizeof(a) == sizeof(int) ? 1 : -1];
783 int check3b[-a < 0 ? 1 : -1];
785 enum { b = (unsigned int)-1 / 2 + 1 };
786 int check4a[sizeof(b) == sizeof(unsigned int) ? 1 : -1];
787 int check4b[-b > 0 ? 1 : -1];
789 enum { c = (unsigned long)-1 / 2 };
790 int check5a[sizeof(c) == sizeof(long) ? 1 : -1];
791 int check5b[-c < 0 ? 1 : -1];
793 enum { d = (unsigned long)-1 / 2 + 1 };
794 int check6a[sizeof(d) == sizeof(unsigned long) ? 1 : -1];
795 int check6b[-d > 0 ? 1 : -1];
797 enum { e = (unsigned long long)-1 / 2 }; // expected-error 0-1{{extension}}
798 int check7a[sizeof(e) == sizeof(long) ? 1 : -1]; // expected-error 0-1{{extension}}
799 int check7b[-e < 0 ? 1 : -1];
801 enum { f = (unsigned long long)-1 / 2 + 1 }; // expected-error 0-1{{extension}}
802 int check8a[sizeof(f) == sizeof(unsigned long) ? 1 : -1]; // expected-error 0-1{{extension}}
803 int check8b[-f > 0 ? 1 : -1];
806 namespace dr173 { // dr173: yes
807 int check[('0' + 1 == '1' && '0' + 2 == '2' && '0' + 3 == '3' &&
808 '0' + 4 == '4' && '0' + 5 == '5' && '0' + 6 == '6' &&
809 '0' + 7 == '7' && '0' + 8 == '8' && '0' + 9 == '9') ? 1 : -1];
814 namespace dr175 { // dr175: yes
815 struct A {}; // expected-note {{here}}
816 struct B : private A {}; // expected-note {{constrained by private inheritance}}
818 A a; // expected-error {{private}}
823 namespace dr176 { // dr176: yes
824 template<typename T> class Y;
825 template<> class Y<int> {
827 typedef Y A; // expected-note {{here}}
828 typedef Y<char> A; // expected-error {{different types ('Y<char>' vs 'Y<int>')}}
832 template<typename T> struct Base {}; // expected-note 2{{found}}
833 template<typename T> struct Derived : public Base<T> {
835 typedef typename Derived::template Base<T> A;
836 typedef typename Derived::Base A;
839 template struct Derived<int>;
841 template<typename T> struct Derived2 : Base<int>, Base<char> {
842 typename Derived2::Base b; // expected-error {{found in multiple base classes}}
843 typename Derived2::Base<double> d;
846 template<typename T> class X { // expected-note {{here}}
850 dr176::X *p4; // expected-error {{requires template arguments}}
854 namespace dr177 { // dr177: yes
857 A(A &); // expected-note 0-1{{not viable: expects an l-value}}
858 A(const B &); // expected-note 0-1{{not viable: no known conversion from 'dr177::A' to}}
862 #if __cplusplus <= 201402L
863 // expected-error@-2 {{no viable constructor copying variable}}
866 struct C { C(C&); }; // expected-note {{not viable: no known conversion from 'dr177::D' to 'dr177::C &'}}
868 struct E { operator D(); };
870 C c = e; // expected-error {{no viable constructor copying variable of type 'dr177::D'}}
873 namespace dr178 { // dr178: yes
874 int check[int() == 0 ? 1 : -1];
875 #if __cplusplus >= 201103L
876 static_assert(int{} == 0, "");
877 struct S { int a, b; };
878 static_assert(S{1}.b == 0, "");
879 struct T { constexpr T() : n() {} int n; };
880 static_assert(T().n == 0, "");
881 struct U : S { constexpr U() : S() {} };
882 static_assert(U().b == 0, "");
886 namespace dr179 { // dr179: yes
888 int n = &f - &f; // expected-error {{arithmetic on pointers to the function type 'void ()'}}
891 namespace dr180 { // dr180: yes
892 template<typename T> struct X : T, T::some_base {
893 X() : T::some_type_that_might_be_T(), T::some_base() {}
894 friend class T::some_class;
901 namespace dr181 { // dr181: yes
903 template <template X<class T> > struct A { }; // expected-error +{{}}
904 template <template X<class T> > void f(A<X>) { } // expected-error +{{}}
908 template <template <class T> class X> struct A { };
909 template <template <class T> class X> void f(A<X>) { }
913 namespace dr182 { // dr182: yes
914 template <class T> struct C {
919 template <class T> void C<T>::f() {}
920 template <class T> void C<T>::g() {}
923 class B {}; // expected-note {{here}}
927 template void C<A::B>::f();
928 template <> void C<A::B>::g(); // expected-error {{private}}
936 namespace dr183 { // dr183: sup 382
937 template<typename T> struct A {};
938 template<typename T> struct B {
941 template<> struct A<int> {
942 #if __cplusplus <= 199711
943 typename B<int>::X x; // expected-error {{'typename' occurs outside of a template}}
945 typename B<int>::X x;
950 namespace dr184 { // dr184: yes
951 template<typename T = float> struct B {};
953 template<template<typename TT = float> class T> struct A {
958 template<template<typename TT> class T> void A<T>::f() { // expected-note {{here}}
959 T<> t; // expected-error {{too few template arguments}}
962 template<template<typename TT = char> class T> void A<T>::g() {
968 void h() { A<B>().g(); }
971 // dr185 FIXME: add codegen test
973 namespace dr187 { // dr187: sup 481
975 template<int X = Z, int Z = X> struct A;
980 namespace dr188 { // dr188: yes
982 int check[sizeof(0, c) == 10 ? 1 : -1];
985 // dr190 FIXME: add codegen test for tbaa
987 // dr193 FIXME: add codegen test
989 namespace dr194 { // dr194: yes
992 void A(); // expected-error {{constructor cannot have a return type}}
995 void B(); // expected-error {{constructor cannot have a return type}}
999 inline explicit C(int) {}
1003 namespace dr195 { // dr195: yes
1005 int *p = (int*)&f; // expected-error 0-1{{extension}}
1006 void (*q)() = (void(*)())&p; // expected-error 0-1{{extension}}
1009 namespace dr197 { // dr197: yes
1012 template <class T> void g(T t) {
1014 char &b = f(T(1)); // expected-error {{unrelated type 'int'}}
1015 char &c = f(t); // expected-error {{unrelated type 'int'}}
1026 g(e); // expected-note {{in instantiation of}}
1030 namespace dr198 { // dr198: yes
1035 #if __cplusplus < 201103L
1036 // expected-error@-2 {{invalid use of non-static data member}}
1038 int f() { return n; }
1039 // expected-error@-1 {{use of non-static data member 'n' of 'A' from nested type 'B'}}
1046 #if __cplusplus < 201103L
1047 // expected-error@-2 {{invalid use of non-static data member}}
1049 int f() { return n; }
1050 // expected-error@-1 {{use of non-static data member 'n' of 'A' from nested type 'C'}}
1054 #if __cplusplus < 201103L
1055 // expected-error@-2 {{invalid use of non-static data member}}
1057 int f() { return n; }
1061 // dr199 FIXME: add codegen test