xref: /minix3/external/bsd/llvm/dist/clang/test/SemaTemplate/instantiate-try-catch.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -std=c++11 -verify %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc template<typename T> struct TryCatch0 {
fTryCatch04*f4a2713aSLionel Sambuc   void f() {
5*f4a2713aSLionel Sambuc     try {
6*f4a2713aSLionel Sambuc     } catch (T&&) { // expected-error 2{{cannot catch exceptions by rvalue reference}}
7*f4a2713aSLionel Sambuc     }
8*f4a2713aSLionel Sambuc   }
9*f4a2713aSLionel Sambuc };
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc template struct TryCatch0<int&>; // okay
12*f4a2713aSLionel Sambuc template struct TryCatch0<int&&>; // expected-note{{instantiation}}
13*f4a2713aSLionel Sambuc template struct TryCatch0<int>; // expected-note{{instantiation}}
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc namespace PR10232 {
17*f4a2713aSLionel Sambuc   template <typename T>
18*f4a2713aSLionel Sambuc   class Templated {
19*f4a2713aSLionel Sambuc     struct Exception {
20*f4a2713aSLionel Sambuc     private:
21*f4a2713aSLionel Sambuc       Exception(const Exception&); // expected-note{{declared private here}}
22*f4a2713aSLionel Sambuc     };
exception()23*f4a2713aSLionel Sambuc     void exception() {
24*f4a2713aSLionel Sambuc       try {
25*f4a2713aSLionel Sambuc       } catch(Exception e) {  // expected-error{{calling a private constructor of class 'PR10232::Templated<int>::Exception'}}
26*f4a2713aSLionel Sambuc       }
27*f4a2713aSLionel Sambuc     }
28*f4a2713aSLionel Sambuc   };
29*f4a2713aSLionel Sambuc 
30*f4a2713aSLionel Sambuc   template class Templated<int>; // expected-note{{in instantiation of member function 'PR10232::Templated<int>::exception' requested here}}
31*f4a2713aSLionel Sambuc }
32