[all-commits] [llvm/llvm-project] 1b8125: Don't assert if we find a dependently-typed variab...

Richard Smith via All-commits all-commits at lists.llvm.org
Tue Jun 16 19:41:34 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 1b8125b041e28a315e5c5fe64441a2fb07a2f5ea
      https://github.com/llvm/llvm-project/commit/1b8125b041e28a315e5c5fe64441a2fb07a2f5ea
  Author: Richard Smith <richard at metafoo.co.uk>
  Date:   2020-06-16 (Tue, 16 Jun 2020)

  Changed paths:
    M clang/lib/Sema/SemaDecl.cpp
    M clang/test/SemaTemplate/array-redeclaration.cpp

  Log Message:
  -----------
  Don't assert if we find a dependently-typed variable in the
redeclaration chain for an array.

A prior attempt to fix this in r280330 didn't handle the case where the
old variable is dependent and the new one is not.

It is notable and worrying that the test case in this example forms a
redeclaration chain for a non-dependent variable that includes a
declaration with a dependent type. We should probably fix that too.


  Commit: 237c2a23b6d4fa953f5ae910dccf492db61bb959
      https://github.com/llvm/llvm-project/commit/237c2a23b6d4fa953f5ae910dccf492db61bb959
  Author: Richard Smith <richard at metafoo.co.uk>
  Date:   2020-06-16 (Tue, 16 Jun 2020)

  Changed paths:
    M clang/include/clang/Parse/Parser.h
    M clang/include/clang/Sema/Scope.h
    M clang/lib/AST/DeclBase.cpp
    M clang/lib/Parse/ParseExprCXX.cpp
    M clang/lib/Parse/ParseTemplate.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaLookup.cpp
    M clang/lib/Sema/SemaTemplate.cpp
    M clang/test/CXX/drs/dr4xx.cpp
    M clang/test/CXX/temp/temp.res/temp.local/p8.cpp
    M clang/test/SemaCXX/lambda-expressions.cpp
    M clang/www/cxx_dr_status.html

  Log Message:
  -----------
  DR458: Search template parameter scopes in the right order.

C++ unqualified name lookup searches template parameter scopes
immediately after finishing searching the entity the parameters belong
to. (Eg, for a class template, you search the template parameter scope
after looking in that class template and its base classes and before
looking in the scope containing the class template.) This is complicated
by the fact that scope lookup within a template parameter scope looks in
a different sequence of places prior to reaching the end of the
declarator-id in the template declaration.

We used to approximate the proper lookup rule with a hack in the scope /
decl context walk inside name lookup. Now we instead compute the lookup
parent for each template parameter scope. This gets the right answer and
as a bonus is substantially simpler and more uniform.

In order to get this right, we now make sure to enter a distinct Scope
for each template parameter scope. (The fact that we didn't before was
already a bug, but not really observable most of the time, since
template parameters can't shadow each other.)


Compare: https://github.com/llvm/llvm-project/compare/50155bcd4642...237c2a23b6d4


More information about the All-commits mailing list