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

2017-12-20 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83131

Martin Sebor  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #6 from Martin Sebor  ---
Fixed in r255898.

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

2017-12-20 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83131

--- Comment #5 from Martin Sebor  ---
Author: msebor
Date: Wed Dec 20 16:56:20 2017
New Revision: 255898

URL: https://gcc.gnu.org/viewcvs?rev=255898=gcc=rev
Log:
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.


Added:
trunk/gcc/testsuite/c-c++-common/attr-nonstring-4.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/builtins.c
trunk/gcc/testsuite/ChangeLog

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

2017-12-11 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83131

Martin Sebor  changed:

   What|Removed |Added

   Keywords||patch

--- Comment #4 from Martin Sebor  ---
Patch: https://gcc.gnu.org/ml/gcc-patches/2017-12/msg00665.html

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

2017-11-29 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83131

Martin Sebor  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |msebor at gcc dot 
gnu.org

--- Comment #3 from Martin Sebor  ---
Confirmed with the following test case.

  extern char arr[] __attribute__ ((nonstring));
  extern char str[];

  int f (void)
  {
return __builtin_strcmp (arr, str);
  }

The expected output is:

  $ gcc -O2 -S -Wall -Wextra -Wpedantic a.c
  a.c: In function ‘f’:
  a.c:6:10: warning: ‘__builtin_strcmp’ argument 1 declared attribute
‘nonstring’ [-Wstringop-overflow=]
 return __builtin_strcmp (arr, str);
^~~
  a.c:1:13: note: argument ‘arr’ declared here
   extern char arr[] __attribute__ ((nonstring));
   ^~~

With a powerpc64le-linux GCC, there is no warning.

The strcmp call is expanded in builtins.c and never reaches expand_call in
calls.c where the checking is done.  Something similar can happen for strlen on
x86_64 and there it's being handled by also checking in builtins.c (in
expand_builtin_strlen).  So strcmp and other string functions will need the
same treatment.

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

2017-11-29 Thread seurer at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83131

--- Comment #2 from seurer at gcc dot gnu.org ---
The new test case was added in r255031.

Here are the warnings it is complaining about:

spawn -ignore SIGHUP /home/seurer/gcc/build/gcc-test/gcc/xgcc
-B/home/seurer/gcc/build/gcc-test/gcc/
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c
-fno-diagnostics-show-caret -fdiagnostics-color=never -Wc++-compat -O2
-Wattributes -Wstringop-overflow -ftrack-macro-expansion=0 -S -o
attr-nonstring-3.s
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c: In
function 'test_printf':
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:71:3:
warning: 'printf' argument 1 declared attribute 'nonstring'
[-Wstringop-overflow=]
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:51:6:
note: argument 'arr' declared here
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:74:3:
warning: 'printf' argument 1 declared attribute 'nonstring'
[-Wstringop-overflow=]
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:54:7:
note: argument 'parr' declared here
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:77:3:
warning: 'printf' argument 1 declared attribute 'nonstring'
[-Wstringop-overflow=]
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:59:8:
note: argument 'arr' declared here
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c: In
function 'test_puts':
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:84:3:
warning: 'puts' argument 1 declared attribute 'nonstring'
[-Wstringop-overflow=]
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:51:6:
note: argument 'arr' declared here
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:87:3:
warning: 'puts' argument 1 declared attribute 'nonstring'
[-Wstringop-overflow=]
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:54:7:
note: argument 'parr' declared here
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:90:3:
warning: 'puts' argument 1 declared attribute 'nonstring'
[-Wstringop-overflow=]
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:59:8:
note: argument 'arr' declared here
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c: In
function 'test_snprintf':
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:97:3:
warning: 'snprintf' argument 3 declared attribute 'nonstring'
[-Wstringop-overflow=]
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:51:6:
note: argument 'arr' declared here
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:100:3:
warning: 'snprintf' argument 3 declared attribute 'nonstring'
[-Wstringop-overflow=]
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:54:7:
note: argument 'parr' declared here
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:103:3:
warning: 'snprintf' argument 3 declared attribute 'nonstring'
[-Wstringop-overflow=]
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:59:8:
note: argument 'arr' declared here
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c: In
function 'test_sprintf':
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:110:3:
warning: 'sprintf' argument 2 declared attribute 'nonstring'
[-Wstringop-overflow=]
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:51:6:
note: argument 'arr' declared here
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:113:3:
warning: 'sprintf' argument 2 declared attribute 'nonstring'
[-Wstringop-overflow=]
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:54:7:
note: argument 'parr' declared here
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:116:3:
warning: 'sprintf' argument 2 declared attribute 'nonstring'
[-Wstringop-overflow=]
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:59:8:
note: argument 'arr' declared here
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c: In
function 'test_vsnprintf':
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:123:3:
warning: 'vsnprintf' argument 3 declared attribute 'nonstring'
[-Wstringop-overflow=]
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:51:6:
note: argument 'arr' declared here
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:126:3:
warning: 'vsnprintf' argument 3 declared attribute 'nonstring'
[-Wstringop-overflow=]
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:54:7:
note: argument 'parr' declared here
/home/seurer/gcc/gcc-test/gcc/testsuite/c-c++-common/attr-nonstring-3.c:129:3:
warning: 'vsnprintf' argument 3 

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

2017-11-23 Thread dje at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83131

David Edelsohn  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-11-23
 Ever confirmed|0   |1

--- Comment #1 from David Edelsohn  ---
Confirmed.