]> granicus.if.org Git - clang/commit
Fix recognition of shadowed template parameter
authorSerge Pavlov <sepavloff@gmail.com>
Fri, 10 Jun 2016 04:39:07 +0000 (04:39 +0000)
committerSerge Pavlov <sepavloff@gmail.com>
Fri, 10 Jun 2016 04:39:07 +0000 (04:39 +0000)
commit13f56e29a745a736abae6e82eb082c93c8f238d9
tree71917b4caa85bfd4dcb1b7eaf27e34db17e6ba08
parent8085b7c130683f01bf8901997d93f24eede69b20
Fix recognition of shadowed template parameter

Crash reported in PR28023 is caused by the fact that non-type template
parameters are found by tag name lookup.  In the code provided in that PR:

template<int V> struct A {
  struct B {
    template <int> friend struct V;
  };
};

the template parameter V is found when lookup for redeclarations of 'struct V'
is made. Latter on the error about shadowing of 'V' is emitted but the semantic
context of 'struct V' is already determined wrong: 'struct A' instead of
translation unit.

The fix moves the check for shadowing toward the beginning of the method and
thus prevents from wrong context calculations.

This change fixes PR28023.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272366 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Sema/SemaTemplate.cpp
test/CXX/temp/temp.res/temp.local/p6.cpp