err.D_PROTO_ARG.DupStructAssoc.d revision 178476
154359Sroberto/*
254359Sroberto * CDDL HEADER START
354359Sroberto *
482498Sroberto * The contents of this file are subject to the terms of the
554359Sroberto * Common Development and Distribution License (the "License").
682498Sroberto * You may not use this file except in compliance with the License.
754359Sroberto *
854359Sroberto * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
954359Sroberto * or http://www.opensolaris.org/os/licensing.
1054359Sroberto * See the License for the specific language governing permissions
1154359Sroberto * and limitations under the License.
1254359Sroberto *
1354359Sroberto * When distributing Covered Code, include this CDDL HEADER in each
1454359Sroberto * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1554359Sroberto * If applicable, add the following below this CDDL HEADER, with the
1682498Sroberto * fields enclosed by brackets "[]" replaced with your own identifying
1782498Sroberto * information: Portions Copyright [yyyy] [name of copyright owner]
1882498Sroberto *
1982498Sroberto * CDDL HEADER END
2082498Sroberto */
2182498Sroberto
2282498Sroberto/*
2382498Sroberto * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
2482498Sroberto * Use is subject to license terms.
2582498Sroberto */
2682498Sroberto
2782498Sroberto#pragma ident	"%Z%%M%	%I%	%E% SMI"
2882498Sroberto
2982498Sroberto/*
3054359Sroberto * ASSERTION:
3154359Sroberto * Declaring an associative array with a struct to be its key type and trying to
3254359Sroberto * index with another struct having the same composition throws an error.
3354359Sroberto *
3454359Sroberto * SECTION: Structs and Unions/Structs
3554359Sroberto *
3654359Sroberto */
3754359Sroberto
3854359Sroberto#pragma D option quiet
3954359Sroberto
4054359Srobertostruct record {
4154359Sroberto	int position;
42132451Sroberto	char content;
43132451Sroberto};
44132451Sroberto
4554359Srobertostruct pirate {
4654359Sroberto	int position;
4754359Sroberto	char content;
4854359Sroberto};
4954359Sroberto
5054359Srobertostruct record r1;
5154359Srobertostruct record r2;
5254359Srobertostruct pirate p1;
5354359Srobertostruct pirate p2;
5454359Sroberto
5554359SrobertoBEGIN
5654359Sroberto{
5754359Sroberto	r1.position = 1;
5854359Sroberto	r1.content = 'a';
5954359Sroberto
6054359Sroberto	r2.position = 2;
6154359Sroberto	r2.content = 'b';
6254359Sroberto
6354359Sroberto	p1.position = 1;
6454359Sroberto	p1.content = 'a';
6554359Sroberto
6654359Sroberto	p2.position = 2;
6754359Sroberto	p2.content = 'b';
6854359Sroberto
6954359Sroberto	assoc_array[r1] = 1000;
7054359Sroberto	assoc_array[r2] = 2000;
7154359Sroberto	assoc_array[p1] = 3333;
7254359Sroberto	assoc_array[p2] = 4444;
7354359Sroberto
7454359Sroberto	printf("assoc_array[r1]: %d\n",  assoc_array[r1]);
7554359Sroberto	printf("assoc_array[r2]: %d\n",  assoc_array[r2]);
7654359Sroberto	printf("assoc_array[p1]: %d\n",  assoc_array[p1]);
7754359Sroberto	printf("assoc_array[p2]: %d\n",  assoc_array[p2]);
78132451Sroberto
79132451Sroberto	exit(0);
80132451Sroberto}
81132451Sroberto