aboutsummaryrefslogtreecommitdiff
path: root/src/check_builtin.cpp
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2026-01-22 11:47:23 +0100
committerGitHub <noreply@github.com>2026-01-22 11:47:23 +0100
commit3f8a32aeb963e056ac7709c26f05a99fb884ef95 (patch)
tree4eed35fa23e9f4c5b7dedc6a355b16f5d3119661 /src/check_builtin.cpp
parentfb479b3aaec5a9a715bcff7d65498ba18020f4f0 (diff)
parent5c09550d383df49a1d29d8f66bc1c45ee3be1136 (diff)
Merge branch 'master' into xmlcomment
Diffstat (limited to 'src/check_builtin.cpp')
-rw-r--r--src/check_builtin.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp
index 1b3e6912c..929891826 100644
--- a/src/check_builtin.cpp
+++ b/src/check_builtin.cpp
@@ -2695,6 +2695,16 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
case BuiltinProc_size_of: {
// size_of :: proc(Type or expr) -> untyped int
+ if (ce->args[0]->kind == Ast_UnaryExpr) {
+ ast_node(arg, UnaryExpr, ce->args[0]);
+ if (arg->op.kind == Token_And) {
+ ERROR_BLOCK();
+
+ warning(ce->args[0], "'size_of(&x)' returns the size of a pointer, not the size of x");
+ error_line("\tSuggestion: Use 'size_of(rawptr)' if you want the size of the pointer");
+ }
+ }
+
Operand o = {};
check_expr_or_type(c, &o, ce->args[0]);
if (o.mode == Addressing_Invalid) {