blob: 2a9dd13adf4ecc2b48e2bd4dd0e7f4744692ef0f [file] [log] [blame]
Richard Smith9ca5c422011-10-13 22:29:44 +00001// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
Andy Gibbsc6e68da2012-10-19 12:44:48 +00002// expected-no-diagnostics
Douglas Gregor205d5e32011-01-31 16:09:46 +00003
4template<typename T>
5struct classify_function {
6 static const unsigned value = 0;
7};
8
9template<typename R, typename ...Args>
10struct classify_function<R(Args...)> {
11 static const unsigned value = 1;
12};
13
14template<typename R, typename ...Args>
Richard Smith63168c72012-02-10 11:05:11 +000015struct classify_function<R(Args...) const> {
Douglas Gregor205d5e32011-01-31 16:09:46 +000016 static const unsigned value = 2;
17};
18
19template<typename R, typename ...Args>
Richard Smith63168c72012-02-10 11:05:11 +000020struct classify_function<R(Args...) volatile> {
Douglas Gregor205d5e32011-01-31 16:09:46 +000021 static const unsigned value = 3;
22};
23
24template<typename R, typename ...Args>
Richard Smith63168c72012-02-10 11:05:11 +000025struct classify_function<R(Args...) const volatile> {
Douglas Gregor205d5e32011-01-31 16:09:46 +000026 static const unsigned value = 4;
27};
28
29template<typename R, typename ...Args>
Richard Smith36ee9fb2014-08-11 23:30:23 +000030struct classify_function<R(Args..., ...)> {
Douglas Gregor205d5e32011-01-31 16:09:46 +000031 static const unsigned value = 5;
32};
33
34template<typename R, typename ...Args>
Richard Smith36ee9fb2014-08-11 23:30:23 +000035struct classify_function<R(Args..., ...) const> {
Douglas Gregor205d5e32011-01-31 16:09:46 +000036 static const unsigned value = 6;
37};
38
39template<typename R, typename ...Args>
Richard Smith36ee9fb2014-08-11 23:30:23 +000040struct classify_function<R(Args..., ...) volatile> {
Douglas Gregor205d5e32011-01-31 16:09:46 +000041 static const unsigned value = 7;
42};
43
44template<typename R, typename ...Args>
Richard Smith36ee9fb2014-08-11 23:30:23 +000045struct classify_function<R(Args..., ...) const volatile> {
Douglas Gregor205d5e32011-01-31 16:09:46 +000046 static const unsigned value = 8;
47};
48
49template<typename R, typename ...Args>
Richard Smith36ee9fb2014-08-11 23:30:23 +000050struct classify_function<R(Args..., ...) &&> {
Douglas Gregor205d5e32011-01-31 16:09:46 +000051 static const unsigned value = 9;
52};
53
54template<typename R, typename ...Args>
Richard Smith36ee9fb2014-08-11 23:30:23 +000055struct classify_function<R(Args..., ...) const &> {
Douglas Gregor205d5e32011-01-31 16:09:46 +000056 static const unsigned value = 10;
57};
58
59typedef void f0(int) const;
60typedef void f1(int, float...) const volatile;
61typedef void f2(int, double, ...) &&;
62typedef void f3(int, double, ...) const &;
63
64int check0[classify_function<f0>::value == 2? 1 : -1];
65int check1[classify_function<f1>::value == 8? 1 : -1];
66int check2[classify_function<f2>::value == 9? 1 : -1];
67int check3[classify_function<f3>::value == 10? 1 : -1];