[PATCH] D116922: [AST] Use recovery-expr to preserve incomplete-type-member-access expression.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 10 03:45:41 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGabe3003ead80: [AST] Use recovery-expr to preserve incomplete-type-member-access expression. (authored by hokein).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116922/new/
https://reviews.llvm.org/D116922
Files:
clang/lib/Sema/SemaExprCXX.cpp
clang/test/AST/ast-dump-recovery.cpp
clang/test/OpenMP/declare_reduction_messages.cpp
Index: clang/test/OpenMP/declare_reduction_messages.cpp
===================================================================
--- clang/test/OpenMP/declare_reduction_messages.cpp
+++ clang/test/OpenMP/declare_reduction_messages.cpp
@@ -169,7 +169,6 @@
#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 at +2 {{extra tokens at the end of '#pragma omp declare reduction' are ignored}}
// expected-note at +1 {{in instantiation of template class 'S<1>' requested here}}
#pragma omp declare reduction (bar : S<1> : omp_out.foo(omp_in))
Index: clang/test/AST/ast-dump-recovery.cpp
===================================================================
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -121,6 +121,16 @@
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;
Index: clang/lib/Sema/SemaExprCXX.cpp
===================================================================
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -7410,8 +7410,10 @@
// 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116922.398564.patch
Type: text/x-patch
Size: 2134 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220110/afa4e82f/attachment.bin>
More information about the cfe-commits
mailing list