================
@@ -5975,9 +5975,22 @@ static bool CheckConstexprFunction(EvalInfo &Info, 
SourceLocation CallLoc,
                                         
Definition->hasAttr<MSConstexprAttr>())))
     return true;
 
-  if (Info.getLangOpts().CPlusPlus11) {
-    const FunctionDecl *DiagDecl = Definition ? Definition : Declaration;
+  const FunctionDecl *DiagDecl = Definition ? Definition : Declaration;
+  // Special note for the assert() macro, as the normal error message falsely
+  // implies we cannot use an assertion during constant evaluation.
+  if (CallLoc.isMacroID() && DiagDecl->getIdentifier()) {
+    // FIXME: Instead of checking for an implementation-defined function,
+    // check and evaluate the assert() macro.
+    const bool assertFailed = DiagDecl->getName() == "__assert_rtn" ||
+                              DiagDecl->getName() == "__assert_fail" ||
+                              DiagDecl->getName() == "_wassert";
----------------
cor3ntin wrote:

```suggestion
    StringRef Name = DiagDecl->getName();
    bool AssertFailed = Name == "__assert_rtn" ||
                                       Name == "__assert_fail" ||
                                       Name  == "_wassert";
```

https://github.com/llvm/llvm-project/pull/130458
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to