From 69450a2be7575aa4f984b9ae2824da0e5634c9f0 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 5 Jul 2023 13:23:14 -0400 Subject: Initial sizeof/alignof implementation. (#2954) * Initial sizeof implementation. * Small macro improvement. * Fix some typos. * Refactor NaturalSize. Add more sizeof tests. * Use _makeParseExpr to add sizeof support. * Add size-of.slang diagnostic result. * Fix typo in folding with macro change. * Add a sizeof test of This. * Some more NaturalSize coverage. * Simple alignof support. * Testing for alignof. * Added 8 bit enum to check enums values are correctly sized. * Add alignof to completion. * Lower sizeof/alignof to IR. sizeof/alignof IR pass. Tests for simple generic scenarios. * Make append handle invalid properly. Improve comments. --------- Co-authored-by: Theresa Foley <10618364+tangent-vector@users.noreply.github.com> --- tests/diagnostics/size-of.slang | 8 ++++++++ tests/diagnostics/size-of.slang.expected | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/diagnostics/size-of.slang create mode 100644 tests/diagnostics/size-of.slang.expected (limited to 'tests/diagnostics') diff --git a/tests/diagnostics/size-of.slang b/tests/diagnostics/size-of.slang new file mode 100644 index 000000000..63c55398e --- /dev/null +++ b/tests/diagnostics/size-of.slang @@ -0,0 +1,8 @@ +// sizeof.slang + +//DIAGNOSTIC_TEST:SIMPLE: + +int func() +{ + return sizeof(func); +} diff --git a/tests/diagnostics/size-of.slang.expected b/tests/diagnostics/size-of.slang.expected new file mode 100644 index 000000000..19c837799 --- /dev/null +++ b/tests/diagnostics/size-of.slang.expected @@ -0,0 +1,8 @@ +result code = -1 +standard error = { +tests/diagnostics/size-of.slang(7): error 30099: argument to sizeof is invalid + return sizeof(func); + ^~~~~~ +} +standard output = { +} -- cgit v1.2.3