Having extended check_and_warn_address_or_pointer_of_packed_member to
find the packed (short) enum pointer in the cast expression coming
from the C++ front-end, and amended the C++ front end to mark short
enums as TYPE_PACKED, C++ issues the same warning that C does for
c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c,
so drop the exclusion.

Regstrapped on x86_64-linux-gnu, also tested on arm-eabi with default
cpu on trunk, and with tms570 on gcc-13.  Ok to install?


for  gcc/testsuite/ChangeLog

        * 
c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c:
        Expect warning in C++ as well.
        * 
c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c:
        Likewise.
---
 ...-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c |    2 +-
 ...ull-deref-pr108251-smp_fetch_ssl_fc_has_early.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c
 
b/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c
index aaa2031b6dca4..bf5bf5cc2e278 100644
--- 
a/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c
+++ 
b/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c
@@ -61,7 +61,7 @@ static inline enum obj_type obj_type(const enum obj_type *t)
 }
 static inline struct connection *__objt_conn(enum obj_type *t)
 {
- return ((struct connection *)(((char *)(t)) - ((long)&((struct connection 
*)0)->obj_type))); /* { dg-warning "unaligned pointer value" "warning" { target 
{ short_enums && { ! c++ } } } } */
+ return ((struct connection *)(((char *)(t)) - ((long)&((struct connection 
*)0)->obj_type))); /* { dg-warning "unaligned pointer value" "warning" { target 
short_enums } } */
 }
 static inline struct connection *objt_conn(enum obj_type *t)
 {
diff --git 
a/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c
 
b/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c
index 6c96f5a76ef1c..7c2710c64d35e 100644
--- 
a/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c
+++ 
b/gcc/testsuite/c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c
@@ -60,7 +60,7 @@ static inline enum obj_type obj_type(const enum obj_type *t)
 }
 static inline struct connection *__objt_conn(enum obj_type *t)
 {
- return ((struct connection *)(((char *)(t)) - ((long)&((struct connection 
*)0)->obj_type))); /* { dg-warning "unaligned pointer value" "warning" { target 
{ short_enums && { ! c++ } } } } */
+ return ((struct connection *)(((char *)(t)) - ((long)&((struct connection 
*)0)->obj_type))); /* { dg-warning "unaligned pointer value" "warning" { target 
short_enums } } */
 }
 static inline struct connection *objt_conn(enum obj_type *t)
 {

-- 
Alexandre Oliva, happy hacker            https://FSFLA.org/blogs/lxo/
   Free Software Activist                   GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity
Excluding neuro-others for not behaving ""normal"" is *not* inclusive

Reply via email to