forked from OSchip/llvm-project
[AST] Use recovery-expr to preserve incomplete-type-member-access expression.
Fixes https://github.com/clangd/clangd/issues/502 Differential Revision: https://reviews.llvm.org/D116922
This commit is contained in:
parent
c44d521b30
commit
abe3003ead
clang
|
@ -7410,8 +7410,10 @@ ExprResult Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base,
|
|||
// the member function body.
|
||||
if (!BaseType->isDependentType() &&
|
||||
!isThisOutsideMemberFunctionBody(BaseType) &&
|
||||
RequireCompleteType(OpLoc, BaseType, diag::err_incomplete_member_access))
|
||||
return ExprError();
|
||||
RequireCompleteType(OpLoc, BaseType,
|
||||
diag::err_incomplete_member_access)) {
|
||||
return CreateRecoveryExpr(Base->getBeginLoc(), Base->getEndLoc(), {Base});
|
||||
}
|
||||
|
||||
// C++ [basic.lookup.classref]p2:
|
||||
// If the id-expression in a class member access (5.2.5) is an
|
||||
|
|
|
@ -121,6 +121,16 @@ void test(int x) {
|
|||
foo->func(x);
|
||||
}
|
||||
|
||||
void AccessIncompleteClass() {
|
||||
struct Forward;
|
||||
Forward* ptr;
|
||||
// CHECK: CallExpr {{.*}} '<dependent type>'
|
||||
// CHECK-NEXT: `-CXXDependentScopeMemberExpr {{.*}} '<dependent type>'
|
||||
// CHECK-NEXT: `-RecoveryExpr {{.*}} '<dependent type>' contains-errors
|
||||
// CHECK-NEXT: `-DeclRefExpr {{.*}} 'Forward *'
|
||||
ptr->method();
|
||||
}
|
||||
|
||||
struct Foo2 {
|
||||
double func();
|
||||
class ForwardClass;
|
||||
|
|
|
@ -169,7 +169,6 @@ struct S
|
|||
#pragma omp declare reduction (xxx : U, S : bar(omp_in)) // expected-error {{non-const lvalue reference to type 'S<1>' cannot bind to a value of unrelated type 'U'}}
|
||||
static void bar(S &x); // expected-note {{passing argument to parameter 'x' here}}
|
||||
};
|
||||
// expected-warning@+2 {{extra tokens at the end of '#pragma omp declare reduction' are ignored}}
|
||||
// expected-note@+1 {{in instantiation of template class 'S<1>' requested here}}
|
||||
#pragma omp declare reduction (bar : S<1> : omp_out.foo(omp_in))
|
||||
|
||||
|
|
Loading…
Reference in New Issue