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 // FIXME: This is included to avoid a diagnostic with no source location
9 // pointing at the implicit operator new. We can't match such a diagnostic
11 __extension__
typedef __SIZE_TYPE__
size_t;
12 void *operator new(size_t); // expected-error 0-1{{missing exception spec}} expected-note{{candidate}}
13 #if __cplusplus > 201402L
15 enum class align_val_t
: size_t {};
17 void *operator new(size_t, std::align_val_t
); // expected-note{{candidate}}
20 namespace dr500
{ // dr500: dup 372
28 class A::C
: public A::B
{};
29 class D
: public A::B
{};
32 namespace dr501
{ // dr501: yes
36 void (*p
)() = &f
; // expected-error {{undeclared identifier}}
41 namespace dr502
{ // dr502: yes
43 template<typename T
> struct A
{
46 void q2() { Q arr
[sizeof(E
)]; f(arr
); }
47 void q3() { Q arr
[e
]; f(arr
); }
48 void sanity() { Q arr
[1]; f(arr
); } // expected-error {{undeclared identifier 'f'}}
51 template<int N
> int f(Q (&)[N
]);
52 template struct A
<int>;
55 namespace dr505
{ // dr505: yes
56 const char *exts
= "\e\(\{\[\%"; // expected-error 5{{use of non-standard escape}}
57 const char *unknown
= "\Q"; // expected-error {{unknown escape sequence}}
60 namespace dr506
{ // dr506: yes
61 struct NonPod
{ ~NonPod(); };
63 void g(NonPod np
) { f(np
); } // expected-error {{cannot pass}}
66 // FIXME: Add tests here once DR260 is resolved.
73 namespace dr512
{ // dr512: yes
78 #if __cplusplus < 201103L
79 // expected-error@-2 {{has a non-trivial default constructor}}
80 // expected-note@-6 {{no default constructor}}
81 // expected-note@-6 {{suppressed by user-declared constructor}}
87 namespace dr514
{ // dr514: yes
88 namespace A
{ extern int x
, y
; }
92 namespace dr515
{ // dr515: sup 1017
93 // FIXME: dr1017 reverses the wording of dr515, but the current draft has
94 // dr515's wording, with a different fix for dr1017.
97 template<typename T
> struct Y
: T
{
98 int f() { return X::n
; }
103 struct B
{ void f() { int k
= sizeof(A::a
); } };
104 #if __cplusplus < 201103L
105 // expected-error@-2 {{invalid use of non-static data member}}
111 namespace dr517
{ // dr517: no
112 // This is NDR, but we should diagnose it anyway.
113 template<typename T
> struct S
{};
114 template<typename T
> int v
= 0; // expected-error 0-1{{extension}}
116 template struct S
<int*>;
117 template int v
<int*>;
122 // FIXME: These are both ill-formed.
123 template<typename T
> struct S
<T
*> {};
124 template<typename T
> int v
<T
*> = 0; // expected-error 0-1{{extension}}
126 // FIXME: These are both ill-formed.
127 template<typename T
> struct S
<T
&> {};
128 template<typename T
> int v
<T
&> = 0; // expected-error 0-1{{extension}}
131 namespace dr518
{ // dr518: yes c++11
133 #if __cplusplus < 201103L
134 // expected-error@-2 {{C++11 extension}}
138 namespace dr519
{ // dr519: yes
139 // FIXME: Add a codegen test.
140 #if __cplusplus >= 201103L
141 #define fold(x) (__builtin_constant_p(x) ? (x) : (x))
142 int test
[fold((int*)(void*)0) ? -1 : 1];
150 // FIXME: The wording here is broken. It's not reasonable to expect a
151 // diagnostic here. Once the relevant DR gets a number, mark this as a dup.
153 namespace dr522
{ // dr522: yes
155 template<typename T
> void b1(volatile T
&);
156 template<typename T
> void b2(volatile T
* const *);
157 template<typename T
> void b2(volatile T
* const S::*);
158 template<typename T
> void b2(volatile T
* const S::* const *);
159 template<typename T
> void b2a(volatile T
*S::* const *); // expected-note {{candidate template ignored: deduced type 'volatile int *dr522::S::*const *' of 1st parameter does not match adjusted type 'int *dr522::S::**' of argument}}
161 template<typename T
> struct Base
{};
162 struct Derived
: Base
<int> {};
163 template<typename T
> void b3(Base
<T
>);
164 template<typename T
> void b3(Base
<T
> *);
166 void test(int n
, const int cn
, int **p
, int *S::*pm
) {
167 int *a
[3], *S::*am
[3];
168 const Derived cd
= Derived();
177 b2a(am
); // expected-error {{no matching function}}
183 namespace dr524
{ // dr524: yes
184 template<typename T
> void f(T a
, T b
) { operator+(a
, b
); } // expected-error {{call}}
187 void operator+(S
, S
);
188 template void f(S
, S
);
190 namespace N
{ struct S
{}; }
191 void operator+(N::S
, N::S
); // expected-note {{should be declared}}
192 template void f(N::S
, N::S
); // expected-note {{instantiation}}
195 namespace dr525
{ // dr525: yes
197 // Note, the example was correct prior to the change; instantiation is
198 // required for cases like this:
199 template <class T
> struct D
{ operator T
*(); };
200 void g(D
<double> ppp
) {
205 template <class T
> struct D
{ typename
T::error e
; }; // expected-error {{prior to '::'}}
206 void g(D
<double> *ppp
) {
207 delete ppp
; // expected-note {{instantiation of}}
212 namespace dr526
{ // dr526: yes
213 template<int> struct S
{};
214 template<int N
> void f1(S
<N
> s
);
215 template<int N
> void f2(S
<(N
)> s
); // expected-note {{couldn't infer}}
216 template<int N
> void f3(S
<+N
> s
); // expected-note {{couldn't infer}}
217 template<int N
> void g1(int (&)[N
]);
218 template<int N
> void g2(int (&)[(N
)]); // expected-note {{couldn't infer}}
219 template<int N
> void g3(int (&)[+N
]); // expected-note {{couldn't infer}}
221 void test(int (&a
)[3], S
<3> s
) {
223 f2(s
); // expected-error {{no matching}}
224 f3(s
); // expected-error {{no matching}}
226 g2(a
); // expected-error {{no matching}}
227 g3(a
); // expected-error {{no matching}}
230 template<int N
> struct X
{
235 #if __cplusplus <= 201703L
236 // expected-error@-3 {{implicit 'typename' is a C++20 extension}}
237 // expected-error@-3 {{implicit 'typename' is a C++20 extension}}
242 namespace dr527
{ // dr527: na
243 // This DR is meaningless. It removes a required diagnostic from the case
244 // where a not-externally-visible object is odr-used but not defined, which
245 // requires a diagnostic for a different reason.
246 extern struct { int x
; } a
; // FIXME: We should reject this, per dr389.
247 static struct { int x
; } b
;
248 extern "C" struct { int x
; } c
;
249 namespace { extern struct { int x
; } d
; }
250 typedef struct { int x
; } *P
;
251 struct E
{ static P e
; }; // FIXME: We should reject this, per dr389.
252 namespace { struct F
{ static P f
; }; }
254 int ax
= a
.x
, bx
= b
.x
, cx
= c
.x
, dx
= d
.x
, ex
= E::e
->x
, fx
= F::f
->x
;
257 namespace dr530
{ // dr530: yes
258 template<int*> struct S
{ enum { N
= 1 }; };
259 template<void(*)()> struct T
{ enum { N
= 1 }; };
266 namespace dr531
{ // dr531: partial
268 template<typename T
> struct A
{
269 void f(T
) { T::error
; }
270 template<typename U
> void g(T
, U
) { T::error
; }
271 struct B
{ typename
T::error error
; };
272 template<typename U
> struct C
{ typename
T::error error
; };
275 template<typename T
> T A
<T
>::n
= T::error
;
277 template<> void A
<int>::f(int) {}
278 template<> template<typename U
> void A
<int>::g(int, U
) {}
279 template<> struct A
<int>::B
{};
280 template<> template<typename U
> struct A
<int>::C
{};
281 template<> int A
<int>::n
= 0;
290 template<> struct A
<char> {
292 template<typename U
> void g(char, U
);
294 template<typename U
> struct C
;
298 void A
<char>::f(char) {}
299 template<typename U
> void A
<char>::g(char, U
) {}
300 struct A
<char>::B
{};
301 template<typename U
> struct A
<char>::C
{};
306 template<typename T
> struct A
{
307 void f(T
) { T::error
; }
308 template<typename U
> void g(T
, U
) { T::error
; }
309 struct B
{ typename
T::error error
; };
310 template<typename U
> struct C
{ typename
T::error error
; }; // expected-note {{here}}
313 template<typename T
> T A
<T
>::n
= T::error
;
315 void A
<int>::f(int) {} // expected-error {{requires 'template<>'}}
316 template<typename U
> void A
<int>::g(int, U
) {} // expected-error {{should be empty}}
317 struct A
<int>::B
{}; // expected-error {{requires 'template<>'}}
318 template<typename U
> struct A
<int>::C
{}; // expected-error {{should be empty}} expected-error {{different kind of symbol}}
319 int A
<int>::n
= 0; // expected-error {{requires 'template<>'}}
321 template<> struct A
<char> { // expected-note 2{{here}}
323 template<typename U
> void g(char, U
);
324 struct B
; // expected-note {{here}}
325 template<typename U
> struct C
;
329 template<> void A
<char>::f(char) {} // expected-error {{no function template matches}}
330 // FIXME: This is ill-formed; -pedantic-errors should reject.
331 template<> template<typename U
> void A
<char>::g(char, U
) {} // expected-warning {{extraneous template parameter list}}
332 template<> struct A
<char>::B
{}; // expected-error {{extraneous 'template<>'}} expected-error {{does not specialize}}
333 // FIXME: This is ill-formed; -pedantic-errors should reject.
334 template<> template<typename U
> struct A
<char>::C
{}; // expected-warning {{extraneous template parameter list}}
335 template<> char A
<char>::n
= 0; // expected-error {{extraneous 'template<>'}}
339 template<typename T
> struct A
{
340 template<typename U
> struct B
;
342 template<> template<typename U
> struct A
<int>::B
{
345 template<typename V
> void h();
346 template<typename V
> void i();
348 template<> template<typename U
> void A
<int>::B
<U
>::f() {}
349 template<typename U
> void A
<int>::B
<U
>::g() {} // expected-error {{should be empty}}
351 template<> template<typename U
> template<typename V
> void A
<int>::B
<U
>::h() {}
352 template<typename U
> template<typename V
> void A
<int>::B
<U
>::i() {} // expected-error {{should be empty}}
354 #if __cplusplus <= 201703L
355 // FIXME: All of those declarations shouldn't crash in C++20 mode.
356 template<> template<> void A
<int>::B
<int>::f() {}
357 template<> template<> template<typename V
> void A
<int>::B
<int>::h() {}
358 template<> template<> template<> void A
<int>::B
<int>::h
<int>() {}
360 template<> void A
<int>::B
<char>::f() {} // expected-error {{requires 'template<>'}}
361 template<> template<typename V
> void A
<int>::B
<char>::h() {} // expected-error {{should be empty}}
367 namespace dr532
{ // dr532: 3.5
370 template<class T
> struct B
{
371 template<class R
> int &operator*(R
&);
374 template<class T
, class R
> float &operator*(T
&, R
&);
384 namespace dr534
{ // dr534: yes
386 template<typename T
> void operator+(S
, T
);
387 template<typename T
> void operator+<T
*>(S
, T
*) {} // expected-error {{function template partial spec}}
390 namespace dr535
{ // dr535: yes
391 class X
{ private: X(const X
&); };
394 template<typename T
> A(T
&);
402 A
a2(a1
); // ok, uses constructor template
404 extern volatile B b1
;
405 B
b2(b1
); // ok, uses converting constructor
407 void f() { throw a1
; }
409 #if __cplusplus >= 201103L
411 constexpr C() : n(0) {}
412 template<typename T
> constexpr C(T
&t
) : n(t
.n
== 0 ? throw 0 : 0) {}
415 constexpr C
c() { return C(); }
416 // ok, copy is elided
426 const dr539( // expected-error {{a type specifier is required}}
427 const a
) { // expected-error {{unknown type name 'a'}}
428 const b
; // expected-error {{a type specifier is required}}
429 new const; // expected-error {{expected a type}}
430 try {} catch (const n
) {} // expected-error {{unknown type name 'n'}}
431 try {} catch (const) {} // expected-error {{expected a type}}
432 if (const n
= 0) {} // expected-error {{a type specifier is required}}
433 switch (const n
= 0) {} // expected-error {{a type specifier is required}}
434 while (const n
= 0) {} // expected-error {{a type specifier is required}}
435 for (const n
= 0; // expected-error {{a type specifier is required}}
436 const m
= 0; ) {} // expected-error {{a type specifier is required}}
437 sizeof(const); // expected-error {{a type specifier is required}}
439 const n
; // expected-error {{a type specifier is required}}
440 operator const(); // expected-error {{expected a type}}
442 #if __cplusplus >= 201103L
444 // FIXME: The extra braces here are to avoid the parser getting too
445 // badly confused when recovering here. We should fix this recovery.
446 { for (const n
// expected-error {{unknown type name 'n'}} expected-note {{}}
447 : arr
) ; {} } // expected-error +{{}}
448 (void) [](const) {}; // expected-error {{a type specifier is required}}
449 (void) [](const n
) {}; // expected-error {{unknown type name 'n'}}
450 enum E
: const {}; // expected-error {{expected a type}}
451 using T
= const; // expected-error {{expected a type}}
452 auto f() -> const; // expected-error {{expected a type}}
456 namespace dr540
{ // dr540: yes
458 typedef const a
&a
; // expected-warning {{has no effect}}
459 typedef const int &b
;
461 typedef const a
&c
; // expected-note {{previous}} expected-warning {{has no effect}}
462 typedef const b
&c
; // expected-error {{different}} expected-warning {{has no effect}}
465 namespace dr541
{ // dr541: yes
466 template<int> struct X
{ typedef int type
; };
467 template<typename T
> struct S
{
477 // These are type-dependent expressions, even though we could
478 // determine that all calls have type 'int'.
479 X
<sizeof(f(0))>::type a
; // expected-error +{{}}
480 X
<sizeof(g(0))>::type b
; // expected-error +{{}}
481 X
<sizeof(h(0))>::type b
; // expected-error +{{}}
483 typename X
<sizeof(f(0))>::type a
;
484 typename X
<sizeof(h(0))>::type b
;
489 namespace dr542
{ // dr542: yes
490 #if __cplusplus >= 201103L
491 // In C++20 A and B are no longer aggregates and thus the constructor is
492 // called, which fails.
493 struct A
{ A() = delete; int n
; };
494 A a
[32] = {}; // ok, constructor not called
495 #if __cplusplus > 201703L
496 // expected-error@-2 {{call to deleted constructor}}
497 // expected-note@-3 {{in implicit initialization}}
498 // expected-note@-5 {{marked deleted here}}
506 B b
[32] = {}; // ok, constructor not called
507 #if __cplusplus > 201703L
508 // expected-error@-2 {{calling a private constructor}}
509 // expected-note@-5 {{declared private here}}
514 namespace dr543
{ // dr543: yes
515 // In C++98+DR543, this is valid because value-initialization doesn't call a
516 // trivial default constructor, so we never notice that defining the
517 // constructor would be ill-formed.
519 // In C++11+DR543, this is ill-formed, because the default constructor is
520 // deleted, and value-initialization *does* call a deleted default
521 // constructor, even if it is trivial.
526 #if __cplusplus >= 201103L
527 // expected-error@-2 {{deleted}}
528 // expected-note@-5 {{would not be initialized}}
532 namespace dr544
{ // dr544: yes
535 template<class T
> struct A
{ int n
; };
536 template<class T
> struct B
: A
<T
> { int get(); };
537 template<> int B
<int>::get() { return n
; }
538 int k
= B
<int>().get();
541 namespace dr546
{ // dr546: yes
542 template<typename T
> struct A
{ void f(); };
543 template struct A
<int>;
544 template<typename T
> void A
<T
>::f() { T::error
; }
547 namespace dr547
{ // dr547: yes
548 template<typename T
> struct X
;
549 template<typename T
> struct X
<T() const> {};
550 template<typename T
, typename C
> X
<T
> f(T
C::*) { return X
<T
>(); }
552 struct S
{ void f() const; };
553 X
<void() const> x
= f(&S::f
);
556 namespace dr548
{ // dr548: dup 482
557 template<typename T
> struct S
{};
558 template<typename T
> void f() {}
559 template struct dr548::S
<int>;
560 template void dr548::f
<int>();
563 namespace dr551
{ // dr551: yes c++11
564 // FIXME: This obviously should apply in C++98 mode too.
565 template<typename T
> void f() {}
566 template inline void f
<int>();
567 #if __cplusplus >= 201103L
568 // expected-error@-2 {{cannot be 'inline'}}
571 template<typename T
> inline void g() {}
572 template inline void g
<int>();
573 #if __cplusplus >= 201103L
574 // expected-error@-2 {{cannot be 'inline'}}
577 template<typename T
> struct X
{
580 template inline void X
<int>::f();
581 #if __cplusplus >= 201103L
582 // expected-error@-2 {{cannot be 'inline'}}
586 namespace dr552
{ // dr552: yes
587 template<typename T
, typename
T::U
> struct X
{};
588 struct Y
{ typedef int U
; };
593 friend void *operator new(size_t, dr553_class
);
597 // Contrary to the apparent intention of the DR, operator new is not actually
598 // looked up with a lookup mechanism that performs ADL; the standard says it
599 // "is looked up in global scope", where it is not visible.
600 void *p
= new (c
) int; // expected-error {{no matching function}}
602 struct namespace_scope
{
603 friend void *operator new(size_t, namespace_scope
); // expected-error {{cannot be declared inside a namespace}}
610 namespace dr557
{ // dr557: yes
611 template<typename T
> struct S
{
612 friend void f(S
<T
> *);
613 friend void g(S
<S
<T
> > *);
615 void x(S
<int> *p
, S
<S
<int> > *q
) {
621 namespace dr558
{ // dr558: yes
622 wchar_t a
= L
'\uD7FF';
623 wchar_t b
= L
'\xD7FF';
624 wchar_t c
= L
'\uD800'; // expected-error {{invalid universal character}}
625 wchar_t d
= L
'\xD800';
626 wchar_t e
= L
'\uDFFF'; // expected-error {{invalid universal character}}
627 wchar_t f
= L
'\xDFFF';
628 wchar_t g
= L
'\uE000';
629 wchar_t h
= L
'\xE000';
632 template<typename
> struct dr559
{ typedef int T
; dr559::T u
; }; // dr559: yes
634 namespace dr561
{ // dr561: yes
635 template<typename T
> void f(int);
636 template<typename T
> void g(T t
) {
641 template<typename T
> static void f(S
);
650 namespace dr564
{ // dr564: yes
651 extern "C++" void f(int);
653 extern "C++" { extern int n
; }
657 namespace dr565
{ // dr565: yes
659 template<typename T
> int f(T
); // expected-note {{target}}
661 using N::f
; // expected-note {{using}}
662 template<typename T
> int f(T
*);
663 template<typename T
> void f(T
);
664 template<typename T
, int = 0> int f(T
); // expected-error 0-1{{extension}}
665 template<typename T
> int f(T
, int = 0);
666 template<typename T
> int f(T
); // expected-error {{conflicts with}}
669 namespace dr566
{ // dr566: yes
670 #if __cplusplus >= 201103L
671 int check
[int(-3.99) == -3 ? 1 : -1];
677 namespace dr568
{ // dr568: yes c++11
678 // FIXME: This is a DR issue against C++98, so should probably apply there
686 int check_trivial
[__is_trivial(trivial
) ? 1 : -1];
690 std_layout(const std_layout
&);
695 int check_std_layout
[__is_standard_layout(std_layout
) ? 1 : -1];
706 void g(trivial t
) { f(t
); }
707 #if __cplusplus < 201103L
708 // expected-error@-2 {{non-POD}}
713 #if __cplusplus < 201103L
714 // expected-error@-2 {{cannot jump}}
715 // expected-note@+2 {{non-POD}}
722 namespace dr569
{ // dr569: yes c++11
723 // FIXME: This is a DR issue against C++98, so should probably apply there
726 #if __cplusplus < 201103L
727 // expected-error@-2 {{C++11 extension}}
731 namespace dr570
{ // dr570: dup 633
733 int &r
= n
; // expected-note {{previous}}
734 int &r
= n
; // expected-error {{redefinition}}
737 namespace dr571
{ // dr571 unknown
738 // FIXME: Add a codegen test.
741 const ir r
= n
; // expected-warning {{has no effect}} FIXME: Test if this has internal linkage.
744 namespace dr572
{ // dr572: yes
745 enum E
{ a
= 1, b
= 2 };
746 int check
[a
+ b
== 3 ? 1 : -1];
749 namespace dr573
{ // dr573: no
751 int *b
= reinterpret_cast<int*>(a
);
752 void (*c
)() = reinterpret_cast<void(*)()>(a
);
753 void *d
= reinterpret_cast<void*>(c
);
754 #if __cplusplus < 201103L
755 // expected-error@-3 {{extension}}
756 // expected-error@-3 {{extension}}
758 void f() { delete a
; } // expected-error {{cannot delete}}
759 int n
= d
- a
; // expected-error {{arithmetic on pointers to void}}
760 // FIXME: This is ill-formed.
761 template<void*> struct S
;
762 template<int*> struct T
;
765 namespace dr574
{ // dr574: yes
767 A
&operator=(const A
&) const; // expected-note {{different qualifiers}}
770 B
&operator=(const B
&) volatile; // expected-note {{different qualifiers}}
772 #if __cplusplus >= 201103L
774 C
&operator=(const C
&) &; // #574-overload1 \
775 // expected-note {{not viable}} \
776 // expected-note {{here}}
780 D
&operator=(const D
&) &&; // #574-overload2 \
781 // expected-note {{not viable}} \
782 // expected-note {{here}}
784 void test(C c
, D d
) {
786 C() = c
; // expected-error {{no viable}}
787 d
= d
; // expected-error {{no viable}}
792 friend A
&A::operator=(const A
&); // expected-error {{does not match}}
793 friend B
&B::operator=(const B
&); // expected-error {{does not match}}
794 #if __cplusplus >= 202302L
795 friend C
&C::operator=(const C
&); // expected-error {{conflicting types for 'operator='}}
796 friend D
&D::operator=(const D
&); // expected-error {{conflicting types for 'operator='}} __cplusplus >= 201103L
797 #elif __cplusplus >= 201103L
798 // FIXME: We shouldn't produce the 'cannot overload' diagnostics here.
799 friend C
&C::operator=(const C
&); // expected-error {{does not match}} \
800 // expected-error {{cannot overload}} \
801 // expected-note@#574-overload1 {{candidate}}
802 friend D
&D::operator=(const D
&); // expected-error {{does not match}} \
803 // expected-error {{cannot overload}} \
804 // expected-note@#574-overload2 {{candidate}}
809 namespace dr575
{ // dr575: yes
810 template<typename T
, typename U
= typename
T::type
> void a(T
); void a(...); // expected-error 0-1{{extension}}
811 template<typename T
, typename
T::type U
= 0> void b(T
); void b(...); // expected-error 0-1{{extension}}
812 template<typename T
, int U
= T::value
> void c(T
); void c(...); // expected-error 0-1{{extension}}
813 template<typename T
> void d(T
, int = T::value
); void d(...); // expected-error {{cannot be used prior to '::'}}
818 d(0); // expected-note {{in instantiation of default function argument}}
821 template<typename T
= int&> void f(T
* = 0); // expected-error 0-1{{extension}}
822 template<typename T
= int> void f(T
= 0); // expected-error 0-1{{extension}}
825 template<typename T
> T
&h(T
*);
826 template<typename T
> T
*h(T
*);
827 void *p
= h((void*)0);
830 namespace dr576
{ // dr576: yes
831 typedef void f() {} // expected-error {{function definition declared 'typedef'}}
832 void f(typedef int n
); // expected-error {{invalid storage class}}
833 void f(char c
) { typedef int n
; }
836 namespace dr577
{ // dr577: yes
838 typedef const void CV
;
840 void b(const void); // expected-error {{qualifiers}}
842 void d(CV
); // expected-error {{qualifiers}}
844 void (*f
)(const void); // expected-error {{qualifiers}}
846 void (*h
)(CV
); // expected-error {{qualifiers}}
847 template<typename T
> void i(T
); // expected-note 2{{requires 1 arg}}
848 template<typename T
> void j(void (*)(T
)); // expected-note 2{{argument may not have 'void' type}}
852 i
<void>(); // expected-error {{no match}}
853 i
<const void>(); // expected-error {{no match}}
854 j
<void>(0); // expected-error {{no match}}
855 j
<const void>(0); // expected-error {{no match}}
859 namespace dr580
{ // dr580: partial
861 struct A
{ static C c
; };
862 struct B
{ static C c
; };
864 C(); // expected-note {{here}}
865 ~C(); // expected-note {{here}}
867 typedef int I
; // expected-note 2{{here}}
868 template<int> struct X
;
869 template<int> friend struct Y
;
870 template<int> void f();
871 template<int> friend void g();
875 template<C::I
> struct C::X
{};
876 template<C::I
> struct Y
{};
877 template<C::I
> struct Z
{}; // expected-error {{private}}
886 template<X::I
> struct A
{}; // FIXME: We incorrectly accept this
887 // because we think C2::Y::A<...> might
888 // instantiate to C2::X::A
892 template<C::I
> void C::f() {}
893 template<C::I
> void g() {}
894 template<C::I
> void h() {} // expected-error {{private}}
897 C
B::c
; // expected-error 2{{private}}
902 namespace dr583
{ // dr583: 4
905 bool b1
= p
< 0; // expected-error {{ordered comparison between pointer and zero}}
906 bool b2
= p
> 0; // expected-error {{ordered comparison between pointer and zero}}
907 bool b3
= p
<= 0; // expected-error {{ordered comparison between pointer and zero}}
908 bool b4
= p
>= 0; // expected-error {{ordered comparison between pointer and zero}}
913 namespace dr585
{ // dr585: yes
914 template<typename
> struct T
;
917 #if __cplusplus <= 201402L
918 // expected-error@-2 {{a type specifier is required}} expected-error@-2 {{can only be classes or functions}}
920 // expected-error@-4 {{use of class template 'T' requires template arguments; argument deduction not allowed in friend declaration}}
921 // expected-note@-7 {{here}}
923 // FIXME: It's not clear whether the standard allows this or what it means,
924 // but the DR585 writeup suggests it as an alternative.
925 template<typename U
> friend T
<U
>; // expected-error {{must use an elaborated type}}
927 template<template<typename
> class T
> struct B
{
929 #if __cplusplus <= 201402L
930 // expected-error@-2 {{a type specifier is required}} expected-error@-2 {{can only be classes or functions}}
932 // expected-error@-4 {{use of template template parameter 'T' requires template arguments; argument deduction not allowed in friend declaration}}
933 // expected-note@-6 {{here}}
935 template<typename U
> friend T
<U
>; // expected-error {{must use an elaborated type}}
941 namespace dr587
{ // dr587: yes
942 template<typename T
> void f(bool b
, const T x
, T y
) {
943 const T
*p
= &(b
? x
: y
);
946 template void f(bool, const int, int);
947 template void f(bool, const S
, S
);
950 namespace dr588
{ // dr588: yes
951 struct A
{ int n
; }; // expected-note {{ambiguous}}
952 template<typename T
> int f() {
953 struct S
: A
, T
{ int f() { return n
; } } s
;
955 int b
= s
.n
; // expected-error {{found in multiple}}
957 struct B
{ int n
; }; // expected-note {{ambiguous}}
958 int k
= f
<B
>(); // expected-note {{here}}
961 namespace dr589
{ // dr589: yes
967 const B
*p
= &(a
? f() : b
); // expected-error {{temporary}}
968 const B
*q
= &(a
? D() : b
); // expected-error {{temporary}}
971 namespace dr590
{ // dr590: yes
972 template<typename T
> struct A
{
975 A
<T
>::B::C
f(A
<T
>::B::C
); // ok, no 'typename' required.
979 template<typename T
> typename A
<T
>::B::C A
<T
>::B::C::f(A
<T
>::B::C
) {}
982 namespace dr591
{ // dr591: no
983 template<typename T
> struct A
{
991 template<typename T
> struct A
<T
>::B::C
: A
<T
> {
992 // FIXME: Should find member of non-dependent base class A<T>.
993 M m
; // expected-error {{incomplete type 'M' (aka 'void'}}
998 // dr593 needs an IRGen test.
1001 namespace dr595
{ // dr595: dup 1330
1002 template<class T
> struct X
{
1003 void f() throw(T
) {}
1004 #if __cplusplus > 201402L
1005 // expected-error@-2 {{ISO C++17 does not allow}} expected-note@-2 {{use 'noexcept}}
1015 namespace dr598
{ // dr598: yes
1019 // Not found by ADL.
1020 void g(void (*)(int));
1021 void h(void (*)(int));
1025 int &h(void (*)(S
));
1030 int &g(void(*)(char));
1032 int &s
= h(N::f
); // expected-error {{undeclared}}
1036 namespace dr599
{ // dr599: partial
1038 struct S
{ operator void*(); };
1039 struct T
{ operator Fn
*(); };
1040 struct U
{ operator int*(); operator void*(); }; // expected-note 2{{conversion}}
1041 struct V
{ operator int*(); operator Fn
*(); };
1042 void f(void *p
, void (*q
)(), S s
, T t
, U u
, V v
) {
1043 delete p
; // expected-error {{cannot delete}}
1044 delete q
; // expected-error {{cannot delete}}
1045 delete s
; // expected-error {{cannot delete}}
1046 delete t
; // expected-error {{cannot delete}}
1047 // FIXME: This is valid, but is rejected due to a non-conforming GNU
1048 // extension allowing deletion of pointers to void.
1049 delete u
; // expected-error {{ambiguous}}