Skip to content

Commit

Permalink
windows.cfg: Fix wrong FlushConsoleInputBuffer configuration (#5526)
Browse files Browse the repository at this point in the history
After flushing, the function returns. Before it was configured to
not-return.
A proper regression test was added.
  • Loading branch information
orbitcowboy committed Oct 7, 2023
1 parent d48df98 commit e9c39c1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cfg/windows.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4791,7 +4791,7 @@ HFONT CreateFont(
</function>
<!--BOOL WINAPI FlushConsoleInputBuffer(_In_ HANDLE hConsoleInput);-->
<function name="FlushConsoleInputBuffer">
<noreturn>true</noreturn>
<noreturn>false</noreturn>
<returnValue type="BOOL"/>
<leak-ignore/>
<arg nr="1" direction="in">
Expand Down
12 changes: 11 additions & 1 deletion test/cfg/windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

#include <windows.h>
#include <Windows.h>
#include <WinCon.h>
#include <cstdio>
#include <direct.h>
#include <cstdlib>
Expand All @@ -18,6 +19,15 @@
#include <atlstr.h>
#include <string>

/// https://learn.microsoft.com/en-us/windows/console/flushconsoleinputbuffer
BOOL unreachableCode_FlushConsoleInputBuffer(int &val)
{
const BOOL retVal = FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE));
// still reachable after call FlushConsoleInputBuffer()
val = 42;
return retVal;
}

/// https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulefilenamew
std::string constVariable_GetModuleFileName(void) {
char path[42];
Expand Down

0 comments on commit e9c39c1

Please sign in to comment.