A crash on (late parsed) lambda body with local class.

The following code shows a crash in (debug mode) clang++:

$ cat crash.cc
class Class {
   void Method(char c = []()->char {
       int d = []()->int {
         struct LateParsedClass {
           int LateParsedMethod() { return 0; }
         };
         return 0;
       }();
       return d;
     }());
};

$ clang++ -fsyntax-only -std=c++11 crash.cc
clang: SemaDecl.cpp:913: void clang::Sema::PushDeclContext(clang::Scope*, clang::DeclContext*): Assertion `getContainingDC(DC) == CurContext && "The next DeclContext should be lexically contained in the current one."' failed.

It seems that, when parsing (LateParsedMethod inside) LateParsedClass, the value of Sema.CurContext is still that of the outer class Class, while the (lexical) DC of LateParsedClass is that of the inner lambda operator() method, hence the assertion failure.

Is this a known bug? Should we file it?

Enea.

Please file.

  - Doug

[...]

Is this a known bug? Should we file it?

Please file.

  - Doug

Here it is

http://llvm.org/bugs/show_bug.cgi?id=13987