aboutsummaryrefslogtreecommitdiffhomepage
path: root/c/c.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-11-26 18:46:44 +0100
committerlemon <lsof@mailbox.org>2025-11-26 19:31:10 +0100
commit375e9f050de6b09c00eecafd63bd9b967fbeb335 (patch)
tree940db01d53dbe8d39279b6c95902b4cfadb31f92 /c/c.c
parent0bb43ea3af31d4c141285ab968b476228416f0c8 (diff)
c/type: make implicit const T* -> T* conversion warning, not error
Diffstat (limited to 'c/c.c')
-rw-r--r--c/c.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/c/c.c b/c/c.c
index 5dd4368..c50ffa7 100644
--- a/c/c.c
+++ b/c/c.c
@@ -342,7 +342,14 @@ argpromote(union type t)
bool
assigncheck(union type t, const struct expr *src)
{
- if (assigncompat(t, typedecay(src->ty))) return 1;
+ union type srcty = typedecay(src->ty);;
+ if (assigncompat(t, srcty)) {
+ if (t.t == TYPTR && srcty.t == TYPTR
+ && (t.flag & TFCHLDQUAL & srcty.flag & TFCHLDQUAL) != (srcty.flag & TFCHLDQUAL)) {
+ warn(&src->span, "usage of '%ty' discards pointer qualifiers", src->ty);
+ }
+ return 1;
+ }
if (t.t == TYPTR && iszero(*src)) return 1;
return 0;
}