Commit f375b7a7 by Joseph Myers Committed by Joseph Myers

re PR c/2735 (can't cast a union type defined by a typedef to itself)

	* c-typeck.c (build_c_cast): Use TYPE_MAIN_VARIANT when checking
	for casting an aggregate to its own type.  Fixes PR c/2735.

testsuite:
	* gcc.c-torture/compile/20010605-2.c: New test.

From-SVN: r42900
parent c90efa7a
2001-06-05 Joseph S. Myers <jsm28@cam.ac.uk>
* c-typeck.c (build_c_cast): Use TYPE_MAIN_VARIANT when checking
for casting an aggregate to its own type. Fixes PR c/2735.
2001-06-05 Joseph S. Myers <jsm28@cam.ac.uk>
* doc/texinfo.tex: Update to version 2001-05-24.08.
2001-06-05 Nathan Sidwell <nathan@codesourcery.com>
......
......@@ -3719,7 +3719,7 @@ build_c_cast (type, expr)
return error_mark_node;
}
if (type == TREE_TYPE (value))
if (type == TYPE_MAIN_VARIANT (TREE_TYPE (value)))
{
if (pedantic)
{
......
2001-06-05 Joseph S. Myers <jsm28@cam.ac.uk>
* gcc.c-torture/compile/20010605-2.c: New test.
2001-06-04 John David Anglin <dave@hiauly1.hia.nrc.ca>
* gcc.c-torture/execute/20010604-1.c: New test.
......
/* Origin: Joseph Myers <jsm28@cam.ac.uk>. */
/* As an extension, GCC allows a struct or union to be cast to its own
type, but failed to allow this when a typedef was involved.
Reported as PR c/2735 by <cowan@ccil.org>. */
union u { int i; };
typedef union u uu;
union u a;
uu b;
void
foo (void)
{
a = (union u) b;
a = (uu) b;
b = (union u) a;
b = (uu) a;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment