Index: clang/lib/Sema/SemaExprMember.cpp =================================================================== --- clang/lib/Sema/SemaExprMember.cpp +++ clang/lib/Sema/SemaExprMember.cpp @@ -163,8 +163,11 @@ CXXRecordDecl *contextClass; if (CXXMethodDecl *MD = dyn_cast(DC)) contextClass = MD->getParent()->getCanonicalDecl(); - else + else if (CXXRecordDecl *RD = dyn_cast(DC)) contextClass = cast(DC); + else + return AbstractInstanceResult ? AbstractInstanceResult + : IMA_Error_StaticContext; // [class.mfct.non-static]p3: // ...is used in the body of a non-static member function of class X, Index: clang/test/SemaCXX/cxx1y-generic-lambdas.cpp =================================================================== --- clang/test/SemaCXX/cxx1y-generic-lambdas.cpp +++ clang/test/SemaCXX/cxx1y-generic-lambdas.cpp @@ -1026,3 +1026,11 @@ void *v = x(f); // expected-error {{cannot initialize a variable of type 'void *' with an rvalue of type 'int'}} void *w = y(f); // expected-error {{cannot initialize a variable of type 'void *' with an rvalue of type 'int'}} } + +namespace GH37792 { +struct A { int x; }; + +void f() { + [](auto t) -> decltype(decltype(t)::x) { return 0; }(A()); +} +} Index: clang/test/SemaCXX/statements.cpp =================================================================== --- clang/test/SemaCXX/statements.cpp +++ clang/test/SemaCXX/statements.cpp @@ -52,3 +52,14 @@ int a = test7(1); double b = test7(2.0); } + +namespace GH48405 { +void foo() { + struct S { + int i; + int j = ({i;}); // expected-error {{invalid use of non-static data member 'i'}} + // expected-error@-1 {{cannot initialize a member subobject of type 'int' with an rvalue of type 'void'}} + // expected-warning@-2 {{use of GNU statement expression extension}} + }; +} +}