|
@@ -760,7 +760,8 @@ public:
|
|
IFT(pOutputStream.QueryInterface(&pOutputBlob));
|
|
IFT(pOutputStream.QueryInterface(&pOutputBlob));
|
|
|
|
|
|
primaryOutput.kind = DXC_OUT_OBJECT;
|
|
primaryOutput.kind = DXC_OUT_OBJECT;
|
|
- if (opts.AstDump || opts.OptDump || opts.DumpDependencies)
|
|
|
|
|
|
+ if (opts.AstDump || opts.OptDump || opts.DumpDependencies ||
|
|
|
|
+ opts.VerifyDiagnostics)
|
|
primaryOutput.kind = DXC_OUT_TEXT;
|
|
primaryOutput.kind = DXC_OUT_TEXT;
|
|
else if (isPreprocessing)
|
|
else if (isPreprocessing)
|
|
primaryOutput.kind = DXC_OUT_HLSL;
|
|
primaryOutput.kind = DXC_OUT_HLSL;
|
|
@@ -919,7 +920,8 @@ public:
|
|
// validator can be used as a fallback.
|
|
// validator can be used as a fallback.
|
|
produceFullContainer = !opts.CodeGenHighLevel && !opts.AstDump &&
|
|
produceFullContainer = !opts.CodeGenHighLevel && !opts.AstDump &&
|
|
!opts.OptDump && rootSigMajor == 0 &&
|
|
!opts.OptDump && rootSigMajor == 0 &&
|
|
- !opts.DumpDependencies;
|
|
|
|
|
|
+ !opts.DumpDependencies &&
|
|
|
|
+ !opts.VerifyDiagnostics;
|
|
needsValidation = produceFullContainer && !opts.DisableValidation;
|
|
needsValidation = produceFullContainer && !opts.DisableValidation;
|
|
|
|
|
|
if (compiler.getCodeGenOpts().HLSLProfile == "lib_6_x") {
|
|
if (compiler.getCodeGenOpts().HLSLProfile == "lib_6_x") {
|
|
@@ -1012,6 +1014,13 @@ public:
|
|
pOutputBlob, &compiler.getDiagnostics());
|
|
pOutputBlob, &compiler.getDiagnostics());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ } else if (opts.VerifyDiagnostics) {
|
|
|
|
+ SyntaxOnlyAction action;
|
|
|
|
+ FrontendInputFile file(pUtf8SourceName, IK_HLSL);
|
|
|
|
+ if (action.BeginSourceFile(compiler, file)) {
|
|
|
|
+ action.Execute();
|
|
|
|
+ action.EndSourceFile();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
// SPIRV change starts
|
|
// SPIRV change starts
|
|
#ifdef ENABLE_SPIRV_CODEGEN
|
|
#ifdef ENABLE_SPIRV_CODEGEN
|
|
@@ -1289,7 +1298,15 @@ public:
|
|
|
|
|
|
IFT(primaryOutput.SetObject(pOutputBlob, opts.DefaultTextCodePage));
|
|
IFT(primaryOutput.SetObject(pOutputBlob, opts.DefaultTextCodePage));
|
|
IFT(pResult->SetOutput(primaryOutput));
|
|
IFT(pResult->SetOutput(primaryOutput));
|
|
- IFT(pResult->SetStatusAndPrimaryResult(hasErrorOccurred ? E_FAIL : S_OK, primaryOutput.kind));
|
|
|
|
|
|
+
|
|
|
|
+ // It is possible for errors to occur, but the diagnostic or AST consumers
|
|
|
|
+ // can recover from them, or translate them to mean something different.
|
|
|
|
+ // This happens with the `-verify` flag where an error may be expected.
|
|
|
|
+ // The correct way to identify errors in this case is to query the
|
|
|
|
+ // DiagnosticClient for the number of errors.
|
|
|
|
+ unsigned NumErrors = compiler.getDiagnostics().getClient()->getNumErrors();
|
|
|
|
+ IFT(pResult->SetStatusAndPrimaryResult(NumErrors > 0 ? E_FAIL : S_OK,
|
|
|
|
+ primaryOutput.kind));
|
|
IFT(pResult->QueryInterface(riid, ppResult));
|
|
IFT(pResult->QueryInterface(riid, ppResult));
|
|
|
|
|
|
hr = S_OK;
|
|
hr = S_OK;
|
|
@@ -1401,6 +1418,7 @@ public:
|
|
compiler.HlslLangExtensions = helper;
|
|
compiler.HlslLangExtensions = helper;
|
|
compiler.getDiagnosticOpts().ShowOptionNames = Opts.ShowOptionNames ? 1 : 0;
|
|
compiler.getDiagnosticOpts().ShowOptionNames = Opts.ShowOptionNames ? 1 : 0;
|
|
compiler.getDiagnosticOpts().Warnings = std::move(Opts.Warnings);
|
|
compiler.getDiagnosticOpts().Warnings = std::move(Opts.Warnings);
|
|
|
|
+ compiler.getDiagnosticOpts().VerifyDiagnostics = Opts.VerifyDiagnostics;
|
|
compiler.createDiagnostics(diagPrinter, false);
|
|
compiler.createDiagnostics(diagPrinter, false);
|
|
// don't output warning to stderr/file if "/no-warnings" is present.
|
|
// don't output warning to stderr/file if "/no-warnings" is present.
|
|
compiler.getDiagnostics().setIgnoreAllWarnings(!Opts.OutputWarnings);
|
|
compiler.getDiagnostics().setIgnoreAllWarnings(!Opts.OutputWarnings);
|