1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -verify -fexceptions -fcxx-exceptions
// This is a test for an egregious hack in Clang that works around
// an issue with GCC's <utility> implementation. std::pair::swap
// has an exception specification that makes an unqualified call to
// swap. This is invalid, because it ends up calling itself with
// the wrong number of arguments.
#ifdef BE_THE_HEADER
#pragma GCC system_header
namespace std {
template<typename T> void swap(T &, T &);
template<typename A, typename B> struct pair {
void swap(pair &other) noexcept(noexcept(swap(*this, other)));
};
}
#else
#define BE_THE_HEADER
#include __FILE__
struct X {};
using PX = std::pair<X, X>;
using PI = std::pair<int, int>;
void swap(PX &, PX &) noexcept;
PX px;
PI pi;
static_assert(noexcept(px.swap(px)), "");
static_assert(!noexcept(pi.swap(pi)), "");
namespace sad {
template<typename T> void swap(T &, T &);
template<typename A, typename B> struct pair {
void swap(pair &other) noexcept(noexcept(swap(*this, other))); // expected-error {{too many arguments}} expected-note {{declared here}}
};
pair<int, int> pi;
static_assert(!noexcept(pi.swap(pi)), ""); // expected-note {{in instantiation of}}
}
#endif
|