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]

[C++ PATCH] Implementation of C++0x decltype


Hello all,

The attached patches (for gcc, cp, testsuite subdirs) implement the C+ +0x "decltype" facility, which computes the declared type of an arbitrary expression. The latest standard wording, on which this patch is based, is available here:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2115.pdf

Decltype has not yet been voted into the C++0x working draft, but it has been approved by the C++ Evolution Working Group and has been extensively discussed in the Core Working Group, so it is relatively stable (only corner cases are likely to change). It's a highly- requested feature in the library writer community. This patch only makes decltype available when the experimental C++0x mode is enabled.

Tested i386-apple-darwin8.8.1, no regressions.

Okay for mainline?

	Cheers,
	Doug

2007-02-03 Douglas Gregor <doug.gregor@gmail.com>

	* typeck.c (structural_comptypes): Compare DECLARED_TYPE nodes.
	* cp-tree.def (DECLARED_TYPE): New.
	* error.c (dump_type): Dump DECLARED_TYPE nodes.
	(dump_type_prefix): Ditto.
	(dump_type_suffix): Ditto.
	* tree.c (DECLARED_TYPE): Walk DECLARED_TYPE nodes.
	* mangle.c (write_type): Handle DECLARED_TYPE, but don't mangle
	the expression.
	* cp-tree.h (IS_AGGR_TYPE): DECLARED_TYPE nodes can be aggregate
	types.
	(DECLARED_TYPE_EXPR): New.
	(DECLARED_TYPE_ID_EXPR_OR_MEMBER_ACCESS_P): New.
	(finished_declared_type): Declare.
	* cxx-pretty-print.c (pp_cxx_type_specifier_seq): Print
	DECLARED_TYPE nodes.
	(pp_cxx_type_id): Ditto.
	* pt.c (for_each_tempalte_parm_r): Walk DECLARED_TYPE children.
	(tsubst): Substitute into a DECLARED_TYPE node.
	(tsubst_copy): Ditto.
	(unify): Cannot deduce anything from TYPEOF_OF or DECLARED_TYPE
	nodes.
	(dependent_type_p_r): DECLARED_TYPE types are always dependent.
	* semantics.c (finish_typeof): TYPEOF_TYPE types need to use
	structural equality (because we can't hash the expressions).
	(finish_declared_type): New.
	* lex.c (reswords): Add "decltype" keyword.
	* parser.c (cp_parser_postfix_expression): Add
	MEMBER_ACCESS_ONLY_P to restrict postfix expression to member
	access expressions.
	(cp_parser_unary_expression): Update call to
	cp_parser_postfix_expression to reflect new parameter.
	(cp_parser_declared_type): New.
	(cp_parser_simple_type_specifier): Parse decltype types.
	
2007-02-03  Douglas Gregor  <doug.gregor@gmail.com>

* c-common.h (enum rid): Add RID_DECLTYPE, update RID_LAST_CXX0X.

2007-02-03 Douglas Gregor <doug.gregor@gmail.com>

	* g++.dg/cpp0x/decltype1.C: New.
	* g++.dg/cpp0x/decltype2.C: New.
	* g++.dg/cpp0x/decltype3.C: New.
	* g++.dg/cpp0x/decltype4.C: New.
	* g++.dg/cpp0x/decltype5.C: New.
	* g++.dg/cpp0x/decltype6.C: New.
	* g++.dg/cpp0x/decltype7.C: New.

Attachment: decltype-cp.patch
Description: Binary data

Attachment: decltype-gcc.patch
Description: Binary data

Attachment: decltype-testsuite.patch
Description: Binary data


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