From 750734c6778d9e9e8200bf0676addb77da713ac2 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 6 Jul 2011 18:14:43 +0000 Subject: [PATCH] Don't try to type-check a copy construction of an exception declaration with dependent type. Fixes PR10232 / . llvm-svn: 134515 --- clang/lib/Sema/SemaDeclCXX.cpp | 2 +- .../test/SemaTemplate/instantiate-try-catch.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 368fd9259e3b..f4fd20ef7b84 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -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()) { // C++ [except.handle]p16: // The object declared in an exception-declaration or, if the diff --git a/clang/test/SemaTemplate/instantiate-try-catch.cpp b/clang/test/SemaTemplate/instantiate-try-catch.cpp index 1c6c26f2586e..f4ce0e173146 100644 --- a/clang/test/SemaTemplate/instantiate-try-catch.cpp +++ b/clang/test/SemaTemplate/instantiate-try-catch.cpp @@ -12,3 +12,20 @@ template struct TryCatch0; // okay template struct TryCatch0; // expected-note{{instantiation}} template struct TryCatch0; // expected-note{{instantiation}} + +namespace PR10232 { + template + 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::Exception'}} + } + } + }; + + template class Templated; // expected-note{{in instantiation of member function 'PR10232::Templated::exception' requested here}} +}