tests/lint: add platform-specific tests
This commit is contained in:
parent
fb591c4d97
commit
f29e29e219
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: platform_ilp32.c,v 1.2 2021/09/26 14:28:22 rillig Exp $ */
|
||||
/* $NetBSD: platform_ilp32.c,v 1.3 2023/02/22 22:12:35 rillig Exp $ */
|
||||
# 3 "platform_ilp32.c"
|
||||
|
||||
/*
|
||||
|
@ -9,7 +9,20 @@
|
|||
/* lint1-extra-flags: -c -h -a -p -b -r -z */
|
||||
/* lint1-only-if: ilp32 */
|
||||
|
||||
// TODO: Add some code that passes.
|
||||
// TODO: Add some code that fails.
|
||||
int s32;
|
||||
unsigned int u32;
|
||||
long sl32;
|
||||
unsigned long ul32;
|
||||
|
||||
/* expect+1: warning: empty translation unit [272] */
|
||||
void
|
||||
convert_between_int_and_long(void)
|
||||
{
|
||||
/*
|
||||
* No warning about possible loss of accuracy, as the types have the
|
||||
* same size.
|
||||
*/
|
||||
s32 = sl32;
|
||||
sl32 = s32;
|
||||
u32 = ul32;
|
||||
ul32 = u32;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: platform_ldbl128.c,v 1.2 2021/09/26 14:28:22 rillig Exp $ */
|
||||
/* $NetBSD: platform_ldbl128.c,v 1.3 2023/02/22 22:12:35 rillig Exp $ */
|
||||
# 3 "platform_ldbl128.c"
|
||||
|
||||
/*
|
||||
|
@ -8,7 +8,6 @@
|
|||
/* lint1-extra-flags: -c -h -a -p -b -r -z */
|
||||
/* lint1-only-if: ldbl-128 */
|
||||
|
||||
// TODO: Add some code that passes.
|
||||
// TODO: Add some code that fails.
|
||||
|
||||
/* expect+1: warning: empty translation unit [272] */
|
||||
/* CONSTCOND */
|
||||
typedef int bits_per_byte[((unsigned char)-1) == 255 ? 1 : -1];
|
||||
typedef int bytes_per_long_double[sizeof(long double) == 16 ? 1 : -1];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: platform_ldbl64.c,v 1.2 2021/09/26 14:28:22 rillig Exp $ */
|
||||
/* $NetBSD: platform_ldbl64.c,v 1.3 2023/02/22 22:12:35 rillig Exp $ */
|
||||
# 3 "platform_ldbl64.c"
|
||||
|
||||
/*
|
||||
|
@ -8,7 +8,6 @@
|
|||
/* lint1-extra-flags: -c -h -a -p -b -r -z */
|
||||
/* lint1-only-if: ldbl-64 */
|
||||
|
||||
// TODO: Add some code that passes.
|
||||
// TODO: Add some code that fails.
|
||||
|
||||
/* expect+1: warning: empty translation unit [272] */
|
||||
/* CONSTCOND */
|
||||
typedef int bits_per_byte[((unsigned char)-1) == 255 ? 1 : -1];
|
||||
typedef int bytes_per_long_double[sizeof(long double) == 8 ? 1 : -1];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: platform_ldbl96.c,v 1.2 2021/09/26 14:28:22 rillig Exp $ */
|
||||
/* $NetBSD: platform_ldbl96.c,v 1.3 2023/02/22 22:12:35 rillig Exp $ */
|
||||
# 3 "platform_ldbl96.c"
|
||||
|
||||
/*
|
||||
|
@ -8,7 +8,6 @@
|
|||
/* lint1-extra-flags: -c -h -a -p -b -r -z */
|
||||
/* lint1-only-if: ldbl-96 */
|
||||
|
||||
// TODO: Add some code that passes.
|
||||
// TODO: Add some code that fails.
|
||||
|
||||
/* expect+1: warning: empty translation unit [272] */
|
||||
/* CONSTCOND */
|
||||
typedef int bits_per_byte[((unsigned char)-1) == 255 ? 1 : -1];
|
||||
typedef int bytes_per_long_double[sizeof(long double) == 12 ? 1 : -1];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: platform_lp64.c,v 1.3 2022/06/11 11:52:13 rillig Exp $ */
|
||||
/* $NetBSD: platform_lp64.c,v 1.4 2023/02/22 22:12:35 rillig Exp $ */
|
||||
# 3 "platform_lp64.c"
|
||||
|
||||
/*
|
||||
|
@ -9,6 +9,22 @@
|
|||
/* lint1-extra-flags: -c -h -a -p -b -r -z */
|
||||
/* lint1-only-if: lp64 */
|
||||
|
||||
int s32;
|
||||
unsigned int u32;
|
||||
long sl32;
|
||||
unsigned long ul32;
|
||||
|
||||
void
|
||||
convert_between_int_and_long(void)
|
||||
{
|
||||
/* expect+1: warning: conversion from 'long' to 'int' may lose accuracy [132] */
|
||||
s32 = sl32;
|
||||
sl32 = s32;
|
||||
/* expect+1: warning: conversion from 'unsigned long' to 'unsigned int' may lose accuracy [132] */
|
||||
u32 = ul32;
|
||||
ul32 = u32;
|
||||
}
|
||||
|
||||
void to_size_t(typeof(sizeof(int)));
|
||||
|
||||
void
|
||||
|
@ -17,6 +33,3 @@ convert_unsigned_char_to_size_t(unsigned char uc)
|
|||
/* no warning, unlike platform_int */
|
||||
to_size_t(uc);
|
||||
}
|
||||
|
||||
/* expect+1: warning: static variable 'unused_variable' unused [226] */
|
||||
static int unused_variable;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: platform_schar.c,v 1.2 2021/09/26 14:28:22 rillig Exp $ */
|
||||
/* $NetBSD: platform_schar.c,v 1.3 2023/02/22 22:12:35 rillig Exp $ */
|
||||
# 3 "platform_schar.c"
|
||||
|
||||
/*
|
||||
|
@ -9,7 +9,7 @@
|
|||
/* lint1-extra-flags: -c -h -a -p -b -r -z */
|
||||
/* lint1-only-if: schar */
|
||||
|
||||
// TODO: Add some code that passes.
|
||||
// TODO: Add some code that fails.
|
||||
|
||||
/* expect+1: warning: empty translation unit [272] */
|
||||
/* CONSTCOND */
|
||||
/* FIXME: Wrong order in the diagnostic, should be '-128 <' instead. */
|
||||
/* expect+1: warning: nonportable character comparison '< -128' [230] */
|
||||
typedef int is_signed[(char)'\200' < (char)'\177' ? 1 : -1];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: platform_uchar.c,v 1.2 2021/09/26 14:28:22 rillig Exp $ */
|
||||
/* $NetBSD: platform_uchar.c,v 1.3 2023/02/22 22:12:35 rillig Exp $ */
|
||||
# 3 "platform_uchar.c"
|
||||
|
||||
/*
|
||||
|
@ -9,7 +9,6 @@
|
|||
/* lint1-extra-flags: -c -h -a -p -b -r -z */
|
||||
/* lint1-only-if: uchar */
|
||||
|
||||
// TODO: Add some code that passes.
|
||||
// TODO: Add some code that fails.
|
||||
|
||||
/* expect+1: warning: empty translation unit [272] */
|
||||
/* CONSTCOND */
|
||||
/* expect+1: warning: nonportable character comparison '< 128' [230] */
|
||||
typedef int is_unsigned[(char)'\177' < (char)'\200' ? 1 : -1];
|
||||
|
|
Loading…
Reference in New Issue