[PATCH] D142490: [Clang] Fix ClassifyImplicitMemberAccess to handle cases where the access in an unevaluated context is not within a CXXRecordDecl or CXXMethodDecl

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 24 09:17:44 PST 2023


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, though you should add a release note as well.



================
Comment at: clang/lib/Sema/SemaExprMember.cpp:164-167
   if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC))
     contextClass = MD->getParent()->getCanonicalDecl();
-  else
+  else if (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC))
     contextClass = cast<CXXRecordDecl>(DC);
----------------



================
Comment at: clang/test/SemaCXX/statements.cpp:60-61
+    int i;
+    int j = ({i;}); // expected-error {{invalid use of non-static data member 'i'}}
+                    // expected-error at -1 {{cannot initialize a member subobject of type 'int' with an rvalue of type 'void'}}
+		    // expected-warning at -2 {{use of GNU statement expression extension}}
----------------
This diagnostic isn't entirely unreasonable, but I think GCC gives a better diagnostic: https://godbolt.org/z/T4dbhnoo7


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142490/new/

https://reviews.llvm.org/D142490



More information about the cfe-commits mailing list