[PATCH] D115248: [clang] Fix Bug 28101

PoYao Chang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 7 07:40:03 PST 2021


rZhBoYao updated this revision to Diff 392399.

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

https://reviews.llvm.org/D115248

Files:
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp


Index: clang/lib/Sema/SemaDeclCXX.cpp
===================================================================
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -15440,6 +15440,11 @@
         break;
       }
     }
+    if (LLVM_UNLIKELY(!Pattern))
+      for (const auto *FD : ClassPattern->fields())
+        if (Diags.hasErrorOccurred() && !FD->getIdentifier()) {
+          return ExprError();
+        }
     assert(Pattern && "We must have set the Pattern!");
 
     if (!Pattern->hasInClassInitializer() ||
Index: clang/lib/Parse/ParseDecl.cpp
===================================================================
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -6205,6 +6205,12 @@
         // is exited (and the declarator has been parsed).
         DeclScopeObj.EnterDeclaratorScope();
     }
+    if (D.getContext() == DeclaratorContext::Member && D.hasName() &&
+        !D.getIdentifier())
+      Diag(getMissingDeclaratorIdLoc(D, Tok.getLocation()),
+           diag::err_expected_member_name_or_semi)
+          << (D.getDeclSpec().isEmpty() ? SourceRange()
+                                        : D.getDeclSpec().getSourceRange());
   } else if (D.mayOmitIdentifier()) {
     // This could be something simple like "int" (in which case the declarator
     // portion is empty), if an abstract-declarator is allowed.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115248.392399.patch
Type: text/x-patch
Size: 1373 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211207/b451a0df/attachment.bin>


More information about the cfe-commits mailing list