[all-commits] [llvm/llvm-project] be0905: [Clang][Sema] Fix invalid redefinition error in if...

Jun Zhang via All-commits all-commits at lists.llvm.org
Fri Apr 15 06:55:19 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: be0905a333d6f7c4d7f5c70c18211463e53473cd
      https://github.com/llvm/llvm-project/commit/be0905a333d6f7c4d7f5c70c18211463e53473cd
  Author: Jun Zhang <jun at junz.org>
  Date:   2022-04-15 (Fri, 15 Apr 2022)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/lib/Sema/IdentifierResolver.cpp
    M clang/test/SemaCXX/cxx1z-init-statement.cpp

  Log Message:
  -----------
  [Clang][Sema] Fix invalid redefinition error in if/switch/for statement

Clang should no longer incorrectly diagnose a variable declaration inside of a
lambda expression that shares the name of a variable in a containing
if/while/for/switch init statement as a redeclaration.

After this patch, clang is supposed to accept code below:

void foo() {
  for (int x = [] { int x = 0; return x; }(); ;) ;
}

Fixes https://github.com/llvm/llvm-project/issues/54913

Differential Revision: https://reviews.llvm.org/D123840




More information about the All-commits mailing list