[llvm-branch-commits] [clang] f87cc45 - Put microsoft template parameter shadow warning behind separate flag (PR44794)

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Feb 26 07:09:21 PST 2020


Author: Hans Wennborg
Date: 2020-02-26T16:06:11+01:00
New Revision: f87cc45dffa0a83b9db1aff143829d3f5c04c52f

URL: https://github.com/llvm/llvm-project/commit/f87cc45dffa0a83b9db1aff143829d3f5c04c52f
DIFF: https://github.com/llvm/llvm-project/commit/f87cc45dffa0a83b9db1aff143829d3f5c04c52f.diff

LOG: Put microsoft template parameter shadow warning behind separate flag (PR44794)

Differential revision: https://reviews.llvm.org/D75121

(cherry picked from commit 41a6612ea8afc5254e4de3aca55628d37f0be433)

Added: 
    clang/test/SemaCXX/microsoft-template-shadow.cpp

Modified: 
    clang/include/clang/Basic/DiagnosticGroups.td
    clang/include/clang/Basic/DiagnosticSemaKinds.td

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index 67885ac14ab5..8e43052f30e2 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1014,7 +1014,8 @@ def MicrosoftExplicitConstructorCall : DiagGroup<
 def MicrosoftEnumValue : DiagGroup<"microsoft-enum-value">;
 def MicrosoftDefaultArgRedefinition :
     DiagGroup<"microsoft-default-arg-redefinition">;
-def MicrosoftTemplate : DiagGroup<"microsoft-template">;
+def MicrosoftTemplateShadow : DiagGroup<"microsoft-template-shadow">;
+def MicrosoftTemplate : DiagGroup<"microsoft-template", [MicrosoftTemplateShadow]>;
 def MicrosoftInconsistentDllImport : DiagGroup<"inconsistent-dllimport">;
 def MicrosoftRedeclareStatic : DiagGroup<"microsoft-redeclare-static">;
 def MicrosoftEnumForwardReference :

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index f643739eaac1..917377420505 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4210,7 +4210,7 @@ def err_ovl_no_viable_literal_operator : Error<
 def err_template_param_shadow : Error<
   "declaration of %0 shadows template parameter">;
 def ext_template_param_shadow : ExtWarn<
-  err_template_param_shadow.Text>, InGroup<MicrosoftTemplate>;
+  err_template_param_shadow.Text>, InGroup<MicrosoftTemplateShadow>;
 def note_template_param_here : Note<"template parameter is declared here">;
 def warn_template_export_unsupported : Warning<
   "exported templates are unsupported">;

diff  --git a/clang/test/SemaCXX/microsoft-template-shadow.cpp b/clang/test/SemaCXX/microsoft-template-shadow.cpp
new file mode 100644
index 000000000000..ab2ffdefdd8f
--- /dev/null
+++ b/clang/test/SemaCXX/microsoft-template-shadow.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -verify -fms-compatibility -Wno-microsoft -Wmicrosoft-template-shadow
+
+template <typename T> // expected-note {{template parameter is declared here}}
+struct Outmost {
+  template <typename T> // expected-warning {{declaration of 'T' shadows template parameter}}
+  struct Inner {
+    void f() {
+      T *var;
+    }
+  };
+};


        


More information about the llvm-branch-commits mailing list