2
0
Эх сурвалжийг харах

Propagate /no-warnings flag (#1349)

* Propagate /no-warnings flag

* With these changes, warnings are not shown when /no-warnings flag is used and they get printed when /no-warnings flag is not used. The exact behavior is mirrored when a user decides to output warnings and errors to an output file by using /Fe flag.
Vishal Sharma 7 жил өмнө
parent
commit
523b74e251

+ 10 - 0
tools/clang/test/CodeGenHLSL/check_nowarning.hlsl

@@ -0,0 +1,10 @@
+// RUN: %dxc -E main -no-warnings -T ps_6_0 %s | FileCheck %s
+// CHECK-NOT: warning: attribute 'branch' can only be applied to 'if' and 'switch' statements
+
+[branch] // this should generate a warning that is used for testing
+float4 main() : SV_TARGET
+{
+    // no return stmt should cause error which is needed to direct errors
+	// and warnings to stdin instead of dxil output.
+    // return float4(1, 0, 0, 1);
+}

+ 10 - 0
tools/clang/test/CodeGenHLSL/check_warning.hlsl

@@ -0,0 +1,10 @@
+// RUN: %dxc -E main -T ps_6_0 %s | FileCheck %s
+// CHECK: warning: attribute 'branch' can only be applied to 'if' and 'switch' statements
+
+[branch] // this should generate a warning that is used for testing
+float4 main() : SV_TARGET
+{
+    // no return stmt should cause error which is needed to direct errors
+	// and warnings to stdin instead of dxil output.
+    // return float4(1, 0, 0, 1);
+}

+ 2 - 0
tools/clang/tools/dxcompiler/dxcompilerobj.cpp

@@ -770,6 +770,8 @@ public:
       : hlsl::DXIL::kLegacyLayoutString;
       : hlsl::DXIL::kLegacyLayoutString;
     compiler.HlslLangExtensions = helper;
     compiler.HlslLangExtensions = helper;
     compiler.createDiagnostics(diagPrinter, false);
     compiler.createDiagnostics(diagPrinter, false);
+    // don't output warning to stderr/file if "/no-warnings" is present.
+    compiler.getDiagnostics().setIgnoreAllWarnings(!Opts.OutputWarnings);
     compiler.createFileManager();
     compiler.createFileManager();
     compiler.createSourceManager(compiler.getFileManager());
     compiler.createSourceManager(compiler.getFileManager());
     compiler.setTarget(
     compiler.setTarget(