[flang-commits] [libc] [clang-tools-extra] [libcxx] [compiler-rt] [clang] [llvm] [flang] [C23] Complete support for WG14 N2508 (PR #71398)

via flang-commits flang-commits at lists.llvm.org
Mon Nov 6 16:30:33 PST 2023


================
@@ -698,6 +695,19 @@ StmtResult Parser::ParseSEHLeaveStatement() {
   return Actions.ActOnSEHLeaveStmt(LeaveLoc, getCurScope());
 }
 
+static void DiagnoseLabelFollowedByDecl(Parser &P, const Stmt *SubStmt) {
+  // When in C mode (but not Microsoft extensions mode), diagnose use of a
+  // label that is followed by a declaration rather than a statement.
+  if (!P.getLangOpts().CPlusPlus && !P.getLangOpts().MicrosoftExt &&
+      isa<DeclStmt>(SubStmt)) {
+    if (P.getLangOpts().C23)
+      P.Diag(SubStmt->getBeginLoc(),
+             diag::warn_c23_compat_label_followed_by_declaration);
+    else
+      P.Diag(SubStmt->getBeginLoc(), diag::ext_c_label_followed_by_declaration);
+  }
----------------
cor3ntin wrote:

```suggestion
P.Diag(SubStmt->getBeginLoc(), P.getLangOpts().C23 ?
             diag::warn_c23_compat_label_followed_by_declaration
           : diag::ext_c_label_followed_by_declaration);
```

https://github.com/llvm/llvm-project/pull/71398


More information about the flang-commits mailing list