gcc/gcc/testsuite/gcc.dg/decl-8.c
Joseph Myers dc5027f474 c-decl.c (diagnose_mismatched_decls): Give error for duplicate typedefs with different but compatible types.
* c-decl.c (diagnose_mismatched_decls): Give error for duplicate
	typedefs with different but compatible types.  Allow duplicate
	typedefs with the same type except for pedantic non-C1X, but give
	warning for variably modified types.
	* c-typeck.c (tagged_types_tu_compatible_p,
	function_types_compatible_p, type_lists_compatible_p,
	comptypes_internal): Add parameter different_types_p; set
	*different_types_p for different but compatible types.  All
	callers changed.
	(comptypes_check_different_types): New.
	* c-tree.h (comptypes_check_different_types): Declare.

testsuite:
	* gcc.dg/c1x-typedef-1.c, gcc.dg/c1x-typedef-2.c,
	gcc.dg/c90-typedef-1.c, gcc.dg/c99-typedef-1.c: New tests.
	* gcc.dg/decl-8.c: Use -std=gnu89 -pedantic-errors.

From-SVN: r159767
2010-05-23 21:47:16 +01:00

11 lines
491 B
C

/* Test diagnostics for duplicate typedefs. Basic diagnostics. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "-std=gnu89 -pedantic-errors" } */
typedef int I; /* { dg-message "note: previous declaration of 'I' was here" } */
typedef int I; /* { dg-error "redefinition of typedef 'I'" } */
typedef int I1; /* { dg-message "note: previous declaration of 'I1' was here" } */
typedef long I1; /* { dg-error "conflicting types for 'I1'" } */