[all-commits] [llvm/llvm-project] ca68f3: Fix a diagnoses-valid bug with using declarations

Aaron Ballman via All-commits all-commits at lists.llvm.org
Fri Jun 4 12:52:31 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ca68f3bc48e48f839142de1461e95d87ae48e9df
      https://github.com/llvm/llvm-project/commit/ca68f3bc48e48f839142de1461e95d87ae48e9df
  Author: Aaron Ballman <aaron at aaronballman.com>
  Date:   2021-06-04 (Fri, 04 Jun 2021)

  Changed paths:
    M clang/lib/Sema/SemaDecl.cpp
    M clang/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp
    M clang/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp
    M clang/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp
    M clang/test/SemaCXX/using-decl-templates.cpp

  Log Message:
  -----------
  Fix a diagnoses-valid bug with using declarations

The following was found by a customer and is accepted by the other primary
C++ compilers, but fails to compile in Clang:

namespace sss {
double foo(int, double);
template <class T>
T foo(T); // note: target of using declaration
}  // namespace sss

namespace oad {
void foo();
}

namespace oad {
using ::sss::foo;
}

namespace sss {
using oad::foo; // note: using declaration
}

namespace sss {
double foo(int, double) { return 0; }
template <class T>
T foo(T t) { // error: declaration conflicts with target of using
  return t;
}
}  // namespace sss

I believe the issue is that MergeFunctionDecl() was calling
checkUsingShadowRedecl() but only considering a FunctionDecl as a
possible shadow and not FunctionTemplateDecl. The changes in this patch
largely mirror how variable declarations were being handled by also
catching FunctionTemplateDecl.




More information about the All-commits mailing list