Bug 42603 - [C++0x] decltype not supported for parent class specifier
Summary: [C++0x] decltype not supported for parent class specifier
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.4.2
: P3 enhancement
Target Milestone: 4.7.0
Assignee: Jason Merrill
URL:
Keywords:
: 49155 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-01-04 05:23 UTC by James Pike
Modified: 2011-07-20 16:15 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-01-04 09:47:56


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description James Pike 2010-01-04 05:23:57 UTC
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.
Comment 1 Paolo Carlini 2010-01-04 09:47:56 UTC
Let's CC Jason...
Comment 2 Jason Merrill 2010-01-05 13:29:43 UTC
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.
Comment 3 Adam Butcher 2011-01-20 22:07:31 UTC
Fix proposed for this in http://gcc.gnu.org/ml/gcc-patches/2011-01/msg01387.html
Comment 4 Jonathan Wakely 2011-05-25 09:38:50 UTC
*** Bug 49155 has been marked as a duplicate of this bug. ***
Comment 5 Jason Merrill 2011-07-20 14:21:09 UTC
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
Comment 6 Jason Merrill 2011-07-20 16:15:05 UTC
Implemented for 4.7.