Commit 16155777 by Martin Sebor Committed by Martin Sebor

PR testsuite/83131 - c-c++/common/attr-nonstring-3 failure for strcmp tests on PowerPC

gcc/ChangeLog:

	PR testsuite/83131
	* builtins.c (expand_builtin_strlen): Use get_callee_fndecl.
	(expand_builtin_strcmp): Call maybe_warn_nonstring_arg.	
	(expand_builtin_strncmp): Same.

gcc/testsuite/ChangeLog:

	PR testsuite/83131
	* c-c++-common/attr-nonstring-4.c: New test.

From-SVN: r255898
parent 35c4515b
2017-12-20 Martin Sebor <msebor@redhat.com>
PR testsuite/83131
* builtins.c (expand_builtin_strlen): Use get_callee_fndecl.
(expand_builtin_strcmp): Call maybe_warn_nonstring_arg.
(expand_builtin_strncmp): Same.
2017-12-20 Alexandre Oliva <aoliva@redhat.com>
PR bootstrap/83396
2017-12-20 Martin Sebor <msebor@redhat.com>
PR testsuite/83131
* c-c++-common/attr-nonstring-4.c: New test.
2017-12-20 Richard Sandiford <richard.sandiford@linaro.org>
* gcc.dg/plugin/poly-int-tests.h (test_nonpoly_multiple_p): New
......
/* PR middle-end/83131 - c-c++/common/attr-nonstring-3 failure for strcmp
tests on PowerPC
{ dg-do compile }
{ dg-options "-O2 -Wstringop-overflow -ftrack-macro-expansion=0" } */
#if __cplusplus
extern "C" {
#endif
typedef __SIZE_TYPE__ size_t;
extern int strcmp (const char*, const char*);
extern int strncmp (const char*, const char*, size_t);
#if __cplusplus
} /* extern "C" */
#endif
extern char arx[] __attribute__ ((nonstring));
extern char ar5[5] __attribute__ ((nonstring));
extern char str[];
enum { N = sizeof ar5 };
enum { X = sizeof ar5 + 1 };
int warn_strcmp_cst_1 (void)
{
return strcmp ("bar", arx); /* { dg-warning "argument 2 declared attribute .nonstring." } */
}
int warn_strcmp_cst_2 (void)
{
return strcmp (arx, "foo"); /* { dg-warning "argument 1 declared attribute .nonstring." } */
}
int warn_strncmp_cst_1 (void)
{
return strncmp ("bar", ar5, X); /* { dg-warning "argument 2 declared attribute .nonstring." } */
}
int warn_strncmp_cst_2 (void)
{
return strncmp (ar5, "foo", X); /* { dg-warning "argument 1 declared attribute .nonstring." } */
}
int nowarn_strncmp_cst_1 (void)
{
return strncmp ("bar", ar5, N);
}
int nowarn_strncmp_cst_2 (void)
{
return strncmp (ar5, "foo", N);
}
int warn_strncmp_var_1 (void)
{
return strncmp (str, ar5, X); /* { dg-warning "argument 2 declared attribute .nonstring." } */
}
int warn_strncmp_var_2 (void)
{
return strncmp (ar5, str, X); /* { dg-warning "argument 1 declared attribute .nonstring." } */
}
int nowarn_strncmp_var_1 (void)
{
return strncmp (str, ar5, N);
}
int nowarn_strncmp_var_2 (void)
{
return strncmp (ar5, str, N);
}
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