diff options
author | CoprDistGit <infra@openeuler.org> | 2023-10-17 02:15:03 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-10-17 02:15:03 +0000 |
commit | d82826d1a1c7ea45a761dfbf76b879712c7332ec (patch) | |
tree | 973a28470803b27c914f813f43d43f8932763ea3 /0090-bogus-Wstringop-overflow-with-VLA-of-elements-larger.patch | |
parent | b868000cf68cec0c9cd45fbf89a83173dea7c5eb (diff) |
automatic import of gccopeneuler22.03_LTS
Diffstat (limited to '0090-bogus-Wstringop-overflow-with-VLA-of-elements-larger.patch')
-rw-r--r-- | 0090-bogus-Wstringop-overflow-with-VLA-of-elements-larger.patch | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/0090-bogus-Wstringop-overflow-with-VLA-of-elements-larger.patch b/0090-bogus-Wstringop-overflow-with-VLA-of-elements-larger.patch new file mode 100644 index 0000000..fb51808 --- /dev/null +++ b/0090-bogus-Wstringop-overflow-with-VLA-of-elements-larger.patch @@ -0,0 +1,129 @@ +From bf537e82d452ee9b79f438df721c2e0dfaae12a0 Mon Sep 17 00:00:00 2001 +From: Xiong Zhou <xiongzhou4@huawei.com> +Date: Fri, 5 May 2023 11:57:40 +0800 +Subject: [PATCH 1/2] - bogus -Wstringop-overflow with VLA of elements larger + than byte + +--- + gcc/calls.c | 5 ++ + gcc/testsuite/gcc.dg/Wstringop-overflow-67.c | 92 ++++++++++++++++++++ + 2 files changed, 97 insertions(+) + create mode 100644 gcc/testsuite/gcc.dg/Wstringop-overflow-67.c + +diff --git a/gcc/calls.c b/gcc/calls.c +index 26894342c..45c137cee 100644 +--- a/gcc/calls.c ++++ b/gcc/calls.c +@@ -2112,6 +2112,11 @@ maybe_warn_rdwr_sizes (rdwr_map *rwm, tree fndecl, tree fntype, tree exp) + } + else + { ++ /* If the size cannot be determined clear it to keep it from ++ being taken as real (and excessive). */ ++ if (objsize && integer_all_onesp (objsize)) ++ objsize = NULL_TREE; ++ + /* For read-only and read-write attributes also set the source + size. */ + srcsize = objsize; +diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-67.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-67.c +new file mode 100644 +index 000000000..7b8f3f014 +--- /dev/null ++++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-67.c +@@ -0,0 +1,92 @@ ++/* PR middle-end/100571 - bogus -Wstringop-overflow with VLA of elements ++ larger than byte ++ { dg-do compile } ++ { dg-options "-O2 -Wall" } */ ++ ++__attribute__ ((access (read_only, 1, 2))) void fro (int *, int); ++__attribute__ ((access (write_only, 1, 2))) void fwo (int *, int); ++__attribute__ ((access (read_write, 1, 2))) void frw (int *, int); ++ ++extern __SIZE_TYPE__ n; ++ ++void alloca_ro (void) ++{ ++ int *a = __builtin_alloca (n * sizeof *a); ++ a[0] = 0; ++ fro (a, n); ++} ++ ++void alloca_wo (void) ++{ ++ int *a = __builtin_alloca (n * sizeof *a); ++ fwo (a, n); ++} ++ ++void alloca_rw (void) ++{ ++ int *a = __builtin_alloca (n * sizeof *a); ++ a[0] = 0; ++ frw (a, n); ++} ++ ++ ++void calloc_ro (void) ++{ ++ int *a = __builtin_calloc (n, sizeof *a); ++ fro (a, n); ++} ++ ++void calloc_wo (void) ++{ ++ int *a = __builtin_calloc (n, sizeof *a); ++ fwo (a, n); ++} ++ ++void calloc_rw (void) ++{ ++ int *a = __builtin_calloc (n, sizeof *a); ++ a[0] = 0; ++ frw (a, n); ++} ++ ++ ++void malloc_ro (void) ++{ ++ int *a = __builtin_malloc (n * sizeof *a); ++ a[0] = 0; ++ fro (a, n); ++} ++ ++void malloc_wo (void) ++{ ++ int *a = __builtin_malloc (n * sizeof *a); ++ fwo (a, n); ++} ++ ++void malloc_rw (void) ++{ ++ int *a = __builtin_malloc (n * sizeof *a); ++ a[0] = 0; ++ frw (a, n); ++} ++ ++ ++void vla_ro (void) ++{ ++ int a[n]; ++ a[0] = 0; ++ fro (a, n); ++} ++ ++void vla_wo (void) ++{ ++ int a[n]; ++ fwo (a, n); ++} ++ ++void vla_rw (void) ++{ ++ int a[n]; ++ a[0] = 0; ++ frw (a, n); ++} +-- +2.33.0 + |