Skip to content

Commit f746f77

Browse files
ozone10donho
authored andcommitted
Fix msys2 clang build
Fix notepad-plus-plus#17448, close notepad-plus-plus#17449
1 parent 7d684c7 commit f746f77

File tree

21 files changed

+235
-184
lines changed

21 files changed

+235
-184
lines changed

.github/workflows/CI_build.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,35 +170,35 @@ jobs:
170170

171171
- name: Archive artifacts for x64 / Release
172172
if: matrix.build_platform == 'x64' && matrix.build_configuration == 'Release'
173-
uses: actions/upload-artifact@v5
173+
uses: actions/upload-artifact@v6
174174
with:
175175
name: Notepad++.MSVC.${{ matrix.build_platform}}.${{ matrix.build_configuration}}
176176
path: PowerEditor\bin64\Notepad++.exe
177177

178178
- name: Archive artifacts for Win32 / Release
179179
if: matrix.build_platform == 'Win32' && matrix.build_configuration == 'Release'
180-
uses: actions/upload-artifact@v5
180+
uses: actions/upload-artifact@v6
181181
with:
182182
name: Notepad++.MSVC.${{ matrix.build_platform}}.${{ matrix.build_configuration}}
183183
path: PowerEditor\bin\Notepad++.exe
184184

185185
- name: Archive artifacts for ARM64 / Release
186186
if: matrix.build_platform == 'ARM64' && matrix.build_configuration == 'Release'
187-
uses: actions/upload-artifact@v5
187+
uses: actions/upload-artifact@v6
188188
with:
189189
name: Notepad++.MSVC.${{ matrix.build_platform}}.${{ matrix.build_configuration}}
190190
path: PowerEditor\binarm64\Notepad++.exe
191191

192192
- name: Archive artifacts for ARM64|x64 / Debug
193193
if: (matrix.build_platform == 'ARM64' || matrix.build_platform == 'x64') && matrix.build_configuration == 'Debug'
194-
uses: actions/upload-artifact@v5
194+
uses: actions/upload-artifact@v6
195195
with:
196196
name: Notepad++.MSVC.${{ matrix.build_platform}}.${{ matrix.build_configuration}}
197197
path: PowerEditor\visual.net\${{ matrix.build_platform}}\${{ matrix.build_configuration}}\Notepad++.exe
198198

199199
- name: Archive artifacts for Win32 / Debug
200200
if: matrix.build_platform == 'Win32' && matrix.build_configuration == 'Debug'
201-
uses: actions/upload-artifact@v5
201+
uses: actions/upload-artifact@v6
202202
with:
203203
name: Notepad++.MSVC.${{ matrix.build_platform}}.${{ matrix.build_configuration}}
204204
path: PowerEditor\visual.net\${{ matrix.build_configuration}}\Notepad++.exe
@@ -336,6 +336,7 @@ jobs:
336336
strategy:
337337
fail-fast: false
338338
matrix:
339+
build_compiler: [gcc]
339340
build_configuration: [Release, Debug]
340341
build_platform: [x86_64, i686]
341342

@@ -351,7 +352,8 @@ jobs:
351352
$newContent = $content -replace 'TEXT\(\"Notepad\+\+ v.*\"\)', 'TEXT("Notepad++ GH_BUILD")'
352353
$newContent | Set-Content -Path 'resource.h'
353354
354-
- name: Make n++ exe
355+
- name: Make n++ exe / gcc
356+
if: matrix.build_compiler == 'gcc'
355357
working-directory: .\
356358
run: |
357359
Write-host "${{ matrix.build_platform }}"
@@ -374,14 +376,14 @@ jobs:
374376
375377
- name: Archive artifacts for ${{ matrix.build_platform}} / Release
376378
if: matrix.build_configuration == 'Release'
377-
uses: actions/upload-artifact@v5
379+
uses: actions/upload-artifact@v6
378380
with:
379-
name: Notepad++.GCC.${{ matrix.build_platform}}.${{ matrix.build_configuration}}
380-
path: bin.${{ matrix.build_platform}}\notepad++.exe
381+
name: Notepad++.${{ matrix.build_compiler}}.${{ matrix.build_platform}}.${{ matrix.build_configuration}}
382+
path: bin.${{ matrix.build_compiler}}.${{ matrix.build_platform}}\notepad++.exe
381383

382384
- name: Archive artifacts for ${{ matrix.build_platform}} / Debug
383385
if: matrix.build_configuration == 'Debug'
384-
uses: actions/upload-artifact@v5
386+
uses: actions/upload-artifact@v6
385387
with:
386-
name: Notepad++.GCC.${{ matrix.build_platform}}.${{ matrix.build_configuration}}
387-
path: bin.${{ matrix.build_platform}}-debug\notepad++.exe
388+
name: Notepad++.${{ matrix.build_compiler}}.${{ matrix.build_platform}}.${{ matrix.build_configuration}}
389+
path: bin.${{ matrix.build_compiler}}.${{ matrix.build_platform}}-debug\notepad++.exe

PowerEditor/gcc/makefile

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
# definitions
1919
#
2020

21+
MAKEFILE_ABS_DIR = $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
22+
2123
GCC_DIRECTORY := ../gcc
2224
GCC_EXCLUDE := $(GCC_DIRECTORY)/gcc-%
2325
SRC_DIRECTORY := ../src
@@ -38,8 +40,11 @@ LEXILLA_TARGET := liblexilla.a
3840

3941
ifeq ($(CXX),clang++)
4042
CXX := $(CROSS_COMPILE)clang++
43+
SCI_CLANG := 1
44+
COMPILER_SUFFIX := clang.
4145
else
4246
CXX := $(CROSS_COMPILE)g++
47+
COMPILER_SUFFIX := gcc.
4348
endif
4449

4550
CXXFLAGS := -include $(GCC_DIRECTORY)/gcc-fixes.h -std=c++20
@@ -74,26 +79,34 @@ CXXFLAGS += -Og \
7479
-Wextra-semi \
7580
-Wformat=2 \
7681
-Wmisleading-indentation \
77-
-Wunused \
78-
-Wno-cast-function-type \
79-
-Wno-overloaded-virtual
82+
-Wunused
8083
CPP_DEFINE += DEBUG
8184
endif
8285

8386
ifeq ($(CXX),clang++)
84-
CXXFLAGS += -Wimplicit-fallthrough \
87+
CXXFLAGS += -Wpedantic \
88+
-Wall \
89+
-Wextra \
90+
-Wimplicit-fallthrough \
8591
-Wno-c++98-compat \
8692
-Wno-c++98-compat-pedantic \
87-
-Wno-reserved-id-macro \
88-
-Wno-pragma-pack \
89-
-Wno-unknown-pragmas \
90-
-Wno-unused-command-line-argument \
93+
-Wno-c99-extensions \
94+
-Wno-cast-align \
95+
-Wno-deprecated-declarations \
96+
-Wno-nested-anon-types \
9197
-Wno-overloaded-virtual \
98+
-Wno-padded \
99+
-Wno-pragma-pack \
100+
-Wno-reserved-id-macro \
101+
-Wno-reserved-identifier \
92102
-Wno-sign-conversion \
93-
-Wno-c99-extensions \
94-
-Wno-deprecated-declarations
95-
else ifeq ($(BUILD_TYPE),release)
96-
CXXFLAGS += -Wno-alloc-size-larger-than
103+
-Wno-switch-default \
104+
-Wno-unsafe-buffer-usage \
105+
-Wno-unsafe-buffer-usage-in-libc-call \
106+
-Wno-unused-command-line-argument
107+
else
108+
CXXFLAGS += -Wno-cast-function-type \
109+
-Wno-overloaded-virtual
97110
endif
98111

99112
ifneq "$(filter-out 0,$(CLANGANALYZE))" ""
@@ -135,7 +148,7 @@ export RC += -Fpe-x86-64
135148
endif
136149

137150
# define target and build directories and update dependent variables
138-
TARGET_DIRECTORY := bin.$(TARGET_CPU)$(BUILD_SUFFIX)
151+
TARGET_DIRECTORY := bin.$(COMPILER_SUFFIX)$(TARGET_CPU)$(BUILD_SUFFIX)
139152
BUILD_DIRECTORY := $(TARGET_DIRECTORY).build
140153

141154
TARGET_BINARY := $(TARGET_DIRECTORY)/$(TARGET_BINARY)
@@ -195,7 +208,7 @@ CPDIR := cp -r
195208
RMDIR := rm -rf
196209
CP := cp
197210
RM := rm -f
198-
PREBUILD_EVENT_CMD := cmd //C "cd PowerEditor/src && NppLibsVersionH-generator.bat"
211+
PREBUILD_EVENT_CMD := cmd //C "$(MAKEFILE_ABS_DIR)/../src/NppLibsVersionH-generator.bat"
199212
normalize-path = $1
200213
else ifneq "$(wildcard $(dir $(SHELL))ls.exe)" ""
201214
# a Windows system with a proper shell
@@ -207,7 +220,7 @@ CPDIR := $(SHELL_DIRECTORY)cp.exe -r
207220
RMDIR := $(SHELL_DIRECTORY)rm.exe -rf
208221
CP := $(SHELL_DIRECTORY)cp.exe
209222
RM := $(SHELL_DIRECTORY)rm.exe -f
210-
PREBUILD_EVENT_CMD := cmd //C "cd PowerEditor/src && NppLibsVersionH-generator.bat"
223+
PREBUILD_EVENT_CMD := cmd //C "$(MAKEFILE_ABS_DIR)/../src/NppLibsVersionH-generator.bat"
211224
normalize-path = $1
212225
else
213226
# a standard Windows system
@@ -269,10 +282,10 @@ $(LEXILLA_TARGET): .force
269282
endif
270283

271284
$(SCINTILLA_TARGET): | $(BUILD_DIRECTORY) $(SCINTILLA_BUILD_DIRECTORY)
272-
$(AT)$(MAKE) $(SUBMAKEFLAGS) -C $(SCINTILLA_DIRECTORY)/win32 -f makefile -f ../../boostregex/nppSpecifics_mingw.mak DIR_O=$(SCINTILLA_BUILD_PATH) LIBSCI=$(SCINTILLA_TARGET_PATH) $(SCINTILLA_TARGET_PATH)
285+
$(AT)$(MAKE) $(SUBMAKEFLAGS) -C $(SCINTILLA_DIRECTORY)/win32 -f makefile -f ../../boostregex/nppSpecifics_mingw.mak DIR_O=$(SCINTILLA_BUILD_PATH) LIBSCI=$(SCINTILLA_TARGET_PATH) $(SCINTILLA_TARGET_PATH) CLANG=$(SCI_CLANG)
273286

274287
$(LEXILLA_TARGET): | $(BUILD_DIRECTORY) $(LEXILLA_BUILD_DIRECTORY)
275-
$(AT)$(MAKE) $(SUBMAKEFLAGS) -C $(LEXILLA_DIRECTORY)/src DIR_O=$(LEXILLA_BUILD_PATH) LIBLEXILLA=$(LEXILLA_TARGET_PATH) $(LEXILLA_TARGET_PATH)
288+
$(AT)$(MAKE) $(SUBMAKEFLAGS) -C $(LEXILLA_DIRECTORY)/src DIR_O=$(LEXILLA_BUILD_PATH) LIBLEXILLA=$(LEXILLA_TARGET_PATH) $(LEXILLA_TARGET_PATH) CLANG=$(SCI_CLANG)
276289

277290
binary: $(TARGET_BINARY) data
278291
@echo +++ $(TARGET_CPU) $(BUILD_TYPE) : $(CURDIR)/$(TARGET_BINARY) +++

PowerEditor/src/MISC/Common/Common.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -833,15 +833,15 @@ std::wstring stringToUpper(std::wstring strToConvert)
833833
{
834834
static const auto loc = std::locale("");
835835
std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(),
836-
[](wchar_t ch) { return std::toupper(ch, loc); });
836+
[](auto ch) { return std::toupper(ch, loc); });
837837
return strToConvert;
838838
}
839839

840840
std::wstring stringToLower(std::wstring strToConvert)
841841
{
842842
static const auto loc = std::locale("");
843843
std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(),
844-
[](wchar_t ch) { return std::tolower(ch, loc); });
844+
[](auto ch) { return std::tolower(ch, loc); });
845845
return strToConvert;
846846
}
847847

@@ -1754,7 +1754,7 @@ bool isUnsupportedFileName(const wstring& fileName)
17541754
// upperize because the std::find is case sensitive unlike the Windows OS filesystem
17551755
static const auto& loc = std::locale::classic();
17561756
std::transform(fileNameOnly.begin(), fileNameOnly.end(), fileNameOnly.begin(),
1757-
[](wchar_t ch) { return std::toupper(ch, loc); });
1757+
[](auto ch) { return std::toupper(ch, loc); });
17581758

17591759
const std::vector<std::wstring> reservedWin32NamespaceDeviceList {
17601760
L"CON", L"PRN", L"AUX", L"NUL",
@@ -2111,11 +2111,12 @@ bool doesPathExist(const wchar_t* path, DWORD milliSec2wait, bool* isTimeoutReac
21112111
return (attributes.dwFileAttributes != INVALID_FILE_ATTRIBUTES);
21122112
}
21132113

2114-
2115-
#if defined(__GNUC__)
2116-
#define LAMBDA_STDCALL __attribute__((__stdcall__))
2114+
#if defined(__GNUC__) && __GNUC__ > 8
2115+
#define WINAPI_LAMBDA_RETURN(return_t) -> return_t WINAPI
2116+
#elif defined(__GNUC__)
2117+
#define WINAPI_LAMBDA_RETURN(return_t) WINAPI -> return_t
21172118
#else
2118-
#define LAMBDA_STDCALL
2119+
#define WINAPI_LAMBDA_RETURN(return_t) -> return_t
21192120
#endif
21202121

21212122
// check if the window rectangle intersects with any currently active monitor's working area
@@ -2129,7 +2130,7 @@ bool isWindowVisibleOnAnyMonitor(const RECT& rectWndIn)
21292130
};
21302131

21312132
// callback func to check for intersection with each existing monitor
2132-
auto callback = []([[maybe_unused]] HMONITOR hMon, [[maybe_unused]] HDC hdc, LPRECT lprcMon, LPARAM lpInOut) -> BOOL LAMBDA_STDCALL
2133+
auto callback = []([[maybe_unused]] HMONITOR hMon, [[maybe_unused]] HDC hdc, LPRECT lprcMon, LPARAM lpInOut) WINAPI_LAMBDA_RETURN(BOOL)
21332134
{
21342135
Param4InOut* paramInOut = reinterpret_cast<Param4InOut*>(lpInOut);
21352136
RECT rectIntersection{};

PowerEditor/src/MISC/sha1/sha1.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,10 @@ class CSHA1
247247
// Member variables
248248
UINT_32 m_state[5];
249249
UINT_32 m_count[2];
250-
UINT_32 m_reserved0[1]; // Memory alignment padding
250+
[[maybe_unused]] UINT_32 m_reserved0[1]; // Memory alignment padding
251251
UINT_8 m_buffer[64];
252252
UINT_8 m_digest[20];
253-
UINT_32 m_reserved1[3]; // Memory alignment padding
253+
[[maybe_unused]] UINT_32 m_reserved1[3]; // Memory alignment padding
254254

255255
UINT_8 m_workspace[64];
256256
SHA1_WORKSPACE_BLOCK* m_block; // SHA1 pointer to the byte array above

PowerEditor/src/Notepad_plus.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3097,7 +3097,7 @@ void Notepad_plus::setUniModeText()
30973097
int cmdID = em.getIndexFromEncoding(encoding);
30983098
if (cmdID == -1)
30993099
{
3100-
assert(!"Encoding problem. Encoding is not added in encoding_table?");
3100+
assert(false && "Encoding problem. Encoding is not added in encoding_table?");
31013101
return;
31023102
}
31033103
cmdID += IDM_FORMAT_ENCODE;

PowerEditor/src/NppLibsVersionH-generator.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
@echo off
22

3+
setlocal
4+
cd /d %~dp0
5+
36
rem If this batch file is called from the Microsoft Visual Studio pre-build event,
47
rem then the current dir for this bat-file is set to Notepad++ solution/project dir.
58
rem Because in this batch file we have to go two dir-levels higher (for finding the files

PowerEditor/src/Parameters.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ struct GlobalOverride final
370370

371371
struct StyleArray
372372
{
373-
const auto begin() const { return _styleVect.begin(); }
374-
const auto end() const { return _styleVect.end(); }
373+
auto begin() const { return _styleVect.begin(); }
374+
auto end() const { return _styleVect.end(); }
375375
auto begin() { return _styleVect.begin(); }
376376
auto end() { return _styleVect.end(); }
377377
void clear() { _styleVect.clear(); }
@@ -420,7 +420,9 @@ struct StyleArray
420420
struct LexerStyler : public StyleArray
421421
{
422422
public:
423-
LexerStyler & operator=(const LexerStyler & ls)
423+
LexerStyler() noexcept = default;
424+
LexerStyler(const LexerStyler& ls) noexcept = default;
425+
LexerStyler& operator=(const LexerStyler& ls)
424426
{
425427
if (this != &ls)
426428
{

PowerEditor/src/ScintillaComponent/AutoCompletion.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ static bool isAllDigits(const std::string& str)
281281
{
282282
static const auto& loc = std::locale::classic();
283283
return std::all_of(str.begin(), str.end(),
284-
[](unsigned char c) { return std::isdigit(c, loc); });
284+
[](auto c) { return std::isdigit(c, loc); });
285285
}
286286

287287
static void sortInsensitive(std::vector<std::string>& wordArray)
@@ -295,7 +295,7 @@ static void sortInsensitive(std::vector<std::string>& wordArray)
295295
return lexicographical_compare(
296296
a.begin(), a.end(),
297297
b.begin(), b.end(),
298-
[](const unsigned char &ch1, const unsigned char &ch2)
298+
[](const auto &ch1, const auto &ch2)
299299
{
300300
return std::toupper(ch1, loc) < std::toupper(ch2, loc);
301301
}

PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4871,7 +4871,7 @@ void FindReplaceDlg::doDialog(DIALOG_TYPE whichType, bool isRTL, bool toShow)
48714871
enableReplaceFunc(whichType == REPLACE_DLG);
48724872

48734873
::SetFocus(toShow ? ::GetDlgItem(_hSelf, IDFINDWHAT) : (*_ppEditView)->getHSelf());
4874-
display(toShow, true);
4874+
StaticDialog::displayEnhanced(toShow);
48754875
}
48764876

48774877
LRESULT CALLBACK FindReplaceDlg::FinderProc(
@@ -4942,9 +4942,9 @@ LRESULT CALLBACK FindReplaceDlg::FinderProc(
49424942
return ::DefSubclassProc(hWnd, uMsg, wParam, lParam);
49434943
}
49444944

4945-
bool isUnexpectedInvisible(wchar_t ch)
4945+
static bool isUnexpectedInvisible(wchar_t ch)
49464946
{
4947-
if (ch >= 0x0000 && ch <= 0x001F) // includ EOL
4947+
if (ch <= 0x001F) // includ EOL
49484948
{
49494949
return (ch != L'\t'); // Tab is not considered as unexpected "invisible" characters
49504950
}
@@ -4986,7 +4986,7 @@ bool isUnexpectedInvisible(wchar_t ch)
49864986
}
49874987
}
49884988

4989-
bool containsInvisibleChar(const std::wstring& text)
4989+
static bool containsInvisibleChar(const std::wstring& text)
49904990
{
49914991
for (wchar_t ch : text)
49924992
{

PowerEditor/src/ScintillaComponent/FunctionCallTip.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ static int testNameNoCase(const char* name1, const char* name2, int len = -1)
5555

5656
for (int i = 0; i < len; ++i)
5757
{
58-
const unsigned char char1 = name1[i];
59-
const unsigned char char2 = name2[i];
58+
const char char1 = name1[i];
59+
const char char2 = name2[i];
6060

6161
if (char1 == '\0' || char2 == '\0') // null terminator check
6262
return char1 - char2;

0 commit comments

Comments
 (0)