Commit 783aea33 by Martin Sebor Committed by Martin Sebor

builtin-sprintf-warn-3.c: Declare test functions with noipa attribute.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/builtin-sprintf-warn-3.c: Declare test functions
	with noipa attribute.

From-SVN: r277711
parent 6485d5d6
2019-11-01 Martin Sebor <msebor@redhat.com>
* gcc.dg/tree-ssa/builtin-sprintf-warn-3.c: Declare test functions
with noipa attribute.
2019-11-01 Nathan Sidwell <nathan@acm.org> 2019-11-01 Nathan Sidwell <nathan@acm.org>
* g++.dg/template/fn.C: New. * g++.dg/template/fn.C: New.
......
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
typedef __SIZE_TYPE__ size_t; typedef __SIZE_TYPE__ size_t;
/* Prevent equivalent functions from being merged. */
#define NOIPA __attribute__ ((noipa))
#ifndef LINE #ifndef LINE
# define LINE 0 # define LINE 0
#endif #endif
...@@ -53,7 +56,7 @@ extern int x (void); ...@@ -53,7 +56,7 @@ extern int x (void);
argument is in a known range of lengths and one or both of which argument is in a known range of lengths and one or both of which
exceed the size of the destination. */ exceed the size of the destination. */
void test_sprintf_chk_string (const char *s, const char *t) NOIPA void test_sprintf_chk_string (const char *s, const char *t)
{ {
#define x x () #define x x ()
...@@ -84,7 +87,7 @@ void test_sprintf_chk_string (const char *s, const char *t) ...@@ -84,7 +87,7 @@ void test_sprintf_chk_string (const char *s, const char *t)
/* Verify that the checker makes use of integer constant propagation /* Verify that the checker makes use of integer constant propagation
to detect buffer overflow in non-constant cases. */ to detect buffer overflow in non-constant cases. */
void test_sprintf_chk_integer_value (void) NOIPA void test_sprintf_chk_integer_value (void)
{ {
T ( 1, "%i", i ( 0)); /* { dg-warning "nul past the end" } */ T ( 1, "%i", i ( 0)); /* { dg-warning "nul past the end" } */
T ( 1, "%i", i ( 1)); /* { dg-warning "nul past the end" } */ T ( 1, "%i", i ( 1)); /* { dg-warning "nul past the end" } */
...@@ -182,7 +185,7 @@ range_uint (unsigned int min, unsigned int max) ...@@ -182,7 +185,7 @@ range_uint (unsigned int min, unsigned int max)
return val < min || max < val ? min : val; return val < min || max < val ? min : val;
} }
void test_sprintf_chk_range_schar (void) NOIPA void test_sprintf_chk_range_schar (void)
{ {
#define R(min, max) range_sint (min, max) #define R(min, max) range_sint (min, max)
...@@ -239,7 +242,7 @@ void test_sprintf_chk_range_schar (void) ...@@ -239,7 +242,7 @@ void test_sprintf_chk_range_schar (void)
T ( 6, "%.3i|%.2i/%i", R (0, 1), R (0, 2), R (0, 3)); /* { dg-warning "./. directive writing 1 byte into a region of size 0" } */ T ( 6, "%.3i|%.2i/%i", R (0, 1), R (0, 2), R (0, 3)); /* { dg-warning "./. directive writing 1 byte into a region of size 0" } */
} }
void test_sprintf_chk_range_uchar (void) NOIPA void test_sprintf_chk_range_uchar (void)
{ {
#undef R #undef R
#define R(min, max) range_uchar (min, max) #define R(min, max) range_uchar (min, max)
...@@ -253,7 +256,7 @@ void test_sprintf_chk_range_uchar (void) ...@@ -253,7 +256,7 @@ void test_sprintf_chk_range_uchar (void)
T ( 3, "%i", R (0, 100)); /* { dg-warning "may write a terminating nul past the end of the destination" } */ T ( 3, "%i", R (0, 100)); /* { dg-warning "may write a terminating nul past the end of the destination" } */
} }
void test_sprintf_chk_range_sshrt (void) NOIPA void test_sprintf_chk_range_sshrt (void)
{ {
#undef R #undef R
#define R(min, max) range_sshrt (min, max) #define R(min, max) range_sshrt (min, max)
...@@ -276,7 +279,7 @@ void test_sprintf_chk_range_sshrt (void) ...@@ -276,7 +279,7 @@ void test_sprintf_chk_range_sshrt (void)
T ( 4, "%i", R (999, 1000)); /* { dg-warning "may write a terminating nul past the end of the destination" } */ T ( 4, "%i", R (999, 1000)); /* { dg-warning "may write a terminating nul past the end of the destination" } */
} }
void test_sprintf_chk_range_ushrt (void) NOIPA void test_sprintf_chk_range_ushrt (void)
{ {
#undef R #undef R
#define R(min, max) range_ushrt (min, max) #define R(min, max) range_ushrt (min, max)
...@@ -298,7 +301,7 @@ void test_sprintf_chk_range_ushrt (void) ...@@ -298,7 +301,7 @@ void test_sprintf_chk_range_ushrt (void)
T ( 4, "%i", R (999, 1000)); /* { dg-warning "may write a terminating nul past the end of the destination" } */ T ( 4, "%i", R (999, 1000)); /* { dg-warning "may write a terminating nul past the end of the destination" } */
} }
void test_sprintf_chk_range_sint (void) NOIPA void test_sprintf_chk_range_sint (void)
{ {
#undef R #undef R
#define R(min, max) range_sint (min, max) #define R(min, max) range_sint (min, max)
...@@ -321,7 +324,7 @@ void test_sprintf_chk_range_sint (void) ...@@ -321,7 +324,7 @@ void test_sprintf_chk_range_sint (void)
T ( 4, "%i", R (999, 1000)); /* { dg-warning "may write a terminating nul past the end of the destination" } */ T ( 4, "%i", R (999, 1000)); /* { dg-warning "may write a terminating nul past the end of the destination" } */
} }
void test_sprintf_chk_range_uint (void) NOIPA void test_sprintf_chk_range_uint (void)
{ {
#undef R #undef R
#define R(min, max) range_uint (min, max) #define R(min, max) range_uint (min, max)
...@@ -351,7 +354,7 @@ void test_sprintf_chk_range_uint (void) ...@@ -351,7 +354,7 @@ void test_sprintf_chk_range_uint (void)
fail. The latter because due to the limit of ptrdiff_t no object fail. The latter because due to the limit of ptrdiff_t no object
can be larger than PTRDIFF_MAX bytes. */ can be larger than PTRDIFF_MAX bytes. */
void test_too_large (char *d, int x, __builtin_va_list va) NOIPA void test_too_large (char *d, int x, __builtin_va_list va)
{ {
const size_t imax = __INT_MAX__; const size_t imax = __INT_MAX__;
const size_t imax_p1 = imax + 1; const size_t imax_p1 = imax + 1;
...@@ -393,7 +396,7 @@ void test_too_large (char *d, int x, __builtin_va_list va) ...@@ -393,7 +396,7 @@ void test_too_large (char *d, int x, __builtin_va_list va)
#define TEST_SPRINTF(d, maxsize, objsize, fmt, ...) \ #define TEST_SPRINTF(d, maxsize, objsize, fmt, ...) \
__builtin_sprintf (d, fmt, __VA_ARGS__) __builtin_sprintf (d, fmt, __VA_ARGS__)
void test_sprintf_malloc (const char *s, const char *t) NOIPA void test_sprintf_malloc (const char *s, const char *t)
{ {
#define x x () #define x x ()
...@@ -421,7 +424,7 @@ void test_sprintf_malloc (const char *s, const char *t) ...@@ -421,7 +424,7 @@ void test_sprintf_malloc (const char *s, const char *t)
#undef ALLOC #undef ALLOC
#define ALLOC(p, n) (p) = __builtin_alloca (n) #define ALLOC(p, n) (p) = __builtin_alloca (n)
void test_sprintf_alloca (const char *s, const char *t) NOIPA void test_sprintf_alloca (const char *s, const char *t)
{ {
#define x x () #define x x ()
...@@ -449,7 +452,7 @@ void test_sprintf_alloca (const char *s, const char *t) ...@@ -449,7 +452,7 @@ void test_sprintf_alloca (const char *s, const char *t)
#undef ALLOC #undef ALLOC
#define ALLOC(p, n) char vla [i (n)]; (p) = vla #define ALLOC(p, n) char vla [i (n)]; (p) = vla
void test_sprintf_vla (const char *s, const char *t) NOIPA void test_sprintf_vla (const char *s, const char *t)
{ {
#define x x () #define x x ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment