Jelajahi Sumber

Add warning group: for-redefinition (#2868)

Tex Riddell 5 tahun lalu
induk
melakukan
2a301af89d

+ 1 - 0
tools/clang/include/clang/Basic/DiagnosticGroups.td

@@ -780,4 +780,5 @@ def FutureCompat : DiagGroup<"future-compat">;
 
 // HLSL Change Starts - HLSL diagnostic groups
 def HLSLEffectsSyntax : DiagGroup<"effects-syntax">;
+def HLSLForRedefinition : DiagGroup<"for-redefinition">;
 // HLSL Change Ends

+ 2 - 1
tools/clang/include/clang/Basic/DiagnosticSemaKinds.td

@@ -7632,7 +7632,8 @@ def err_hlsl_invalid_resource_type_on_intrinsic : Error<
     "cannot %0 from resource containing %1">;
 def err_hlsl_usage_not_on_parameter : Error<
     "HLSL usage %0 is only valid on a parameter">;
-def warn_hlsl_for_redefinition : Warning<"redefinition of %0 shadows declaration in the outer scope; most recent declaration will be used">;
+def warn_hlsl_for_redefinition : Warning<"redefinition of %0 shadows declaration in the outer scope; most recent declaration will be used">,
+  InGroup<HLSLForRedefinition>;
 def warn_hlsl_for_redefinition_different_type : Warning<
   "redefinition of %0 with a different type%diff{: $ vs $|}1,2 shadows declaration in the outer scope; most recent declaration will be used">;
 def warn_hlsl_specifier_overridden : Warning<

+ 17 - 0
tools/clang/test/HLSLFileCheck/hlsl/diagnostics/warnings/Wno-for-redefinition.hlsl

@@ -0,0 +1,17 @@
+// RUN: %dxc -T vs_6_0 -Wno-for-redefinition %s | FileCheck %s
+
+// Make sure the specified warning gets turned off
+
+// This function has no output semantic on purpose in order to produce an error,
+// otherwise, the warnings will not be captured in the output for FileCheck.
+float main() {
+
+// redefinition of %0 shadows declaration in the outer scope; most recent declaration will be used
+// CHECK-NOT: redefinition
+  for (int i=0; i<4; i++);
+  for (int i=0; i<4; i++);
+
+  return 0;
+}
+
+// CHECK: error: Semantic must be defined