]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: filter out warning noise for CWE-1341 test
authorJiufu Guo <guojiufu@linux.ibm.com>
Wed, 12 Apr 2023 02:12:58 +0000 (10:12 +0800)
committerJiufu Guo <guojiufu@linux.ibm.com>
Fri, 14 Apr 2023 03:09:38 +0000 (11:09 +0800)
The case file-CWE-1341-example.c checkes [CWE-1341](`double-fclose`).
While on some systems, besides [CWE-1341], a message of [CWE-415] is
also reported. On those systems, attribute `malloc` may be attached on
fopen:
```
# 258 "/usr/include/stdio.h" 3 4
extern FILE *fopen (const char *__restrict __filename,
      const char *__restrict __modes)
  __attribute__ ((__malloc__)) __attribute__ ((__malloc__ (fclose, 1))) ;

or say: __attribute_malloc__ __attr_dealloc_fclose __wur;
```

See (PR analyzer/108722) for future fix in the analyzer.
This workaround patch adds -Wno-analyzer-double-free to this case.

gcc/testsuite/ChangeLog:

PR analyzer/108722
* gcc.dg/analyzer/file-CWE-1341-example.c: Update.

gcc/testsuite/gcc.dg/analyzer/file-CWE-1341-example.c

index 2add3cb109b5d736789b57eea40198c5445e95fa..9d125dfefe5f74943ab7660e219cfddd7a1f3c29 100644 (file)
@@ -19,6 +19,9 @@
 
    IN NO EVENT SHALL THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY), THE MITRE CORPORATION, ITS BOARD OF TRUSTEES, OFFICERS, AGENTS, AND EMPLOYEES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE INFORMATION OR THE USE OR OTHER DEALINGS IN THE CWE.  */
 
+/* Checks double-fclose only, suppress CWE-415. (PR analyzer/108722).  */
+/* { dg-additional-options -Wno-analyzer-double-free } */
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>