[DTrace-devel] [PATCH 6/6] test: Check declaration (without init) inside a probe

eugene.loh at oracle.com eugene.loh at oracle.com
Tue Mar 31 01:02:24 UTC 2026


From: Eugene Loh <eugene.loh at oracle.com>

We test that declaration (with init) of a variable inside a probe is not
allowed.

Check also that declaration without init inside a probe is also
forbidden.

The related test/unittest/probes/err.D_SYNTAX/err.D_SYNTAX.declare*.d
tests are left alone.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
 .../scalars/err.D_SYNTAX.declare-init.d       | 20 +++++++++++++++++++
 test/unittest/scalars/err.D_SYNTAX.declare.d  |  4 ++--
 2 files changed, 22 insertions(+), 2 deletions(-)
 create mode 100644 test/unittest/scalars/err.D_SYNTAX.declare-init.d

diff --git a/test/unittest/scalars/err.D_SYNTAX.declare-init.d b/test/unittest/scalars/err.D_SYNTAX.declare-init.d
new file mode 100644
index 000000000..fd8dca6c0
--- /dev/null
+++ b/test/unittest/scalars/err.D_SYNTAX.declare-init.d
@@ -0,0 +1,20 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2006, 2026, Oracle and/or its affiliates. All rights reserved.
+ * Licensed under the Universal Permissive License v 1.0 as shown at
+ * http://oss.oracle.com/licenses/upl.
+ */
+
+/*
+ * ASSERTION:
+ *
+ * Declare and init a variable Inside Begin and make sure compilation fails.
+ *
+ * SECTION:  Variables/Scalar Variables
+ *
+ */
+
+BEGIN
+{
+	int x = 123;
+}
diff --git a/test/unittest/scalars/err.D_SYNTAX.declare.d b/test/unittest/scalars/err.D_SYNTAX.declare.d
index f5b2ea914..b26acd04a 100644
--- a/test/unittest/scalars/err.D_SYNTAX.declare.d
+++ b/test/unittest/scalars/err.D_SYNTAX.declare.d
@@ -1,6 +1,6 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2026, Oracle and/or its affiliates. All rights reserved.
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
@@ -16,5 +16,5 @@
 
 BEGIN
 {
-	int x = 123;
+	int x;
 }
-- 
2.47.3




More information about the DTrace-devel mailing list