Skip to content

Commit

Permalink
meson: Add more tests for system includes
Browse files Browse the repository at this point in the history
  • Loading branch information
artem committed Nov 5, 2024
1 parent 9bbcc0b commit be55a8f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#include <stdbool.h>

/* Attempt to trigger -Wsizeof-array-div */
extern int arr1[10];
const int C0 = sizeof(arr1) / sizeof(short);
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#include <stdbool.h>

/* Attempt to trigger -Wsizeof-array-div */
extern int arr1[10];
const int C1 = sizeof(arr1) / sizeof(short);
6 changes: 6 additions & 0 deletions test cases/linuxlike/16 isystem includes/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <my_global_lib/my_global.h>
#include <my_local1_lib/my_local1.h>

int main() {
return C0 + C1;
}
23 changes: 23 additions & 0 deletions test cases/linuxlike/16 isystem includes/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
project('isystem includes', 'c', default_options : 'werror=true')

cc = meson.get_compiler('c')

# Canary warning to check suppression in system headers. Chosen randomly from GCC docs.
incwarg = '-Wsizeof-array-div'

add_project_dependencies(
declare_dependency(
include_directories: include_directories('global_include', is_system: true),
),
language: ['c'],
)

local_inc_dep1 = declare_dependency(
include_directories: 'local_include1',
).as_system().partial_dependency(includes : true)

if cc.has_argument(incwarg)
executable('main', 'main.c', c_args: incwarg, dependencies: local_inc_dep1)
else
error('MESON_SKIP_TEST compiler does not support emitting canary warning.')
endif

0 comments on commit be55a8f

Please sign in to comment.