[clang] [clang][Sema] Diagnose exceptions only in non-dependent context in discarded `try/catch/throw` blocks (PR #139859)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Tue May 27 07:56:41 PDT 2025
================
@@ -4304,10 +4304,9 @@ StmtResult Sema::ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock,
getLangOpts().OpenMPIsTargetDevice && (T.isNVPTX() || T.isAMDGCN());
// Don't report an error if 'try' is used in system headers or in an OpenMP
// target region compiled for a GPU architecture.
- if (!IsOpenMPGPUTarget && !getLangOpts().CXXExceptions &&
- !getSourceManager().isInSystemHeader(TryLoc) && !getLangOpts().CUDA) {
+ if (!IsOpenMPGPUTarget && !getLangOpts().CUDA) {
// Delay error emission for the OpenMP device code.
- targetDiag(TryLoc, diag::err_exceptions_disabled) << "try";
+ DiagnoseExceptionUse(TryLoc, /* IsTry */ true);
----------------
erichkeane wrote:
```suggestion
DiagnoseExceptionUse(TryLoc, /* IsTry= */ true);
```
https://github.com/llvm/llvm-project/pull/139859
More information about the cfe-commits
mailing list