[llvm-branch-commits] [clang] release/22.x: [clang] Restore diagnostic for certain jumps into VLA(ish) scopes. (#175833) (PR #175858)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jan 13 14:29:21 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: None (llvmbot)
<details>
<summary>Changes</summary>
Backport ac15ac9
Requested by: @<!-- -->keinflue
---
Full diff: https://github.com/llvm/llvm-project/pull/175858.diff
3 Files Affected:
- (modified) clang/docs/ReleaseNotes.rst (+2)
- (modified) clang/lib/Sema/JumpDiagnostics.cpp (+3-1)
- (modified) clang/test/Sema/scope-check.c (+8)
``````````diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c11a604a46d83..192db30db9b3f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -672,6 +672,8 @@ Miscellaneous Bug Fixes
Miscellaneous Clang Crashes Fixed
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+- Fixed a crash when attempting to jump over initialization of a variable with variably modified type. (#GH175540)
+
OpenACC Specific Changes
------------------------
diff --git a/clang/lib/Sema/JumpDiagnostics.cpp b/clang/lib/Sema/JumpDiagnostics.cpp
index 36c9d9afb37f1..2c45de69e7cdf 100644
--- a/clang/lib/Sema/JumpDiagnostics.cpp
+++ b/clang/lib/Sema/JumpDiagnostics.cpp
@@ -179,8 +179,10 @@ static ScopePair GetDiagForGotoScopeDecl(Sema &S, const Decl *D) {
}
}
+ // An earlier diag::note_protected_by_vla is more severe, so don't overwrite
+ // it here.
if (const Expr *Init = VD->getInit();
- VD->hasLocalStorage() && Init && !Init->containsErrors()) {
+ !InDiag && VD->hasLocalStorage() && Init && !Init->containsErrors()) {
// C++11 [stmt.dcl]p3:
// A program that jumps from a point where a variable with automatic
// storage duration is not in scope to a point where it is in scope
diff --git a/clang/test/Sema/scope-check.c b/clang/test/Sema/scope-check.c
index c6aa421b3ebde..f0100759ca9b2 100644
--- a/clang/test/Sema/scope-check.c
+++ b/clang/test/Sema/scope-check.c
@@ -256,3 +256,11 @@ void GH63682() {
(void)({P:1;}); // expected-note {{jump enters a statement expression}}
}
}
+
+void gh175549(int b, void* c) {
+ __asm__ goto("" : : : : d); // expected-error {{cannot jump from this asm goto statement to one of its possible targets}}
+ int(*a)[b] = c; // expected-note {{jump bypasses initialization of variable length array}}
+d: // expected-note {{possible target of asm goto statement}}
+ (void)a[0];
+}
+
``````````
</details>
https://github.com/llvm/llvm-project/pull/175858
More information about the llvm-branch-commits
mailing list