Linux DTrace development list
 help / color / mirror / Atom feed
* [PATCH 4/8] parser: reject scoped type declarations
@ 2026-09-28 18:02 Kris Van Hees
  2026-10-03  8:40 ` [DTrace-devel] " Elena Zannoni
  0 siblings, 1 reply; 2+ messages in thread
From: Kris Van Hees @ 2026-09-28 18:02 UTC (permalink / raw)
  To: dtrace, dtrace-devel

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
---
 libdtrace/dt_decl.c                              | 10 ++++++++++
 .../types/err.D_DECL_SCOPE.scopeop-enum-tag.d    | 16 ++++++++++++++++
 .../types/err.D_DECL_SCOPE.scopeop-enum-tag.r    |  2 ++
 .../types/err.D_DECL_SCOPE.scopeop-struct-tag.d  | 16 ++++++++++++++++
 .../types/err.D_DECL_SCOPE.scopeop-struct-tag.r  |  2 ++
 .../types/err.D_DECL_SCOPE.scopeop-union-tag.d   | 16 ++++++++++++++++
 .../types/err.D_DECL_SCOPE.scopeop-union-tag.r   |  2 ++
 7 files changed, 64 insertions(+)
 create mode 100644 test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.d
 create mode 100644 test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.r
 create mode 100644 test/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.d
 create mode 100644 test/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.r
 create mode 100644 test/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.d
 create mode 100644 test/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.r

diff --git a/libdtrace/dt_decl.c b/libdtrace/dt_decl.c
index 68999422..80ab7826 100644
--- a/libdtrace/dt_decl.c
+++ b/libdtrace/dt_decl.c
@@ -440,6 +440,11 @@ dt_decl_ptr(void)
 dt_decl_t *
 dt_decl_sou(uint_t kind, char *name)
 {
+	if (name != NULL && strchr(name, '`') != NULL) {
+		xyerror(D_DECL_SCOPE, "D scoping operator may not be used "
+		    "in a type name\n");
+	}
+
 	dt_decl_t *ddp = dt_decl_spec(kind, name);
 	char n[DT_TYPE_NAMELEN];
 	ctf_file_t *ctfp;
