public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aoliva/heads/testme)] testsuite: analyzer: expect alignment warning with -fshort-enums
@ 2023-11-19 4:44 Alexandre Oliva
0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 2023-11-19 4:44 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:5d2d7416524dd8061594b4638013bebb71e846c1
commit 5d2d7416524dd8061594b4638013bebb71e846c1
Author: Alexandre Oliva <oliva@adacore.com>
Date: Sat Nov 18 02:11:53 2023 -0300
testsuite: analyzer: expect alignment warning with -fshort-enums
On targets that have -fshort-enums enabled by default, the type casts
in the pr108251 analyzer tests warn that the byte-aligned enums may
not be sufficiently aligned to be a struct connection *. The function
can't know better, the warning is reasonable, the code doesn't
expected enums to be shorter and less aligned than the struct.
Rather than use -fno-short-enums, I decided to embrace the warning on
targets that have short_enums enabled by default.
However, C++ doesn't issue the warning, because even with
-fshort-enums, enumeration types are not TYPE_PACKED, and the
expression is not sufficiently simplified by the C++ front-end for
check_and_warn_address_or_pointer_of_packed_member to identify the
insufficiently aligned pointer. So don't expect the warning there.
for gcc/testsuite/ChangeLog
* c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c:
Expect "unaligned pointer value" warning on short_enums
targets, but not in c++.
* c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c:
Likewise.
Diff:
---
.../analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c | 2 +-
.../analyzer/null-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 c46ffe91a6b..394401fd95a 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)));
+ return ((struct connection *)(((char *)(t)) - ((long)&((struct connection *)0)->obj_type))); /* { dg-warning "unaligned pointer value" "warning" { target short_enums && ! c++ } } */
}
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 ef34a76c50d..7ccfd2e36c0 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)));
+ return ((struct connection *)(((char *)(t)) - ((long)&((struct connection *)0)->obj_type))); /* { dg-warning "unaligned pointer value" "warning" { target short_enums && ! c++ } } */
}
static inline struct connection *objt_conn(enum obj_type *t)
{
^ permalink raw reply [flat|nested] 4+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] testsuite: analyzer: expect alignment warning with -fshort-enums
@ 2023-11-19 5:25 Alexandre Oliva
0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 2023-11-19 5:25 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:01de24b7060fef520c408be813ed202717174dac
commit 01de24b7060fef520c408be813ed202717174dac
Author: Alexandre Oliva <oliva@adacore.com>
Date: Sat Nov 18 02:11:53 2023 -0300
testsuite: analyzer: expect alignment warning with -fshort-enums
On targets that have -fshort-enums enabled by default, the type casts
in the pr108251 analyzer tests warn that the byte-aligned enums may
not be sufficiently aligned to be a struct connection *. The function
can't know better, the warning is reasonable, the code doesn't
expected enums to be shorter and less aligned than the struct.
Rather than use -fno-short-enums, I decided to embrace the warning on
targets that have short_enums enabled by default.
However, C++ doesn't issue the warning, because even with
-fshort-enums, enumeration types are not TYPE_PACKED, and the
expression is not sufficiently simplified by the C++ front-end for
check_and_warn_address_or_pointer_of_packed_member to identify the
insufficiently aligned pointer. So don't expect the warning there.
for gcc/testsuite/ChangeLog
* c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c:
Expect "unaligned pointer value" warning on short_enums
targets, but not in c++.
* c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c:
Likewise.
Diff:
---
.../analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c | 2 +-
.../analyzer/null-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 c46ffe91a6b..aaa2031b6dc 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)));
+ return ((struct connection *)(((char *)(t)) - ((long)&((struct connection *)0)->obj_type))); /* { dg-warning "unaligned pointer value" "warning" { target { short_enums && { ! c++ } } } } */
}
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 ef34a76c50d..6c96f5a76ef 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)));
+ return ((struct connection *)(((char *)(t)) - ((long)&((struct connection *)0)->obj_type))); /* { dg-warning "unaligned pointer value" "warning" { target { short_enums && { ! c++ } } } } */
}
static inline struct connection *objt_conn(enum obj_type *t)
{
^ permalink raw reply [flat|nested] 4+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] testsuite: analyzer: expect alignment warning with -fshort-enums
@ 2023-11-19 5:22 Alexandre Oliva
0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 2023-11-19 5:22 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:f893dacf4a161f69fd7c06f6fbdb41a9569e9eb8
commit f893dacf4a161f69fd7c06f6fbdb41a9569e9eb8
Author: Alexandre Oliva <oliva@adacore.com>
Date: Sat Nov 18 02:11:53 2023 -0300
testsuite: analyzer: expect alignment warning with -fshort-enums
On targets that have -fshort-enums enabled by default, the type casts
in the pr108251 analyzer tests warn that the byte-aligned enums may
not be sufficiently aligned to be a struct connection *. The function
can't know better, the warning is reasonable, the code doesn't
expected enums to be shorter and less aligned than the struct.
Rather than use -fno-short-enums, I decided to embrace the warning on
targets that have short_enums enabled by default.
However, C++ doesn't issue the warning, because even with
-fshort-enums, enumeration types are not TYPE_PACKED, and the
expression is not sufficiently simplified by the C++ front-end for
check_and_warn_address_or_pointer_of_packed_member to identify the
insufficiently aligned pointer. So don't expect the warning there.
for gcc/testsuite/ChangeLog
* c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c:
Expect "unaligned pointer value" warning on short_enums
targets, but not in c++.
* c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c:
Likewise.
Diff:
---
.../analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c | 2 +-
.../analyzer/null-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 c46ffe91a6b..d87853e0a9f 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)));
+ return ((struct connection *)(((char *)(t)) - ((long)&((struct connection *)0)->obj_type))); /* { dg-warning "unaligned pointer value" "warning" { target { short_enums && ! c++ } } } */
}
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 ef34a76c50d..1c64de31982 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)));
+ return ((struct connection *)(((char *)(t)) - ((long)&((struct connection *)0)->obj_type))); /* { dg-warning "unaligned pointer value" "warning" { target { short_enums && ! c++ } } } */
}
static inline struct connection *objt_conn(enum obj_type *t)
{
^ permalink raw reply [flat|nested] 4+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] testsuite: analyzer: expect alignment warning with -fshort-enums
@ 2023-11-18 5:36 Alexandre Oliva
0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 2023-11-18 5:36 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:ec3bb0c8270298f2915a0600ee92d48422aef681
commit ec3bb0c8270298f2915a0600ee92d48422aef681
Author: Alexandre Oliva <oliva@adacore.com>
Date: Sat Nov 18 02:11:53 2023 -0300
testsuite: analyzer: expect alignment warning with -fshort-enums
On targets that have -fshort-enums enabled by default, the type casts
in the pr108251 analyzer tests warn that the byte-aligned enums may
not be sufficiently aligned to be a struct connection *. The function
can't know better, the warning is reasonable, the code doesn't
expected enums to be shorter and less aligned than the struct.
Rather than use -fno-short-enums, I decided to embrace the warning on
targets that have short_enums enabled by default.
for gcc/testsuite/ChangeLog
* c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c:
Expect "unaligned pointer value" warning on short_enums targets.
* c-c++-common/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c:
Likewise.
Diff:
---
.../analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c | 2 +-
.../analyzer/null-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 c46ffe91a6b..bf5bf5cc2e2 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)));
+ 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 ef34a76c50d..7c2710c64d3 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)));
+ 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)
{
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-11-19 5:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-19 4:44 [gcc(refs/users/aoliva/heads/testme)] testsuite: analyzer: expect alignment warning with -fshort-enums Alexandre Oliva
-- strict thread matches above, loose matches on Subject: below --
2023-11-19 5:25 Alexandre Oliva
2023-11-19 5:22 Alexandre Oliva
2023-11-18 5:36 Alexandre Oliva
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).