summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorBryan Cantrill <bryan@joyent.com>2011-07-07 20:20:29 -0700
committerBryan Cantrill <bryan@joyent.com>2011-07-07 20:20:29 -0700
commitec57c73d4fc9c578fb346a0ee62c842c5b66fb97 (patch)
tree86c772e3d52fd3c475c6d066120057f7635f6f79 /usr/src
parent7d5c9b5fdaad32a290692afde7867bd051784395 (diff)
downloadillumos-gate-ec57c73d4fc9c578fb346a0ee62c842c5b66fb97.tar.gz
1458 D compiler fails to generate error on sizeof() an undefined struct
Reviewed by: Gordon Ross <gwr@nexenta.com> Reviewed by: Eric Schrock <eric.schrock@delphix.com> Approved by: Garrett D'Amore <garrett@nexenta.com>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/sizeof/err.D_SIZEOF_TYPE.badstruct.d30
-rw-r--r--usr/src/lib/libdtrace/common/dt_parser.c8
-rw-r--r--usr/src/pkg/manifests/system-dtrace-tests.mf2
3 files changed, 40 insertions, 0 deletions
diff --git a/usr/src/cmd/dtrace/test/tst/common/sizeof/err.D_SIZEOF_TYPE.badstruct.d b/usr/src/cmd/dtrace/test/tst/common/sizeof/err.D_SIZEOF_TYPE.badstruct.d
new file mode 100644
index 0000000000..c921db88b6
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/sizeof/err.D_SIZEOF_TYPE.badstruct.d
@@ -0,0 +1,30 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2011, Joyent Inc. All rights reserved.
+ */
+
+BEGIN
+{
+ trace(sizeof (struct suckitlarry));
+ exit(0);
+}
diff --git a/usr/src/lib/libdtrace/common/dt_parser.c b/usr/src/lib/libdtrace/common/dt_parser.c
index 6ad30a9ac5..05715894a7 100644
--- a/usr/src/lib/libdtrace/common/dt_parser.c
+++ b/usr/src/lib/libdtrace/common/dt_parser.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, Joyent Inc. All rights reserved.
*/
/*
@@ -719,12 +720,19 @@ dt_node_type_name(const dt_node_t *dnp, char *buf, size_t len)
size_t
dt_node_type_size(const dt_node_t *dnp)
{
+ ctf_id_t base;
+
if (dnp->dn_kind == DT_NODE_STRING)
return (strlen(dnp->dn_string) + 1);
if (dt_node_is_dynamic(dnp) && dnp->dn_ident != NULL)
return (dt_ident_size(dnp->dn_ident));
+ base = ctf_type_resolve(dnp->dn_ctfp, dnp->dn_type);
+
+ if (ctf_type_kind(dnp->dn_ctfp, base) == CTF_K_FORWARD)
+ return (0);
+
return (ctf_type_size(dnp->dn_ctfp, dnp->dn_type));
}
diff --git a/usr/src/pkg/manifests/system-dtrace-tests.mf b/usr/src/pkg/manifests/system-dtrace-tests.mf
index fcb488550c..97904e96f3 100644
--- a/usr/src/pkg/manifests/system-dtrace-tests.mf
+++ b/usr/src/pkg/manifests/system-dtrace-tests.mf
@@ -1532,6 +1532,8 @@ file path=opt/SUNWdtrt/tst/common/sizeof/err.D_IDENT_BADREF.SizeofAssoc.d \
mode=0444
file path=opt/SUNWdtrt/tst/common/sizeof/err.D_IDENT_UNDEF.UnknownSymbol.d \
mode=0444
+file path=opt/SUNWdtrt/tst/common/sizeof/err.D_SIZEOF_TYPE.badstruct.d \
+ mode=0444
file path=opt/SUNWdtrt/tst/common/sizeof/err.D_SIZEOF_TYPE.d mode=0444
file path=opt/SUNWdtrt/tst/common/sizeof/err.D_SYNTAX.SizeofBadType.d \
mode=0444