Skip to content

Commit

Permalink
Instatiate macros in the compile tests
Browse files Browse the repository at this point in the history
This requires suppressing `no-c++11-long-long` in C++98/03 (and
`c++98-compat-pedantic` in others).
  • Loading branch information
kainino0x committed Oct 24, 2023
1 parent 92c2b1a commit fb3d7be
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 28 deletions.
1 change: 1 addition & 0 deletions tests/compile/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.out
50 changes: 28 additions & 22 deletions tests/compile/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,33 @@ all: main-c.out main-cpp.out
clean:
rm -f main-c.out main-cpp.out

CLANG_WARNINGS = -Weverything -Wno-padded -Wno-poison-system-directories
GCC_WARNINGS = -Wall -Wextra
CLANG_WARNINGS = -Werror -Weverything -Wno-padded -Wno-poison-system-directories -Wno-c++98-compat-pedantic
GCC_WARNINGS = -Werror -Wall -Wextra

main-c.out: main.c ../../webgpu.h Makefile
clang -std=c99 $(CLANG_WARNINGS) -o $@ $<
gcc -std=c99 $(GCC_WARNINGS) -o $@ $<
clang -std=c11 $(CLANG_WARNINGS) -o $@ $<
gcc -std=c11 $(GCC_WARNINGS) -o $@ $<
clang -std=c17 $(CLANG_WARNINGS) -o $@ $<
gcc -std=c17 $(GCC_WARNINGS) -o $@ $<
main-c.out: main.c main.inl ../../webgpu.h Makefile
clang -o $@ $< -std=c99 $(CLANG_WARNINGS)
gcc -o $@ $< -std=c99 $(GCC_WARNINGS)
clang -o $@ $< -std=c11 $(CLANG_WARNINGS)
gcc -o $@ $< -std=c11 $(GCC_WARNINGS)
clang -o $@ $< -std=c17 $(CLANG_WARNINGS)
gcc -o $@ $< -std=c17 $(GCC_WARNINGS)
# Pre-release C23
clang -o $@ $< -std=c2x $(CLANG_WARNINGS)
gcc -o $@ $< -std=c2x $(GCC_WARNINGS)

main-cpp.out: main.cpp ../../webgpu.h Makefile
clang++ -std=c++98 $(CLANG_WARNINGS) -o $@ $<
g++ -std=c++98 $(GCC_WARNINGS) -o $@ $<
clang++ -std=c++03 $(CLANG_WARNINGS) -o $@ $<
g++ -std=c++03 $(GCC_WARNINGS) -o $@ $<
clang++ -std=c++11 $(CLANG_WARNINGS) -o $@ $<
g++ -std=c++11 $(GCC_WARNINGS) -o $@ $<
clang++ -std=c++14 $(CLANG_WARNINGS) -o $@ $<
g++ -std=c++14 $(GCC_WARNINGS) -o $@ $<
clang++ -std=c++17 $(CLANG_WARNINGS) -o $@ $<
g++ -std=c++17 $(GCC_WARNINGS) -o $@ $<
clang++ -std=c++20 $(CLANG_WARNINGS) -o $@ $<
g++ -std=c++20 $(GCC_WARNINGS) -o $@ $<
main-cpp.out: main.cpp main.inl ../../webgpu.h Makefile
clang++ -o $@ $< -std=c++98 $(CLANG_WARNINGS) -Wno-c++11-long-long
g++ -o $@ $< -std=c++98 $(GCC_WARNINGS)
clang++ -o $@ $< -std=c++03 $(CLANG_WARNINGS) -Wno-c++11-long-long
g++ -o $@ $< -std=c++03 $(GCC_WARNINGS)
clang++ -o $@ $< -std=c++11 $(CLANG_WARNINGS)
g++ -o $@ $< -std=c++11 $(GCC_WARNINGS)
clang++ -o $@ $< -std=c++14 $(CLANG_WARNINGS)
g++ -o $@ $< -std=c++14 $(GCC_WARNINGS)
clang++ -o $@ $< -std=c++17 $(CLANG_WARNINGS)
g++ -o $@ $< -std=c++17 $(GCC_WARNINGS)
clang++ -o $@ $< -std=c++20 $(CLANG_WARNINGS)
g++ -o $@ $< -std=c++20 $(GCC_WARNINGS)
# Pre-release C++23
clang++ -o $@ $< -std=c++2b $(CLANG_WARNINGS)
g++ -o $@ $< -std=c++2b $(GCC_WARNINGS)
4 changes: 1 addition & 3 deletions tests/compile/main.c
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
#include "../../webgpu.h"

int main(void) {}
#include "main.inl"
4 changes: 1 addition & 3 deletions tests/compile/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
#include "../../webgpu.h"

int main(void) {}
#include "main.inl"
43 changes: 43 additions & 0 deletions tests/compile/main.inl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "../../webgpu.h"

// Compile-test the instantiation of all of the macros, and spot-check types
int main(void) {
{
WGPUTextureViewDescriptor a;
a.mipLevelCount = WGPU_MIP_LEVEL_COUNT_UNDEFINED;
a.arrayLayerCount = WGPU_ARRAY_LAYER_COUNT_UNDEFINED;
(void) a;
}
{
WGPUTextureDataLayout a;
uint32_t x = a.bytesPerRow = WGPU_COPY_STRIDE_UNDEFINED;
uint32_t y = a.rowsPerImage = WGPU_COPY_STRIDE_UNDEFINED;
(void) a;
(void) x;
(void) y;
}
{
WGPUBindGroupEntry a;
uint64_t x = a.size = WGPU_WHOLE_SIZE;
(void) a;
(void) x;
}
{
uint64_t x = WGPU_WHOLE_MAP_SIZE;
(void) x;
}
{
WGPULimits a;
uint32_t x = a.maxTextureDimension2D = WGPU_LIMIT_U32_UNDEFINED;
uint64_t y = a.maxBufferSize = WGPU_LIMIT_U64_UNDEFINED;
(void) a;
(void) x;
(void) y;
}
{
WGPUComputePassTimestampWrites a;
a.beginningOfPassWriteIndex = WGPU_QUERY_SET_INDEX_UNDEFINED;
a.endOfPassWriteIndex = WGPU_QUERY_SET_INDEX_UNDEFINED;
(void) a;
}
}

0 comments on commit fb3d7be

Please sign in to comment.