Open Raduq91 opened 8 months ago
Reduced test based on following output:
clang-cl /E /EHsc /Iinclude test.cpp > x1.cpp
clang-cl /EHsc x1.cpp
test.cpp(3,93): error: expected ';' after top level declarator
3 | __declspec(allocate("cr_tst")) struct criterion_test *misc_failing_ptr = &misc_failing_meta
| ^
| ;
test.cpp(7,93): error: expected ';' after top level declarator
7 | __declspec(allocate("cr_tst")) struct criterion_test *misc_skipped_ptr = &misc_skipped_meta
| ^
| ;
2 errors generated.
https://godbolt.org/z/PxaazWPa4
#pragma warning(push)
int a
#pragma warning(pop)
;
#pragma data_seg(push)
int x = 1
#pragma data_seg(pop)
;
#pragma const_seg(push)
const char y[] = "2"
#pragma const_seg(pop)
;
#pragma bss_seg(push)
int z
#pragma bss_seg(pop)
;
clang++: warning: argument unused during compilation: '--gcc-toolchain=/opt/compiler-explorer/gcc-snapshot' [-Wunused-command-line-argument]
<source>:7:10: error: expected ';' after top level declarator
7 | int x = 1
| ^
| ;
<source>:12:21: error: expected ';' after top level declarator
12 | const char y[] = "2"
| ^
| ;
<source>:17:6: error: expected ';' after top level declarator
17 | int z
| ^
| ;
3 errors generated.
Compiler returned: 1
@llvm/issue-subscribers-clang-frontend
Author: None (Raduq91)
Note this looks specific to --target=x86_64-pc-windows-msvc
if we remove that the diagnostics go away.
CC @AaronBallman
It's specific to -fms-compatibility
and the issue occurs as far back as Clang 3.5. The problem is that we're getting annotation tokens and we expect either a comma or a semicolon (https://github.com/llvm/llvm-project/blob/5c3d001668ec6117045a9750a1f9d7e3995adfee/clang/lib/Parse/ParseDecl.cpp#L2429). You can see the same issue with: https://godbolt.org/z/rjdcnzvrM
Windows 10 x64
Clang llvm 18.1.1, I can't use criterion test frame work library. https://github.com/Snaipe/Criterion
( https://github.com/Snaipe/Criterion/issues/282#issuecomment-449566245 ) with --target=x86_64-w64-windows-gnu :
With toolset Visual Studio 2022 (v143) and intel compiler it builds without issue.
( used this to add clang llvm as toolset option in VS2022:https://github.com/zufuliu/llvm-utils ) clang llvm build error list:
build log:
adding --target=x86_64-w64-windows-gnu breaks the include headers:
sample code:
Criterion lib: This version has windows build to download(built from src using the latest version with mingw64 and it was the same issue with clang llvm) https://github.com/Snaipe/Criterion/releases/tag/v2.3.2 I used criterion-v2.3.2-windows-msvc-x86_64.tar.bz2