]> granicus.if.org Git - clang/commitdiff
Don't try to type-check a copy construction of an exception
authorDouglas Gregor <dgregor@apple.com>
Wed, 6 Jul 2011 18:14:43 +0000 (18:14 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 6 Jul 2011 18:14:43 +0000 (18:14 +0000)
declaration with dependent type. Fixes PR10232 /
<rdar://problem/9700653>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134515 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/SemaTemplate/instantiate-try-catch.cpp

index 368fd9259e3b9433e2e609c71ea0e39228ea8971..f4fd20ef7b84a87a8f9706cb491a5cfcd0b0950e 100644 (file)
@@ -8046,7 +8046,7 @@ VarDecl *Sema::BuildExceptionDeclaration(Scope *S,
                                     ExDeclType, TInfo, SC_None, SC_None);
   ExDecl->setExceptionVariable(true);
   
-  if (!Invalid) {
+  if (!Invalid && !ExDeclType->isDependentType()) {
     if (const RecordType *recordType = ExDeclType->getAs<RecordType>()) {
       // C++ [except.handle]p16:
       //   The object declared in an exception-declaration or, if the 
index 1c6c26f2586e3b0b4cd615f293555a5083f859ba..f4ce0e173146e76ae0256d2b098c518adc448f90 100644 (file)
@@ -12,3 +12,20 @@ template struct TryCatch0<int&>; // okay
 template struct TryCatch0<int&&>; // expected-note{{instantiation}}
 template struct TryCatch0<int>; // expected-note{{instantiation}}
 
+
+namespace PR10232 {
+  template <typename T>
+  class Templated {
+    struct Exception {
+    private:
+      Exception(const Exception&); // expected-note{{declared private here}}
+    };
+    void exception() {
+      try {
+      } catch(Exception e) {  // expected-error{{calling a private constructor of class 'PR10232::Templated<int>::Exception'}}
+      }
+    }
+  };
+
+  template class Templated<int>; // expected-note{{in instantiation of member function 'PR10232::Templated<int>::exception' requested here}}
+}