diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2011-04-25 22:27:19 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2011-04-25 22:27:19 +0000 |
commit | a0d260fcc5f6fe1a246e8ee40235a825369f3627 (patch) | |
tree | b836cd0e728b772f3240bdb6c981032673cb2745 /gcc/cp/parser.c | |
parent | d95f258e9027e7d797bde4eace3e29ab7d9382db (diff) | |
download | gcc-a0d260fcc5f6fe1a246e8ee40235a825369f3627.zip gcc-a0d260fcc5f6fe1a246e8ee40235a825369f3627.tar.gz gcc-a0d260fcc5f6fe1a246e8ee40235a825369f3627.tar.bz2 |
c-common.c (struct c_common_resword): Add __underlying_type.
/gcc
2011-04-25 Paolo Carlini <paolo.carlini@oracle.com>
* c-family/c-common.c (struct c_common_resword): Add
__underlying_type.
* c-family/c-common.h (enum rid): Add RID_UNDERLYING_TYPE.
/cp
2011-04-25 Paolo Carlini <paolo.carlini@oracle.com>
* cp-tree.def: Add a new UNDERLYING_TYPE tree code.
* cp-tree.h (enum cp_trait_kind): Add CPTK_UNDERLYING_TYPE, tidy.
(UNDERLYING_TYPE_TYPE): Add.
* cp-objcp-common.c (cp_common_init_ts): Mark UNDERLYING_TYPE
as TS_COMMON.
* parser.c (cp_lexer_next_token_is_decl_specifier_keyword,
cp_parser_simple_type_specifier): Handle UNDERLYING_TYPE.
(cp_parser_trait_expr): Deal with RID_UNDERLYING_TYPE; tidy.
* semantics.c (finish_underlying_type): New.
* typeck.c (structural_comptypes): Handle UNDERLYING_TYPE.
* error.c (dump_type, dump_type_prefix, dump_type_suffix): Likewise.
* cxx-pretty-print.c (p_cxx_type_id): Likewise.
* tree.c (cp_walk_subtrees): Likewise.
* pt.c (for_each_template_parm_r, tsubst, unify,
dependent_type_p_r): Likewise.
* mangle.c (write_type): Sorry for __underlying_type.
* doc/extend.texi: Document __underlying_type.
/testsuite
2011-04-25 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/ext/underlying_type1.C: New.
* g++.dg/ext/underlying_type2.C: Likewise.
* g++.dg/ext/underlying_type3.C: Likewise.
* g++.dg/ext/underlying_type4.C: Likewise.
* g++.dg/ext/underlying_type5.C: Likewise.
* g++.dg/ext/underlying_type6.C: Likewise.
* g++.dg/ext/underlying_type7.C: Likewise.
* g++.dg/ext/underlying_type8.C: Likewise.
* g++.dg/ext/underlying_type9.C: Likewise.
* g++.dg/ext/underlying_type10.C: Likewise.
From-SVN: r172943
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r-- | gcc/cp/parser.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 7d3121c..bb97700 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -1,6 +1,6 @@ /* C++ Parser. Copyright (C) 2000, 2001, 2002, 2003, 2004, - 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + 2005, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. Written by Mark Mitchell <mark@codesourcery.com>. This file is part of GCC. @@ -654,6 +654,7 @@ cp_lexer_next_token_is_decl_specifier_keyword (cp_lexer *lexer) case RID_TYPEOF: /* C++0x extensions. */ case RID_DECLTYPE: + case RID_UNDERLYING_TYPE: return true; default: @@ -7129,7 +7130,10 @@ cp_parser_builtin_offsetof (cp_parser *parser) return expr; } -/* Parse a trait expression. */ +/* Parse a trait expression. + + Returns a representation of the expression, the underlying type + of the type at issue when KEYWORD is RID_UNDERLYING_TYPE. */ static tree cp_parser_trait_expr (cp_parser* parser, enum rid keyword) @@ -7185,6 +7189,9 @@ cp_parser_trait_expr (cp_parser* parser, enum rid keyword) case RID_IS_ENUM: kind = CPTK_IS_ENUM; break; + case RID_IS_LITERAL_TYPE: + kind = CPTK_IS_LITERAL_TYPE; + break; case RID_IS_POD: kind = CPTK_IS_POD; break; @@ -7200,8 +7207,8 @@ cp_parser_trait_expr (cp_parser* parser, enum rid keyword) case RID_IS_UNION: kind = CPTK_IS_UNION; break; - case RID_IS_LITERAL_TYPE: - kind = CPTK_IS_LITERAL_TYPE; + case RID_UNDERLYING_TYPE: + kind = CPTK_UNDERLYING_TYPE; break; default: gcc_unreachable (); @@ -7247,7 +7254,9 @@ cp_parser_trait_expr (cp_parser* parser, enum rid keyword) /* Complete the trait expression, which may mean either processing the trait expr now or saving it for template instantiation. */ - return finish_trait_expr (kind, type1, type2); + return kind != CPTK_UNDERLYING_TYPE + ? finish_trait_expr (kind, type1, type2) + : finish_underlying_type (type1); } /* Lambdas that appear in variable initializer or default argument scope @@ -12505,6 +12514,7 @@ cp_parser_type_specifier (cp_parser* parser, decltype ( expression ) char16_t char32_t + __underlying_type ( type-id ) GNU Extension: @@ -12621,6 +12631,16 @@ cp_parser_simple_type_specifier (cp_parser* parser, return type; + case RID_UNDERLYING_TYPE: + type = cp_parser_trait_expr (parser, RID_UNDERLYING_TYPE); + + if (decl_specs) + cp_parser_set_decl_spec_type (decl_specs, type, + token->location, + /*user_defined_p=*/true); + + return type; + default: break; } |