Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ Improvements to Clang's diagnostics
which are supposed to only exist once per program, but may get duplicated when
built into a shared library.
- Fixed a bug where Clang's Analysis did not correctly model the destructor behavior of ``union`` members (#GH119415).
- A statement attribute applied to a ``case`` label no longer suppresses
'bypassing variable initialization' diagnostics (#84072).

Improvements to Clang's time-trace
----------------------------------
Expand Down
19 changes: 8 additions & 11 deletions clang/lib/Sema/JumpDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,15 +597,6 @@ void JumpScopeChecker::BuildScopeInformation(Stmt *S,
LabelAndGotoScopes[S] = ParentScope;
break;

case Stmt::AttributedStmtClass: {
AttributedStmt *AS = cast<AttributedStmt>(S);
if (GetMustTailAttr(AS)) {
LabelAndGotoScopes[AS] = ParentScope;
MustTailStmts.push_back(AS);
}
break;
}

case Stmt::OpenACCComputeConstructClass: {
unsigned NewParentScope = Scopes.size();
OpenACCComputeConstruct *CC = cast<OpenACCComputeConstruct>(S);
Expand Down Expand Up @@ -649,7 +640,7 @@ void JumpScopeChecker::BuildScopeInformation(Stmt *S,
continue;
}

// Cases, labels, and defaults aren't "scope parents". It's also
// Cases, labels, attributes, and defaults aren't "scope parents". It's also
// important to handle these iteratively instead of recursively in
// order to avoid blowing out the stack.
while (true) {
Expand All @@ -658,7 +649,13 @@ void JumpScopeChecker::BuildScopeInformation(Stmt *S,
Next = SC->getSubStmt();
else if (LabelStmt *LS = dyn_cast<LabelStmt>(SubStmt))
Next = LS->getSubStmt();
else
else if (AttributedStmt *AS = dyn_cast<AttributedStmt>(SubStmt)) {
if (GetMustTailAttr(AS)) {
LabelAndGotoScopes[AS] = ParentScope;
MustTailStmts.push_back(AS);
}
Next = AS->getSubStmt();
} else
break;

LabelAndGotoScopes[SubStmt] = ParentScope;
Expand Down
11 changes: 11 additions & 0 deletions clang/test/CXX/stmt.stmt/stmt.select/stmt.switch/p4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: %clang -fsyntax-only -std=c++20 -Xclang -verify %s

void Func(int x) {
switch (x) {
[[likely]] case 0:
case 1:
int i = 3; // expected-note {{jump bypasses variable initialization}}
case 2: // expected-error {{cannot jump from switch statement to this case label}}
break;
}
}