parser: reject scoped type declarations
PATCH 4/8 parser: reject scoped type declarations
Signed-off-by Kris Van Hees <[email protected]>
--- 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
libdtrace/dt_decl.c +10 -0
@@ -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;
test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.d new file +16 -0
@@ -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 +};
test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.r new file +2 -0
@@ -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
test/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.d new file +16 -0
@@ -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; +};
test/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.r new file +2 -0
@@ -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
test/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.d new file +16 -0
@@ -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; +};
test/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.r new file +2 -0
@@ -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
Signature · 1 line
2.52.0
Reviewed-by Elena Zannoni <[email protected]>
Quoted 144 lines · Kris Van Hees via DTrace-devel
Signed-off-by Kris Van Hees <[email protected]>--- 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.rlibdtrace/dt_decl.c +10
-0@@ -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;test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.d new file +16
-0@@ -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 +};test/unittest/types/err.D_DECL_SCOPE.scopeop-enum-tag.r new file +2
-0@@ -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 nametest/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.d new file +16
-0@@ -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; +};test/unittest/types/err.D_DECL_SCOPE.scopeop-struct-tag.r new file +2
-0@@ -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 nametest/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.d new file +16
-0@@ -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; +};test/unittest/types/err.D_DECL_SCOPE.scopeop-union-tag.r new file +2
-0@@ -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 nameSignature · 7 lines
2.52.0 _______________________________________________ DTrace-devel mailing list [email protected] https://oss.oracle.com/mailman/listinfo/dtrace-devel