Index: lib/Sema/SemaTemplateInstantiate.cpp =================================================================== --- lib/Sema/SemaTemplateInstantiate.cpp +++ lib/Sema/SemaTemplateInstantiate.cpp @@ -1670,7 +1670,7 @@ // Instantiate default arguments for methods of local classes (DR1484) // and non-defining declarations. Sema::ContextRAII SavedContext(*this, OwningFunc); - LocalInstantiationScope Local(*this); + LocalInstantiationScope Local(*this, true); ExprResult NewArg = SubstExpr(Arg, TemplateArgs); if (NewArg.isUsable()) { // It would be nice if we still had this. Index: test/SemaTemplate/default-expr-arguments-3.cpp =================================================================== --- /dev/null +++ test/SemaTemplate/default-expr-arguments-3.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -std=c++14 -ast-dump %s 2>&1 | FileCheck %s + +namespace PR28795 { + // CHECK: FunctionDecl{{.*}}func 'void (void)' + // CHECK: LambdaExpr + // CHECK: CXXMethodDecl{{.*}}operator() 'enum foo (enum foo) const' inline + // CHECK: ParmVarDecl{{.*}}f 'enum foo' cinit + // CHECK: DeclRefExpr{{.*}}'enum foo' EnumConstant{{.*}}'a' 'enum foo' + + template + void func() { + enum class foo { a, b }; + auto bar = [](foo f = foo::a) { return f; }; + bar(); + } + + void foo() { + func(); + } +}