[llvm-bugs] [Bug 40577] New: [clang-cl] [ms] Implement warning for shadowing of template parameter extension

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Feb 2 19:29:34 PST 2019


            Bug ID: 40577
           Summary: [clang-cl] [ms] Implement warning for shadowing of
                    template parameter extension
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: heavenandhell171 at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

Clang usually warns whenever it compiles non conformant code that MSVC accepts,
which i think it's great. However, there is no warning for shadowing of
template parameters, which is illegal.

For exemple:

$ cat test.cpp
template <typename T>
struct type_t {
  template <typename T>
  void function() {

$ clang-cl -c test.cpp

No warning.

I discovered that this is ill-formed when i pushed some code and the GCC build
bot failed. It would be nice to have Clang warn about this extension.

Something like:

$ clang-cl -c test.cpp
test.cpp(3,22):  warning: declaration of 'T' shadows template parameter;
ignored as a Microsoft extension
  template <typename T>
test.cpp(1,20):  note: template parameter is declared here
template <typename T>
1 warning generated.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190203/a3b37315/attachment.html>

More information about the llvm-bugs mailing list