This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix may_alias canonical types regression


This patch fixes PR c++/37553, which is a canonical types regression
regarding uses of the may_alias attribute. The tweak to
build_type_attribute_qual_variant is obvious: we just use the regular
pattern with type_hash_canon and setting TYPE_CANONICAL.

The change to type_hash_eq is a bit more interesting: as part of
testing the first change, I found that type_hash_eq was treating
wchar_t the same as its underlying integer type.  This means that
type_hash_canon on a copy of wchar_t (e.g., an attribute-qualified
copy) would actually end up being hashed down to an
attribute-qualified version of its underlying type. In C, that's okay;
in C++, it means we've lost the wchar_t'ness of the type, which means
we wouldn't be able to overload attribute-qualified wchar_t's
properly. Fixed by making the TYPE_NAME of INTEGER_TYPEs significant.

Tested i386-apple-darwin8.11.1 with no regressions. Assuming bootstrap
runs through, okay for mainline and 4.3?

  - Doug

2008-09-24  Douglas Gregor  <doug.gregor@gmail.com>

	PR c++/37553
	* tree.c (build_type_attribute_qual_variant): Hash on the
	unqualified type, and don't overwrite an existing
	(type_hash_eq): For INTEGER_TYPE nodes, make the TYPE_NAME of the
	types significant, to allow distinguishing between wchar_t and its
	underlying type. This also means that we'll retain a little more
	typedef information.

2008-09-24  Douglas Gregor  <doug.gregor@gmail.com>

	PR c++/37553
	* g++.dg/ext/alias-canon2.C: New.

Attachment: canon-may-alias.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]