@@ -637,6 +642,11 @@ dt_decl_hasmembers(const char *name, int value, void *private)
 dt_decl_t *
 dt_decl_enum(char *name)
 {
+	if (name != NULL && strchr(name, '`') != NULL) {
+		xyerror(D_DECL_SCOPE, "D scoping operator may not be used "
+		    "in a type name\n");
+	}
+
 	dt_decl_t *ddp = dt_decl_spec(CTF_K_ENUM, name);
 	char n[DT_TYPE_NAMELEN];
 	ctf_file_t *ctfp;
diff --git a/test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.d b/test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.d
new file mode 100644
index 00000000..e43e94e5
--- /dev/null
+++ b/test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.d
@@ -0,0 +1,16 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 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: D scoping operators are not permitted in enum definition tags.
+ */
+
+#pragma D option quiet
+
+enum foo`bar {
+	value
+};
diff --git a/test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.r b/test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.r
new file mode 100644
index 00000000..3e0caeb5
--- /dev/null
+++ b/test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.r
@@ -0,0 +1,2 @@
+-- @@stderr --
+dtrace: failed to compile script test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.d: [D_DECL_SCOPE] line 14: D scoping operator may not be used in a type name
diff --git a/test/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.d b/test/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.d
new file mode 100644
index 00000000..3f786e58
--- /dev/null
+++ b/test/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.d
@@ -0,0 +1,16 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 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: D scoping operators are not permitted in struct definition tags.
+ */
+
+#pragma D option quiet
+
+struct foo`bar {
+	int value;
+};
diff --git a/test/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.r b/test/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.r
new file mode 100644
index 00000000..b071cf9c
--- /dev/null
+++ b/test/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.r
@@ -0,0 +1,2 @@
+-- @@stderr --
+dtrace: failed to compile script test/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.d: [D_DECL_SCOPE] line 14: D scoping operator may not be used in a type name
diff --git a/test/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.d b/test/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.d
new file mode 100644
index 00000000..5e504cf5
--- /dev/null
+++ b/test/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.d
@@ -0,0 +1,16 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 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: D scoping operators are not permitted in union definition tags.
+ */
+
+#pragma D option quiet
+
+union foo`bar {
+	int value;
+};
diff --git a/test/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.r b/test/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.r
new file mode 100644
index 00000000..7f35b11c
--- /dev/null
+++ b/test/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.r
@@ -0,0 +1,2 @@
+-- @@stderr --
+dtrace: failed to compile script test/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.d: [D_DECL_SCOPE] line 14: D scoping operator may not be used in a type name
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [DTrace-devel] [PATCH 4/8] parser: reject scoped type declarations
  2026-09-28 18:02 [PATCH 4/8] parser: reject scoped type declarations Kris Van Hees
@ 2026-10-03  8:40 ` Elena Zannoni
  0 siblings, 0 replies; 2+ messages in thread
From: Elena Zannoni @ 2026-10-03  8:40 UTC (permalink / raw)
  To: Kris Van Hees, dtrace, dtrace-devel


Reviewed-by: Elena Zannoni <elena.zannoni@oracle.com>

On 9/28/26 12:02 PM, Kris Van Hees via DTrace-devel wrote:

> Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
> ---
>  libdtrace/dt_decl.c                              | 10 ++++++++++
>  .../types/err.D_DECL_SCOPE.scopeop-enum-tag.d    | 16 ++++++++++++++++
>  .../types/err.D_DECL_SCOPE.scopeop-enum-tag.r    |  2 ++
>  .../types/err.D_DECL_SCOPE.scopeop-struct-tag.d  | 16 ++++++++++++++++
>  .../types/err.D_DECL_SCOPE.scopeop-struct-tag.r  |  2 ++
>  .../types/err.D_DECL_SCOPE.scopeop-union-tag.d   | 16 ++++++++++++++++
>  .../types/err.D_DECL_SCOPE.scopeop-union-tag.r   |  2 ++
>  7 files changed, 64 insertions(+)
>  create mode 100644 test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.d
>  create mode 100644 test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.r
>  create mode 100644 test/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.d
>  create mode 100644 test/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.r
>  create mode 100644 test/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.d
>  create mode 100644 test/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.r
> 
> diff --git a/libdtrace/dt_decl.c b/libdtrace/dt_decl.c
> index 68999422..80ab7826 100644
> --- a/libdtrace/dt_decl.c
> +++ b/libdtrace/dt_decl.c
> @@ -440,6 +440,11 @@ dt_decl_ptr(void)
>  dt_decl_t *
>  dt_decl_sou(uint_t kind, char *name)
>  {
> +	if (name != NULL && strchr(name, '`') != NULL) {
> +		xyerror(D_DECL_SCOPE, "D scoping operator may not be used "
> +		    "in a type name\n");
> +	}
> +
>  	dt_decl_t *ddp = dt_decl_spec(kind, name);
>  	char n[DT_TYPE_NAMELEN];
>  	ctf_file_t *ctfp;
> @@ -637,6 +642,11 @@ dt_decl_hasmembers(const char *name, int value, void *private)
>  dt_decl_t *
>  dt_decl_enum(char *name)
>  {
> +	if (name != NULL && strchr(name, '`') != NULL) {
> +		xyerror(D_DECL_SCOPE, "D scoping operator may not be used "
> +		    "in a type name\n");
> +	}
> +
>  	dt_decl_t *ddp = dt_decl_spec(CTF_K_ENUM, name);
>  	char n[DT_TYPE_NAMELEN];
>  	ctf_file_t *ctfp;
> diff --git a/test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.d b/test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.d
> new file mode 100644
> index 00000000..e43e94e5
> --- /dev/null
> +++ b/test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.d
> @@ -0,0 +1,16 @@
> +/*
> + * Oracle Linux DTrace.
> + * Copyright (c) 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: D scoping operators are not permitted in enum definition tags.
> + */
> +
> +#pragma D option quiet
> +
> +enum foo`bar {
> +	value
> +};
> diff --git a/test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.r b/test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.r
> new file mode 100644
> index 00000000..3e0caeb5
> --- /dev/null
> +++ b/test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.r
> @@ -0,0 +1,2 @@
> +-- @@stderr --
> +dtrace: failed to compile script test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.d: [D_DECL_SCOPE] line 14: D scoping operator may not be used in a type name
> diff --git a/test/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.d b/test/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.d
> new file mode 100644
> index 00000000..3f786e58
> --- /dev/null
> +++ b/test/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.d
> @@ -0,0 +1,16 @@
> +/*
> + * Oracle Linux DTrace.
> + * Copyright (c) 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: D scoping operators are not permitted in struct definition tags.
> + */
> +
> +#pragma D option quiet
> +
> +struct foo`bar {
> +	int value;
> +};
> diff --git a/test/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.r b/test/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.r
> new file mode 100644
> index 00000000..b071cf9c
> --- /dev/null
> +++ b/test/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.r
> @@ -0,0 +1,2 @@
> +-- @@stderr --
> +dtrace: failed to compile script test/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.d: [D_DECL_SCOPE] line 14: D scoping operator may not be used in a type name
> diff --git a/test/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.d b/test/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.d
> new file mode 100644
> index 00000000..5e504cf5
> --- /dev/null
> +++ b/test/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.d
> @@ -0,0 +1,16 @@
> +/*
> + * Oracle Linux DTrace.
> + * Copyright (c) 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: D scoping operators are not permitted in union definition tags.
> + */
> +
> +#pragma D option quiet
> +
> +union foo`bar {
> +	int value;
> +};
> diff --git a/test/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.r b/test/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.r
> new file mode 100644
> index 00000000..7f35b11c
> --- /dev/null
> +++ b/test/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.r
> @@ -0,0 +1,2 @@
> +-- @@stderr --
> +dtrace: failed to compile script test/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.d: [D_DECL_SCOPE] line 14: D scoping operator may not be used in a type name
> -- 
> 2.52.0
> 
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel@oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-03  8:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-28 18:02 [PATCH 4/8] parser: reject scoped type declarations Kris Van Hees
2026-10-03  8:40 ` [DTrace-devel] " Elena Zannoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox