From ce5d277b2bd623f726af9e7a7cbbcad7bca5c210 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 23 Apr 2026 20:18:13 +0000 Subject: [PATCH 1/5] Fix AsmParse::error to always use stderr, matching the warn change from PR #125320 Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/c22bcf9e-557c-49cc-aa89-0e9ce13e9895 Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> --- src/coreclr/ilasm/grammar_after.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/ilasm/grammar_after.cpp b/src/coreclr/ilasm/grammar_after.cpp index 6422ed744be361..5f646864226802 100644 --- a/src/coreclr/ilasm/grammar_after.cpp +++ b/src/coreclr/ilasm/grammar_after.cpp @@ -1809,7 +1809,7 @@ void AsmParse::error(const char* fmt, ...) { char *sz = (char*)(&wzUniBuf[(dwUniBuf >> 1)]); char *psz=&sz[0]; - FILE* pF = ((!assem->m_fReportProgress)&&(assem->OnErrGo)) ? stdout : stderr; + FILE* pF = stderr; success = false; va_list args; va_start(args, fmt); From 81b0888e4a0743605d9114efc19354698503f178 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Thu, 23 Apr 2026 13:32:36 -0700 Subject: [PATCH 2/5] Apply suggestion from @jkotas --- src/coreclr/ilasm/grammar_after.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/coreclr/ilasm/grammar_after.cpp b/src/coreclr/ilasm/grammar_after.cpp index 5f646864226802..e2e017f27b4d50 100644 --- a/src/coreclr/ilasm/grammar_after.cpp +++ b/src/coreclr/ilasm/grammar_after.cpp @@ -1807,6 +1807,7 @@ void PrintANSILine(FILE* pF, _In_ __nullterminated char* sz) /**************************************************************************/ void AsmParse::error(const char* fmt, ...) { + if(assem->OnErrGo) return; char *sz = (char*)(&wzUniBuf[(dwUniBuf >> 1)]); char *psz=&sz[0]; FILE* pF = stderr; From 13db2074b92dc0a9e60bde15e6a1d98fe6c83613 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 23 Apr 2026 20:58:37 +0000 Subject: [PATCH 3/5] Simplify error prefix in AsmParse::error to always use "error : " Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/4d756fde-61d9-46e9-9da8-dd00da09f67e Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> --- src/coreclr/ilasm/grammar_after.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/ilasm/grammar_after.cpp b/src/coreclr/ilasm/grammar_after.cpp index e2e017f27b4d50..f624555da12e83 100644 --- a/src/coreclr/ilasm/grammar_after.cpp +++ b/src/coreclr/ilasm/grammar_after.cpp @@ -1816,7 +1816,7 @@ void AsmParse::error(const char* fmt, ...) va_start(args, fmt); if((penv) && (penv->in)) psz+=sprintf_s(psz, (dwUniBuf >> 1), "%s(%d) : ", penv->in->name(), penv->curLine); - psz+=sprintf_s(psz, (dwUniBuf >> 1), assem->OnErrGo ? "warning : " : "error : "); + psz+=sprintf_s(psz, (dwUniBuf >> 1), "error : "); _vsnprintf_s(psz, (dwUniBuf >> 1),(dwUniBuf >> 1)-strlen(sz)-1, fmt, args); PrintANSILine(pF,sz); } From 37e39b1b8a06b576e9c4cfe12dd9b1ffb02703c0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 23 Apr 2026 21:04:21 +0000 Subject: [PATCH 4/5] Remove no-op OnErrGo-gated error calls in assembler.cpp Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/55305342-7494-4b3d-b27c-fd933da916e1 Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> --- src/coreclr/ilasm/assembler.cpp | 64 +++++++++------------------------ 1 file changed, 17 insertions(+), 47 deletions(-) diff --git a/src/coreclr/ilasm/assembler.cpp b/src/coreclr/ilasm/assembler.cpp index aaafa258a5be10..75557f287efbce 100644 --- a/src/coreclr/ilasm/assembler.cpp +++ b/src/coreclr/ilasm/assembler.cpp @@ -386,25 +386,15 @@ DWORD Assembler::CheckClassFlagsIfNested(Class* pEncloser, DWORD attr) DWORD wasAttr = attr; if(pEncloser && (!IsTdNested(attr))) { - if(OnErrGo) - report->error("Nested class has non-nested visibility (0x%08X)\n",attr); - else - { - attr &= ~tdVisibilityMask; - attr |= (IsTdPublic(wasAttr) ? tdNestedPublic : tdNestedPrivate); - report->warn("Nested class has non-nested visibility (0x%08X), changed to nested (0x%08X)\n",wasAttr,attr); - } + attr &= ~tdVisibilityMask; + attr |= (IsTdPublic(wasAttr) ? tdNestedPublic : tdNestedPrivate); + report->warn("Nested class has non-nested visibility (0x%08X), changed to nested (0x%08X)\n",wasAttr,attr); } else if((pEncloser==NULL) && IsTdNested(attr)) { - if(OnErrGo) - report->error("Non-nested class has nested visibility (0x%08X)\n",attr); - else - { - attr &= ~tdVisibilityMask; - attr |= (IsTdNestedPublic(wasAttr) ? tdPublic : tdNotPublic); - report->warn("Non-nested class has nested visibility (0x%08X), changed to non-nested (0x%08X)\n",wasAttr,attr); - } + attr &= ~tdVisibilityMask; + attr |= (IsTdNestedPublic(wasAttr) ? tdPublic : tdNotPublic); + report->warn("Non-nested class has nested visibility (0x%08X), changed to non-nested (0x%08X)\n",wasAttr,attr); } return attr; } @@ -533,12 +523,8 @@ void Assembler::AddClass() { if(!IsTdSealed(attr)) { - if(OnErrGo) report->error("Non-sealed value class\n"); - else - { - report->warn("Non-sealed value class, made sealed\n"); - m_pCurClass->m_Attr |= tdSealed; - } + report->warn("Non-sealed value class, made sealed\n"); + m_pCurClass->m_Attr |= tdSealed; } } m_pCurClass->m_bIsMaster = FALSE; @@ -626,12 +612,8 @@ void Assembler::StartMethod(_In_ __nullterminated char* name, BinStr* sig, CorMe *(sig->ptr()) |= IMAGE_CEE_CS_CALLCONV_HASTHIS; else if(*(sig->ptr()) & (IMAGE_CEE_CS_CALLCONV_HASTHIS | IMAGE_CEE_CS_CALLCONV_EXPLICITTHIS)) { - if(OnErrGo) report->error("Method '%s' -- both static and instance\n", name); - else - { - report->warn("Method '%s' -- both static and instance, set to static\n", name); - *(sig->ptr()) &= ~(IMAGE_CEE_CS_CALLCONV_HASTHIS | IMAGE_CEE_CS_CALLCONV_EXPLICITTHIS); - } + report->warn("Method '%s' -- both static and instance, set to static\n", name); + *(sig->ptr()) &= ~(IMAGE_CEE_CS_CALLCONV_HASTHIS | IMAGE_CEE_CS_CALLCONV_EXPLICITTHIS); } if(!IsMdPrivateScope(flags)) @@ -713,22 +695,14 @@ void Assembler::StartMethod(_In_ __nullterminated char* name, BinStr* sig, CorMe { if(IsMdAbstract(flags)) { - if(OnErrGo) report->error("Global method '%s' can't be abstract\n",name); - else - { - report->warn("Global method '%s' can't be abstract, flag removed\n",name); - flags = (CorMethodAttr)(((int) flags) &~mdAbstract); - } + report->warn("Global method '%s' can't be abstract, flag removed\n",name); + flags = (CorMethodAttr)(((int) flags) &~mdAbstract); } if(!IsMdStatic(flags)) { - if(OnErrGo) report->error("Non-static global method '%s'\n",name); - else - { - report->warn("Non-static global method '%s', made static\n",name); - flags = (CorMethodAttr)(flags | mdStatic); - *((BYTE*)(sig->ptr())) &= ~(IMAGE_CEE_CS_CALLCONV_HASTHIS | IMAGE_CEE_CS_CALLCONV_EXPLICITTHIS); - } + report->warn("Non-static global method '%s', made static\n",name); + flags = (CorMethodAttr)(flags | mdStatic); + *((BYTE*)(sig->ptr())) &= ~(IMAGE_CEE_CS_CALLCONV_HASTHIS | IMAGE_CEE_CS_CALLCONV_EXPLICITTHIS); } m_pCurMethod = new Method(this, m_pCurClass, name, sig, flags); if (m_pCurMethod) @@ -842,12 +816,8 @@ void Assembler::AddField(__inout_z __inout char* name, BinStr* sig, CorFieldAttr } if(!IsFdStatic(flags)) { - if(OnErrGo) report->error("Non-static global field\n"); - else - { - report->warn("Non-static global field, made static\n"); - flags = (CorFieldAttr)(flags | fdStatic); - } + report->warn("Non-static global field, made static\n"); + flags = (CorFieldAttr)(flags | fdStatic); } } pClass = (m_pCurClass ? m_pCurClass : m_pModuleClass); From 162f89602a24f88bfb334f0aa7f94be8a09e8e00 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 23 Apr 2026 21:41:49 +0000 Subject: [PATCH 5/5] Preserve functional behavior when OnErrGo is set in assembler.cpp Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/302eec63-31c8-415e-a964-5d7cd93009be Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> --- src/coreclr/ilasm/assembler.cpp | 55 +++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/src/coreclr/ilasm/assembler.cpp b/src/coreclr/ilasm/assembler.cpp index 75557f287efbce..5096bbdda453fa 100644 --- a/src/coreclr/ilasm/assembler.cpp +++ b/src/coreclr/ilasm/assembler.cpp @@ -386,15 +386,21 @@ DWORD Assembler::CheckClassFlagsIfNested(Class* pEncloser, DWORD attr) DWORD wasAttr = attr; if(pEncloser && (!IsTdNested(attr))) { - attr &= ~tdVisibilityMask; - attr |= (IsTdPublic(wasAttr) ? tdNestedPublic : tdNestedPrivate); - report->warn("Nested class has non-nested visibility (0x%08X), changed to nested (0x%08X)\n",wasAttr,attr); + if(!OnErrGo) + { + attr &= ~tdVisibilityMask; + attr |= (IsTdPublic(wasAttr) ? tdNestedPublic : tdNestedPrivate); + report->warn("Nested class has non-nested visibility (0x%08X), changed to nested (0x%08X)\n",wasAttr,attr); + } } else if((pEncloser==NULL) && IsTdNested(attr)) { - attr &= ~tdVisibilityMask; - attr |= (IsTdNestedPublic(wasAttr) ? tdPublic : tdNotPublic); - report->warn("Non-nested class has nested visibility (0x%08X), changed to non-nested (0x%08X)\n",wasAttr,attr); + if(!OnErrGo) + { + attr &= ~tdVisibilityMask; + attr |= (IsTdNestedPublic(wasAttr) ? tdPublic : tdNotPublic); + report->warn("Non-nested class has nested visibility (0x%08X), changed to non-nested (0x%08X)\n",wasAttr,attr); + } } return attr; } @@ -523,8 +529,11 @@ void Assembler::AddClass() { if(!IsTdSealed(attr)) { - report->warn("Non-sealed value class, made sealed\n"); - m_pCurClass->m_Attr |= tdSealed; + if(!OnErrGo) + { + report->warn("Non-sealed value class, made sealed\n"); + m_pCurClass->m_Attr |= tdSealed; + } } } m_pCurClass->m_bIsMaster = FALSE; @@ -612,8 +621,11 @@ void Assembler::StartMethod(_In_ __nullterminated char* name, BinStr* sig, CorMe *(sig->ptr()) |= IMAGE_CEE_CS_CALLCONV_HASTHIS; else if(*(sig->ptr()) & (IMAGE_CEE_CS_CALLCONV_HASTHIS | IMAGE_CEE_CS_CALLCONV_EXPLICITTHIS)) { - report->warn("Method '%s' -- both static and instance, set to static\n", name); - *(sig->ptr()) &= ~(IMAGE_CEE_CS_CALLCONV_HASTHIS | IMAGE_CEE_CS_CALLCONV_EXPLICITTHIS); + if(!OnErrGo) + { + report->warn("Method '%s' -- both static and instance, set to static\n", name); + *(sig->ptr()) &= ~(IMAGE_CEE_CS_CALLCONV_HASTHIS | IMAGE_CEE_CS_CALLCONV_EXPLICITTHIS); + } } if(!IsMdPrivateScope(flags)) @@ -695,14 +707,20 @@ void Assembler::StartMethod(_In_ __nullterminated char* name, BinStr* sig, CorMe { if(IsMdAbstract(flags)) { - report->warn("Global method '%s' can't be abstract, flag removed\n",name); - flags = (CorMethodAttr)(((int) flags) &~mdAbstract); + if(!OnErrGo) + { + report->warn("Global method '%s' can't be abstract, flag removed\n",name); + flags = (CorMethodAttr)(((int) flags) &~mdAbstract); + } } if(!IsMdStatic(flags)) { - report->warn("Non-static global method '%s', made static\n",name); - flags = (CorMethodAttr)(flags | mdStatic); - *((BYTE*)(sig->ptr())) &= ~(IMAGE_CEE_CS_CALLCONV_HASTHIS | IMAGE_CEE_CS_CALLCONV_EXPLICITTHIS); + if(!OnErrGo) + { + report->warn("Non-static global method '%s', made static\n",name); + flags = (CorMethodAttr)(flags | mdStatic); + *((BYTE*)(sig->ptr())) &= ~(IMAGE_CEE_CS_CALLCONV_HASTHIS | IMAGE_CEE_CS_CALLCONV_EXPLICITTHIS); + } } m_pCurMethod = new Method(this, m_pCurClass, name, sig, flags); if (m_pCurMethod) @@ -816,8 +834,11 @@ void Assembler::AddField(__inout_z __inout char* name, BinStr* sig, CorFieldAttr } if(!IsFdStatic(flags)) { - report->warn("Non-static global field, made static\n"); - flags = (CorFieldAttr)(flags | fdStatic); + if(!OnErrGo) + { + report->warn("Non-static global field, made static\n"); + flags = (CorFieldAttr)(flags | fdStatic); + } } } pClass = (m_pCurClass ? m_pCurClass : m_pModuleClass);