[clang] [C23] Implement N3018: The constexpr specifier for object definitions (PR #73099)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 22 02:36:09 PST 2023


================
@@ -2231,6 +2231,13 @@ static bool CheckLValueConstantExpression(EvalInfo &Info, SourceLocation Loc,
     return false;
   }
 
+  if (Info.getLangOpts().C23) {
+    auto *VarD = dyn_cast_or_null<VarDecl>(BaseVD);
+    if (VarD && VarD->isConstexpr() && !LVal.isNullPointer()) {
+      Info.report(Loc, diag::err_c23_constexpr_pointer_not_null);
+    }
+  }
----------------
tbaederr wrote:

```suggestion
  if (Info.getLangOpts().C23) {
    if (const auto *VarD = dyn_cast_if_present<VarDecl>(BaseVD);
        VarD && VarD->isConstexpr() && !LVal.isNullPointer())
      Info.report(Loc, diag::err_c23_constexpr_pointer_not_null);
  }
```

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


More information about the cfe-commits mailing list