file: test.cpp template <class T> T make(); struct p {}; struct c : decltype(make<p>()) {}; compilation command: g++ -c -std=c++0x test.cpp output: test.cpp:5: error: expected class-name before 'decltype' test.cpp:5: error: expected '{' before 'decltype' test.cpp:5: error: expected unqualified-id before '{' token Expected result: c should inherit p and everything should compile fine. Note that this can be worked around with the following modification: template <class T> T make(); template <class T> struct wrap { typedef T type; }; struct p {}; struct c : wrap< decltype(make<p>()) >::type {}; However this modification is cumbersome and seems pointless.
Let's CC Jason...
This is http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#950 we decided in Santa Cruz that this usage should be allowed.
Fix proposed for this in http://gcc.gnu.org/ml/gcc-patches/2011-01/msg01387.html
*** Bug 49155 has been marked as a duplicate of this bug. ***
Author: jason Date: Wed Jul 20 14:21:05 2011 New Revision: 176513 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176513 Log: PR c++/6709 (DR 743) PR c++/42603 (DR 950) gcc/cp/ * parser.c (token_is_decltype, cp_lexer_next_token_is_decltype): New. (cp_parser_nested_name_specifier_opt): Allow decltype. (cp_parser_qualifying_entity): Likewise. (cp_parser_decltype): Replace source tokens with CPP_DECLTYPE. (cp_parser_simple_type_specifier): Handle decltype as scope. (cp_parser_base_specifier): Allow decltype. (cp_parser_base_clause): Don't crash on null base. * parser.h (CPP_KEYWORD, CPP_TEMPLATE_ID): Move to c-common.h. (CPP_NESTED_NAME_SPECIFIER, N_CP_TTYPES): Likewise. gcc/c-family/ * c-common.h (CPP_KEYWORD, CPP_TEMPLATE_ID): Move from cp/parser.h. (CPP_NESTED_NAME_SPECIFIER, N_CP_TTYPES): Likewise. (CPP_DECLTYPE): New. * c-common.c (c_parse_error): Handle CPP_DECLTYPE. Added: trunk/gcc/testsuite/g++.dg/cpp0x/decltype21.C Modified: trunk/gcc/c-family/ChangeLog trunk/gcc/c-family/c-common.c trunk/gcc/c-family/c-common.h trunk/gcc/cp/ChangeLog trunk/gcc/cp/parser.c trunk/gcc/cp/parser.h trunk/gcc/testsuite/ChangeLog
Implemented for 4.7.