1 // RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
2 // RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
3 // RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
4 // RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
6 // FIXME: __SIZE_TYPE__ expands to 'long long' on some targets.
7 __extension__ typedef __SIZE_TYPE__ size_t;
9 namespace std { struct type_info; }
11 namespace dr400 { // dr400: yes
12 struct A { int a; struct a {}; }; // expected-note 2{{conflicting}} expected-note {{ambiguous}}
13 struct B { int a; struct a {}; }; // expected-note 2{{target}} expected-note {{ambiguous}}
14 struct C : A, B { using A::a; struct a b; };
15 struct D : A, B { using A::a; using B::a; struct a b; }; // expected-error 2{{conflicts}}
16 struct E : A, B { struct a b; }; // expected-error {{found in multiple base classes}}
19 namespace dr401 { // dr401: yes
20 template<class T, class U = typename T::type> class A : public T {}; // expected-error {{protected}} expected-error 2{{private}}
24 typedef int type; // expected-note {{protected}}
28 typedef int type; // expected-note {{private}}
29 friend class A<C>; // expected-note {{default argument}}
33 typedef int type; // expected-note {{private}}
34 friend class A<D, int>;
37 A<B> *b; // expected-note {{default argument}}
38 // FIXME: We're missing the "in instantiation of" note for the default
43 template<class T, class U = typename T::type> class A : public T {};
49 E::A<F> eaf; // ok, default argument is in befriended context
51 // FIXME: Why do we get different diagnostics in C++11 onwards here? We seem
52 // to not treat the default template argument as a SFINAE context in C++98.
53 template<class T, class U = typename T::type> void f(T) {}
55 #if __cplusplus < 201103L
56 // expected-error@-3 0-1{{extension}} expected-error@-3 {{protected}} expected-note@-3 {{instantiation}}
57 // expected-note@-3 {{substituting}}
59 // expected-error@-5 {{no matching}} expected-note@-6 {{protected}}
63 namespace dr403 { // dr403: yes
68 template<typename T> struct X {};
69 typedef struct X<A::S>::X XS;
71 int k = f(p); // ok, finds A::f, even though type XS is a typedef-name
72 // referring to an elaborated-type-specifier naming a
73 // injected-class-name, which is about as far from a
74 // template-id as we can make it.
80 namespace dr406 { // dr406: yes
82 static int n; // expected-error {{static data member 'n' not allowed in anonymous struct}}
86 namespace dr407 { // dr407: no
92 typedef struct S S; // expected-note {{here}}
93 struct S *p; // expected-error {{refers to a typedef}}
100 struct S {}; // expected-note {{found}}
103 typedef int S; // expected-note {{found}}
108 struct S s; // expected-error {{ambiguous}}
111 // FIXME: This is valid.
113 typedef struct S S; // expected-note {{here}}
114 struct S s; // expected-error {{refers to a typedef}}
117 // FIXME: The standard doesn't say whether this is valid.
123 typedef A::S S; // expected-note {{here}}
125 // FIXME: The standard doesn't say what to do in these cases, but
126 // our behavior should not depend on the order of the using-directives.
135 struct S s; // expected-error {{refers to a typedef}}
140 namespace dr408 { // dr408: 3.4
141 template<int N> void g() { int arr[N != 1 ? 1 : -1]; }
142 template<> void g<2>() { }
144 template<typename T> struct S {
148 template<typename T> int S<T>::i[] = { 1 };
150 template<typename T> void S<T>::f() {
151 g<sizeof (i) / sizeof (int)>();
153 template<> int S<int>::i[] = { 1, 2 };
154 template void S<int>::f(); // uses g<2>(), not g<1>().
157 template<typename T> struct R {
161 template<typename T> int R<T>::arr[1];
162 template<typename T> void R<T>::f() {
163 int arr[sizeof(arr) != sizeof(int) ? 1 : -1];
165 template<> int R<int>::arr[2];
166 template void R<int>::f();
169 namespace dr409 { // dr409: yes
170 template<typename T> struct A {
175 A<T*>::B b4; // expected-error {{missing 'typename'}}
179 namespace dr410 { // dr410: no
180 template<class T> void f(T);
183 template<class T> void h(T);
184 template<class T> void i(T);
186 friend void f<>(int);
187 friend void h<>(int);
189 template<class T> void i(T);
190 friend void i<>(int);
192 static void z(); // expected-note {{private}}
195 template<> void h(int) { A::z(); }
196 // FIXME: This should be ill-formed. The member A::i<> is befriended,
197 // not this function.
198 template<> void i(int) { A::z(); }
200 template<> void f(int) { M::A::z(); }
201 void g(int) { M::A::z(); } // expected-error {{private}}
204 // dr412 is in its own file.
206 namespace dr413 { // dr413: yes
212 S s = { 1, 2, 3 }; // expected-error {{excess elements}}
215 struct T { // expected-note {{here}}
221 T t2 = { 1, 2 }; // expected-error {{aggregate with no elements requires explicit braces}}
224 namespace dr414 { // dr414: dup 305
233 namespace dr415 { // dr415: yes
234 template<typename T> void f(T, ...) { T::error; }
236 void g() { f(0, 0); } // ok
239 namespace dr416 { // dr416: yes
241 int &operator+(const A&, const A&);
243 struct A { float &operator+(A&); };
247 namespace dr417 { // dr417: no
249 struct dr417::A {}; // expected-warning {{extra qualification}}
250 struct B { struct X; };
252 struct C::X {}; // expected-error {{no struct named 'X' in 'dr417::C'}}
253 struct B::X { struct Y; };
254 struct C::X::Y {}; // ok!
261 // FIXME: This is ill-formed.
263 struct dr417::D {}; // expected-warning {{extra qualification}}
265 struct dr417::E {}; // expected-warning {{extra qualification}} expected-error {{no struct named 'E'}}
270 struct dr417::G {}; // expected-error {{namespace 'M' does not enclose}}
271 struct dr417::H {}; // expected-error {{namespace 'M' does not enclose}}
275 namespace dr420 { // dr420: yes
276 template<typename T> struct ptr {
277 T *operator->() const;
278 T &operator*() const;
280 template<typename T, typename P> void test(P p) {
287 template void test<int>(int*);
288 template void test<int>(ptr<int>);
289 template void test<X>(X*);
290 template void test<X>(ptr<X>);
294 p->template Y<int>::~Y<int>();
296 // FIXME: This is ill-formed, but this diagnostic is terrible. We should
297 // reject this in the parser.
298 p->template ~Y<int>(); // expected-error 2{{no member named '~typename Y<int>'}}
300 template<typename T> struct Y {};
301 template void test2(Y<int>*); // expected-note {{instantiation}}
302 template void test2(ptr<Y<int> >); // expected-note {{instantiation}}
304 void test3(int *p, ptr<int> q) {
312 #if __cplusplus >= 201103L
313 template<typename T> using id = T;
314 struct A { template<typename T> using id = T; };
315 void test4(int *p, ptr<int> q) {
318 p->id<int>::~id<int>();
319 q->id<int>::~id<int>();
320 p->template id<int>::~id<int>(); // expected-error {{expected unqualified-id}}
321 q->template id<int>::~id<int>(); // expected-error {{expected unqualified-id}}
322 p->A::template id<int>::~id<int>();
323 q->A::template id<int>::~id<int>();
328 namespace dr421 { // dr421: yes
329 struct X { X(); int n; int &r; };
330 int *p = &X().n; // expected-error {{taking the address of a temporary}}
334 namespace dr422 { // dr422: yes
335 template<typename T, typename U> void f() {
336 typedef T type; // expected-note {{prev}}
337 typedef U type; // expected-error {{redef}}
339 template void f<int, int>();
340 template void f<int, char>(); // expected-note {{instantiation}}
343 namespace dr423 { // dr423: yes
344 template<typename T> struct X { operator T&(); };
345 void f(X<int> x) { x += 1; }
348 namespace dr424 { // dr424: yes
350 typedef int N; // expected-note {{previous}}
351 typedef int N; // expected-error {{redefinition}}
354 typedef X X; // expected-note {{previous}}
361 typedef X X; // expected-error {{redefinition}}
367 typedef int N; // expected-note {{previous}}
368 typedef int N; // expected-error {{redefinition}}
372 namespace dr425 { // dr425: yes
373 struct A { template<typename T> operator T() const; } a;
374 float f = 1.0f * a; // expected-error {{ambiguous}} expected-note 5+{{built-in candidate}}
376 template<typename T> struct is_float;
377 template<> struct is_float<float> { typedef void type; };
380 template<typename T, typename U = typename is_float<T>::type> operator T() const; // expected-error 0-1{{extension}}
382 float g = 1.0f * b; // ok
385 namespace dr427 { // dr427: yes
387 struct D : public B {
388 D(B &) = delete; // expected-error 0-1{{extension}} expected-note {{deleted}}
393 const D &d2 = static_cast<const D&>(b);
394 const D &d3 = (const D&)b;
395 const D &d4(b); // expected-error {{deleted}}
398 namespace dr428 { // dr428: yes
399 template<typename T> T make();
400 extern struct X x; // expected-note 5{{forward declaration}}
402 throw void(); // expected-error {{cannot throw}}
404 throw make<const volatile void*>();
405 throw x; // expected-error {{cannot throw}}
406 throw make<X&>(); // expected-error {{cannot throw}}
407 throw make<X*>(); // expected-error {{cannot throw}}
408 throw make<const volatile X&>(); // expected-error {{cannot throw}}
409 throw make<const volatile X*>(); // expected-error {{cannot throw}}
413 namespace dr429 { // dr429: yes c++11
414 // FIXME: This rule is obviously intended to apply to C++98 as well.
416 static void *operator new(size_t, size_t);
417 static void operator delete(void*, size_t);
419 #if __cplusplus >= 201103L
420 // expected-error@-2 {{'new' expression with placement arguments refers to non-placement 'operator delete'}}
421 // expected-note@-4 {{here}}
424 static void *operator new(size_t, size_t);
425 static void operator delete(void*);
426 static void operator delete(void*, size_t);
427 } *b = new (0) B; // ok, second delete is not a non-placement deallocation function
430 namespace dr430 { // dr430: yes c++11
432 // FIXME: This should apply in C++98 too.
434 int a[] = { n++, n++, n++ };
435 #if __cplusplus < 201103L
436 // expected-warning@-2 {{multiple unsequenced modifications to 'n'}}
441 namespace dr431 { // dr431: yes
443 template<typename T> T *get();
444 template<typename T> struct B {
445 template<typename U> U *get();
449 template<typename T> void f(A a) {
450 a.get<A>()->get<T>();
452 ->get<T>(); // expected-error {{use 'template'}}
453 a.get<T>()->template get<T>();
455 A::B<int> *b = a.get<A::B<int> >();
457 b->A::B<int>::get<int>();
458 b->A::B<int>::get<T>();
459 b->A::B<T>::get<int>(); // expected-error {{use 'template'}}
460 b->A::B<T>::template get<int>();
461 b->A::B<T>::get<T>(); // expected-error {{use 'template'}}
462 b->A::B<T>::template get<T>();
463 A::B<T> *c = a.get<A::B<T> >();
464 c->get<int>(); // expected-error {{use 'template'}}
465 c->template get<int>();
469 namespace dr432 { // dr432: yes
470 template<typename T> struct A {};
471 template<typename T> struct B : A<B> {}; // expected-error {{requires template arguments}} expected-note {{declared}}
472 template<typename T> struct C : A<C<T> > {};
473 #if __cplusplus >= 201103L
474 template<typename T> struct D : decltype(A<D>()) {}; // expected-error {{requires template arguments}} expected-note {{declared}}
478 namespace dr433 { // dr433: yes
479 template<class T> struct S {
483 template<class T> void S<T>::f(union U*) {}
488 namespace dr434 { // dr434: yes
492 const int *&rpci = pi; // expected-error {{cannot bind}}
500 namespace dr436 { // dr436: yes
501 enum E { f }; // expected-note {{previous}}
502 void f(); // expected-error {{redefinition}}
505 namespace dr437 { // dr437: sup 1308
506 // This is superseded by 1308, which is in turn superseded by 1330,
507 // which restores this rule.
508 template<typename U> struct T : U {};
511 void g() throw(T<S>);
518 // dr438 FIXME write a codegen test
519 // dr439 FIXME write a codegen test
520 // dr441 FIXME write a codegen test
524 namespace dr444 { // dr444: yes
526 struct B { // expected-note {{candidate is the implicit copy}} expected-note 0-1 {{implicit move}}
527 D &operator=(D &) = delete; // expected-error 0-1{{extension}} expected-note {{deleted}}
529 struct D : B { // expected-note {{candidate is the implicit}} expected-note 0-1 {{implicit move}}
533 d = d; // expected-error {{deleted}}
537 namespace dr445 { // dr445: yes
538 class A { void f(); }; // expected-note {{private}}
540 friend void A::f(); // expected-error {{private}}
544 namespace dr446 { // dr446: yes
548 A(const A&) = delete; // expected-error 0-1{{extension}} expected-note +{{deleted}}
552 void f(A a, bool b, C c) {
554 b ? A() : a; // expected-error {{deleted}}
555 b ? a : A(); // expected-error {{deleted}}
556 b ? A() : A(); // expected-error {{deleted}}
559 b ? a : C(); // expected-error {{deleted}}
560 b ? c : A(); // expected-error {{deleted}}
561 b ? A() : C(); // expected-error {{deleted}}
565 namespace dr447 { // dr447: yes
566 struct A { int n; int a[4]; };
567 template<int> struct U {
569 template<typename V> static void h();
571 template<typename T> U<sizeof(T)> g(T);
572 template<typename T, int N> void f(int n) {
573 // ok, not type dependent
574 g(__builtin_offsetof(A, n)).h<int>();
575 g(__builtin_offsetof(T, n)).h<int>();
576 // value dependent if first argument is a dependent type
577 U<__builtin_offsetof(A, n)>::type a;
578 U<__builtin_offsetof(T, n)>::type b; // expected-error +{{}} expected-warning 0+{{}}
579 // as an extension, we allow the member-designator to include array indices
580 g(__builtin_offsetof(A, a[0])).h<int>(); // expected-error {{extension}}
581 g(__builtin_offsetof(A, a[N])).h<int>(); // expected-error {{extension}}
582 U<__builtin_offsetof(A, a[0])>::type c; // expected-error {{extension}}
583 U<__builtin_offsetof(A, a[N])>::type d; // expected-error {{extension}} expected-error +{{}} expected-warning 0+{{}}
587 namespace dr448 { // dr448: yes
588 template<typename T = int> void f(int); // expected-error 0-1{{extension}} expected-note {{no known conversion}}
589 template<typename T> void g(T t) {
590 f<T>(t); // expected-error {{neither visible in the template definition nor found by argument-dependent lookup}}
591 dr448::f(t); // expected-error {{no matching function}}
593 template<typename T> void f(T); // expected-note {{should be declared prior to the call site}}
594 namespace HideFromADL { struct X {}; }
595 template void g(int); // ok
596 template void g(HideFromADL::X); // expected-note {{instantiation of}}
601 namespace dr450 { // dr450: yes
604 void f2(A &); // expected-note +{{not viable}}
608 f2(S().n); // expected-error {{no match}}}
610 #if __cplusplus >= 201103L
613 f2(A{}); // expected-error {{no match}}
618 namespace dr451 { // dr451: yes
619 const int a = 1 / 0; // expected-warning {{undefined}}
620 const int b = 1 / 0; // expected-warning {{undefined}}
621 int arr[b]; // expected-error +{{variable length arr}}
624 namespace dr452 { // dr452: yes
629 A() : a(f()), b(this->f() + a), c(this->a), p(this) {}
633 // dr454 FIXME write a codegen test
635 namespace dr456 { // dr456: yes
639 #if __cplusplus >= 201103L
640 // expected-error@-2 {{cannot initialize}}
642 // expected-warning@-4 {{null}}
645 const bool f = false;
647 #if __cplusplus >= 201103L
648 // expected-error@-2 {{cannot initialize}}
650 // expected-warning@-4 {{null}}
654 namespace dr457 { // dr457: yes
656 const volatile int b = 1;
658 int bx[b]; // expected-error +{{variable length array}}
662 eb = b // expected-error {{not an integral constant}} expected-note {{read of volatile-qualified}}
666 namespace dr458 { // dr458: no
670 template<typename> int g();
673 template<typename> struct B : A {
675 template<typename> int g();
676 template<typename> int h();
684 return T; // FIXME: this is invalid, it finds the template parameter
691 template<typename T> template<typename U>
695 template<typename U> template<typename T>
697 return T; // FIXME: this is invalid, it finds the template parameter
701 namespace dr460 { // dr460: yes
702 namespace X { namespace Q { int n; } }
704 using X; // expected-error {{requires a qualified name}}
705 using dr460::X; // expected-error {{cannot refer to namespace}}
706 using X::Q; // expected-error {{cannot refer to namespace}}
711 // dr462 FIXME write a codegen test
716 namespace dr466 { // dr466: no
718 typedef const int CI;
719 typedef volatile int VI;
720 void f(int *a, CI *b, VI *c) {
728 a->CI::~VI(); // FIXME: This is invalid; CI and VI are not the same scalar type.
746 namespace dr467 { // dr467: yes
753 static int k = stuff();
759 goto later; // expected-error {{cannot jump}}
760 int k = stuff(); // expected-note {{bypasses variable initialization}}
766 namespace dr468 { // dr468: yes c++11
767 // FIXME: Should we allow this in C++98 too?
768 template<typename> struct A {
769 template<typename> struct B {
773 int k = dr468::template A<int>::template B<char>::C;
774 #if __cplusplus < 201103L
775 // expected-error@-2 2{{'template' keyword outside of a template}}
779 namespace dr469 { // dr469: no
780 // FIXME: The core issue here didn't really answer the question. We don't
781 // deduce 'const T' from a function or reference type in a class template...
782 template<typename T> struct X; // expected-note 2{{here}}
783 template<typename T> struct X<const T> {};
784 X<int&> x; // expected-error {{undefined}}
785 X<int()> y; // expected-error {{undefined}}
787 // ... but we do in a function template. GCC and EDG fail deduction of 'f'
788 // and the second 'h'.
789 template<typename T> void f(const T *);
790 template<typename T> void g(T *, const T * = 0);
791 template<typename T> void h(T *) { T::error; }
792 template<typename T> void h(const T *);
800 namespace dr470 { // dr470: yes
801 template<typename T> struct A {
804 template<typename T> struct C {
807 template struct A<int>; // expected-note {{previous}}
808 template struct A<int>::B; // expected-error {{duplicate explicit instantiation}}
810 // ok, instantiating C<char> doesn't instantiate base class members.
811 template struct A<char>;
812 template struct C<char>;
815 namespace dr471 { // dr471: yes
817 struct B : private virtual A {};
818 struct C : protected virtual A {};
819 struct D : B, C { int f() { return n; } };
820 struct E : private virtual A {
823 struct F : E, B { int f() { return n; } };
824 struct G : virtual A {
826 using A::n; // expected-note {{here}}
828 struct H : B, G { int f() { return n; } }; // expected-error {{private}}
831 namespace dr474 { // dr474: yes
838 void g(); // expected-note {{previous}}
842 int g(); // expected-error {{cannot be overloaded}}
846 // dr475 FIXME write a codegen test
848 namespace dr477 { // dr477: 3.5
854 friend explicit A::A(); // expected-error {{'explicit' is invalid in friend declarations}}
855 friend virtual void A::f(); // expected-error {{'virtual' is invalid in friend declarations}}
857 explicit A::A() {} // expected-error {{can only be specified inside the class definition}}
858 virtual void A::f() {} // expected-error {{can only be specified inside the class definition}}
861 namespace dr478 { // dr478: yes
862 struct A { virtual void f() = 0; }; // expected-note {{unimplemented}}
864 void f(A a[10]); // expected-error {{array of abstract class type}}
867 namespace dr479 { // dr479: yes
871 S(const S&); // expected-note +{{here}}
872 ~S(); // expected-note +{{here}}
876 // expected-error@-1 {{temporary of type 'dr479::S' has private destructor}}
877 // expected-error@-2 {{calling a private constructor}}
878 // expected-error@-3 {{exception object of type 'dr479::S' has private destructor}}
879 #if __cplusplus < 201103L
880 // expected-error@-5 {{C++98 requires an accessible copy constructor}}
884 S s; // expected-error {{private destructor}}}
886 // expected-error@-1 {{calling a private constructor}}
887 // expected-error@-2 {{exception object of type 'dr479::S' has private destructor}}
894 // expected-error@-1 {{calling a private constructor}}
895 // expected-error@-2 {{variable of type 'dr479::S' has private destructor}}
900 namespace dr480 { // dr480: yes
903 struct C : virtual B {};
907 int D::*b = a; // expected-error {{virtual base}}
910 int A::*d = static_cast<int A::*>(c); // expected-error {{virtual base}}
914 D *g = static_cast<D*>(f); // expected-error {{virtual base}}
918 D &k = static_cast<D&>(j); // expected-error {{virtual base}}
921 namespace dr481 { // dr481: yes
922 template<class T, T U> class A { T *x; };
923 T *x; // expected-error {{unknown type}}
925 template<class T *U> class B { T *x; };
929 template<class T> void f(class D *p);
933 template<typename A = C, typename C = A> struct E {
935 typedef ::dr481::C c; // expected-note {{previous}}
936 typedef C c; // expected-error {{different type}}
939 template struct E<>; // ok
940 template struct E<int>; // expected-note {{instantiation of}}
942 template<template<typename U_no_typo_correction> class A,
944 U_no_typo_correction *C> // expected-error {{unknown type}}
946 U_no_typo_correction *x; // expected-error {{unknown type}}
949 template<template<class H *> class> struct G {
955 template<N X, typename N, template<N Y> class T> struct I;
956 template<char*> struct J;
960 namespace dr482 { // dr482: 3.5
964 int dr482::a = 0; // expected-warning {{extra qualification}}
965 void dr482::f() {} // expected-warning {{extra qualification}}
967 inline namespace X { // expected-error 0-1{{C++11 feature}}
972 int dr482::b = 0; // expected-warning {{extra qualification}}
973 void dr482::g() {} // expected-warning {{extra qualification}}
974 struct dr482::S {}; // expected-warning {{extra qualification}}
976 void dr482::f(); // expected-warning {{extra qualification}}
977 void dr482::g(); // expected-warning {{extra qualification}}
979 // FIXME: The following are valid in DR482's wording, but these are bugs in
980 // the wording which we deliberately don't implement.
981 namespace N { typedef int type; }
982 typedef int N::type; // expected-error {{typedef declarator cannot be qualified}}
985 struct A::B {}; // expected-error {{extra qualification}}
987 #if __cplusplus >= 201103L
989 enum class A::C {}; // expected-error {{extra qualification}}
994 namespace dr483 { // dr483: yes
996 int check1[__SCHAR_MAX__ >= 127 ? 1 : -1];
997 int check2[__SHRT_MAX__ >= 32767 ? 1 : -1];
998 int check3[__INT_MAX__ >= 32767 ? 1 : -1];
999 int check4[__LONG_MAX__ >= 2147483647 ? 1 : -1];
1000 int check5[__LONG_LONG_MAX__ >= 9223372036854775807 ? 1 : -1];
1001 #if __cplusplus < 201103L
1002 // expected-error@-2 {{extension}}
1006 int check1[__PTRDIFF_WIDTH__ >= 16 ? 1 : -1];
1007 int check2[__SIG_ATOMIC_WIDTH__ >= 8 ? 1 : -1];
1008 int check3[__SIZE_WIDTH__ >= 16 ? 1 : -1];
1009 int check4[__WCHAR_WIDTH__ >= 8 ? 1 : -1];
1010 int check5[__WINT_WIDTH__ >= 16 ? 1 : -1];
1014 namespace dr484 { // dr484: yes
1029 void f() { return CA::f(); }
1033 typedef C CT; // expected-note {{here}}
1034 struct CT {}; // expected-error {{conflicts with typedef}}
1038 typedef D DT; // expected-note {{here}}
1040 struct N::DT {}; // expected-error {{conflicts with typedef}}
1043 S(); // expected-error {{requires a type}}
1047 namespace dr485 { // dr485: yes
1050 int operator+(S, S);
1051 template<typename T> int f(S);
1053 template<typename T> int f();
1056 int a = operator+(s, s);
1060 namespace dr486 { // dr486: yes
1061 template<typename T> T f(T *); // expected-note 2{{substitution failure}}
1070 f<void()>(&g); // expected-error {{no match}}
1071 f<int[10]>(&n); // expected-error {{no match}}
1075 namespace dr487 { // dr487: yes
1077 int operator+(int, E);
1078 int i[4 + e]; // expected-error 2{{variable length array}}
1081 namespace dr488 { // dr488: yes c++11
1082 template <typename T> void f(T);
1085 // FIXME: It seems CWG thought this should be a SFINAE failure prior to
1086 // allowing local types as template arguments. In C++98, we should either
1087 // allow local types as template arguments or treat this as a SFINAE
1091 #if __cplusplus < 201103L
1092 // expected-error@-2 {{local type}}
1099 namespace dr490 { // dr490: yes
1100 template<typename T> struct X {};
1104 struct K {}; // expected-note {{declared}}
1109 int X<T>::*i(); // expected-note {{previous}}
1112 template<typename T> T k();
1122 friend int A::h(X<T>);
1124 // FIXME: Per this DR, these two are valid! That is another defect
1125 // (no number yet...) which will eventually supersede this one.
1126 friend int X<T>::*A::i(); // expected-error {{return type}}
1127 friend int K::*A::j(); // expected-error {{undeclared identifier 'K'; did you mean 'A::K'?}}
1129 // ok, lookup finds B::T, not A::T, so return type matches
1130 friend char A::k<T>();
1131 friend int A::k<U>();
1133 // A conversion-type-id in a conversion-function-id is always looked up in
1134 // the class of the conversion function first.
1135 friend A::operator X<T>();
1139 namespace dr491 { // dr491: dup 413
1140 struct A {} a, b[3] = { a, {} };
1141 A c[2] = { a, {}, b[1] }; // expected-error {{excess elements}}
1144 // dr492 FIXME write a codegen test
1146 namespace dr493 { // dr493: dup 976
1148 template <class T> operator const T &() const;
1156 namespace dr494 { // dr494: dup 372
1169 namespace dr495 { // dr495: 3.5
1170 template<typename T>
1172 operator int() { return T::error; }
1173 template<typename U> operator U();
1178 template<typename T>
1180 template<typename U> operator U();
1181 operator int() { return T::error; }
1187 namespace dr496 { // dr496: no
1188 struct A { int n; };
1189 struct B { volatile int n; };
1190 int check1[ __is_trivially_copyable(const int) ? 1 : -1];
1191 int check2[!__is_trivially_copyable(volatile int) ? 1 : -1];
1192 int check3[ __is_trivially_constructible(A, const A&) ? 1 : -1];
1193 // FIXME: This is wrong.
1194 int check4[ __is_trivially_constructible(B, const B&) ? 1 : -1];
1195 int check5[ __is_trivially_assignable(A, const A&) ? 1 : -1];
1196 // FIXME: This is wrong.
1197 int check6[ __is_trivially_assignable(B, const B&) ? 1 : -1];
1200 namespace dr497 { // dr497: yes
1205 const S cs; // expected-error {{default initialization}} expected-note {{add an explicit initializer}}
1217 cs.*pm = 88; // expected-error {{not assignable}}
1221 namespace dr499 { // dr499: yes
1223 void f() { throw str; }