instantiate-try-catch.cpp 936 B

12345678910111213141516171819202122232425262728293031
  1. // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -std=c++11 -verify %s
  2. template<typename T> struct TryCatch0 {
  3. void f() {
  4. try {
  5. } catch (T&&) { // expected-error 2{{cannot catch exceptions by rvalue reference}}
  6. }
  7. }
  8. };
  9. template struct TryCatch0<int&>; // okay
  10. template struct TryCatch0<int&&>; // expected-note{{instantiation}}
  11. template struct TryCatch0<int>; // expected-note{{instantiation}}
  12. namespace PR10232 {
  13. template <typename T>
  14. class Templated {
  15. struct Exception {
  16. private:
  17. Exception(const Exception&); // expected-note{{declared private here}}
  18. };
  19. void exception() {
  20. try {
  21. } catch(Exception e) { // expected-error{{calling a private constructor of class 'PR10232::Templated<int>::Exception'}}
  22. }
  23. }
  24. };
  25. template class Templated<int>; // expected-note{{in instantiation of member function 'PR10232::Templated<int>::exception' requested here}}
  26. }