[PATCH] D44439: [Sema] Pop function scope when instantiating a func with skipped body

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 14 05:28:14 PDT 2018

ilya-biryukov added a comment.

@aaron.ballman , here's a test-case I came up with. I'll fix the other issue (invalid error, that forces the test to fail) and submit it for review along with the fix for the error. Does that SG?

  template <class T>
  auto make_func() {
    struct impl {
      impl* func() {
        // body of this function is skipped during completion.
        // but will be instantiated anyway.
        return this;
    return impl();
  void foo() {
    []() {
      make_func<int>();    // currently also produces invalid error `function with auto-deduced type 'make_func<int>' is used before defined
      // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:17:6 %s -o - | FileCheck %s
      // CHECK: make_func : [#auto#]make_func<<#class T#>>()

Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:3967
       // context seems wrong. Investigate more.
-      ActOnFinishFunctionBody(Function, Body.get(),
-                              /*IsInstantiation=*/true);
+      ActOnFinishFunctionBody(Function, Body.get(), /*IsInstantiation=*/true);
aaron.ballman wrote:
> This change looks unrelated to the patch.
It was a formatting change.

  rC Clang


More information about the cfe-commits mailing list