Skip to content

Commit 9f075c3

Browse files
committed
Revert "[Clang][Sema] Fix invalid redefinition error in if/switch/for statement"
This reverts commit be0905a. This patch broke build addressed in llvm/llvm-project#54968 Signed-off-by: Jun Zhang <jun@junz.org>
1 parent 19884d6 commit 9f075c3

File tree

3 files changed

+1
-20
lines changed

3 files changed

+1
-20
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,6 @@ Bug Fixes
119119
This fixes Issue `Issue 52802 <https://github.com/llvm/llvm-project/issues/52802>`_.
120120
- Unknown type attributes with a ``[[]]`` spelling are no longer diagnosed twice.
121121
This fixes Issue `Issue 54817 <https://github.com/llvm/llvm-project/issues/54817>`_.
122-
- Clang should no longer incorrectly diagnose a variable declaration inside of
123-
a lambda expression that shares the name of a variable in a containing
124-
if/while/for/switch init statement as a redeclaration.
125-
This fixes `Issue 54913 <https://github.com/llvm/llvm-project/issues/54913>`_.
126122

127123
Improvements to Clang's diagnostics
128124
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/IdentifierResolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ bool IdentifierResolver::isDeclInScope(Decl *D, DeclContext *Ctx, Scope *S,
123123
assert(S->getParent() && "No TUScope?");
124124
// If the current decl is in a lambda, we shouldn't consider this is a
125125
// redefinition as lambda has its own scope.
126-
if (S->getParent()->isControlScope() && !S->isFunctionScope()) {
126+
if (S->getParent()->isControlScope()) {
127127
S = S->getParent();
128128
if (S->isDeclScope(D))
129129
return true;

clang/test/SemaCXX/cxx1z-init-statement.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,3 @@ void test_constexpr_init_stmt() {
9090
static_assert(constexpr_switch_init(-2) == 0, "");
9191
static_assert(constexpr_switch_init(-5) == -1, "");
9292
}
93-
94-
int test_lambda_init() {
95-
if (int x = []() {int x = 42; return x; }(); x) {
96-
};
97-
98-
switch (int y = []() {int y = 42; return y; }(); y) {
99-
case 42:
100-
return 1;
101-
}
102-
103-
for (int x = [] { int x = 0; return x; }();;)
104-
;
105-
106-
return 0;
107-
}

0 commit comments

Comments
 (0)