diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp0x/constexpr-friend.C')
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/constexpr-friend.C | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-friend.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-friend.C new file mode 100644 index 000000000..f1d9ccee7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-friend.C @@ -0,0 +1,23 @@ +// PR c++/48948 +// { dg-options -std=c++0x } + +struct A { A(); }; + +struct B { + friend constexpr int f(B) { return 0; } // OK + friend constexpr int f(A) { return 0; } // { dg-error "constexpr" } +}; + +template <class T> +struct C +{ + friend constexpr int f(C) { return 0; } + friend constexpr int g(C, A) { return 0; } // { dg-error "double" } + constexpr int m(C) { return 0; } + constexpr int m(A) { return 0; } // { dg-error "double" } +}; + +constexpr int i = f(C<int>()); +constexpr int j = C<int>().m(C<int>()); +constexpr int k = C<double>().m(A()); // { dg-error "not a constexpr function" } +constexpr int l = g(C<double>(),A()); // { dg-error "not a constexpr function" } |