diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-10-07 21:37:46 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-10-07 21:37:46 +0200 |
commit | be845b04a8e13e91e7ecd76b60254c7d0acfda2e (patch) | |
tree | 7b14e19adcc90c0ed591c2745b010b6ffcf52ade /gcc/cp/parser.c | |
parent | 082139830afb428628657a7520659a01ae00b852 (diff) | |
download | gcc-be845b04a8e13e91e7ecd76b60254c7d0acfda2e.zip gcc-be845b04a8e13e91e7ecd76b60254c7d0acfda2e.tar.gz gcc-be845b04a8e13e91e7ecd76b60254c7d0acfda2e.tar.bz2 |
Implement LWG2296 helper intrinsic c-family/
Implement LWG2296 helper intrinsic
c-family/
* c-common.h (enum rid): Add RID_ADDRESSOF.
* c-common.c (c_common_reswords): Add __builtin_addressof.
cp/
* parser.c (cp_parser_postfix_expression): Handle RID_ADDRESSOF.
* cp-objcp-common.c (cp_common_init_ts): Handle ADDRESSOF_EXPR.
* constexpr.c (potential_constant_expression_1): Likewise.
* error.c (dump_expr): Likewise.
* typeck.c (cp_build_addressof): New function.
* cp-tree.h (cp_build_addressof): Declare.
* cxx-pretty-print.h (pp_cxx_addressof_expression): Declare.
* cp-tree.def (ADDRESSOF_EXPR): New tree code.
* cxx-pretty-print.c (cxx_pretty_printer::primary_expression): Handle
ADDRESSOF_EXPR. Add __builtin_addressof and
__has_unique_object_representations into syntax in function comment.
(pp_cxx_addressof_expression): New function.
* pt.c (tsubst_copy_and_build): Handle ADDRESSOF_EXPR.
testsuite/
* g++.dg/cpp0x/addressof1.C: New test.
* g++.dg/cpp0x/addressof2.C: New test.
From-SVN: r240873
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r-- | gcc/cp/parser.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 8728991..643c1e7 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -6602,6 +6602,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, break; } + case RID_ADDRESSOF: case RID_BUILTIN_SHUFFLE: { vec<tree, va_gc> *vec; @@ -6618,19 +6619,29 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, FOR_EACH_VEC_ELT (*vec, i, p) mark_exp_read (p); - if (vec->length () == 2) - return build_x_vec_perm_expr (loc, (*vec)[0], NULL_TREE, (*vec)[1], - tf_warning_or_error); - else if (vec->length () == 3) - return build_x_vec_perm_expr (loc, (*vec)[0], (*vec)[1], (*vec)[2], - tf_warning_or_error); - else - { - error_at (loc, "wrong number of arguments to " - "%<__builtin_shuffle%>"); - return error_mark_node; - } - break; + switch (keyword) + { + case RID_ADDRESSOF: + if (vec->length () == 1) + return cp_build_addressof (loc, (*vec)[0], tf_warning_or_error); + error_at (loc, "wrong number of arguments to " + "%<__builtin_addressof%>"); + return error_mark_node; + + case RID_BUILTIN_SHUFFLE: + if (vec->length () == 2) + return build_x_vec_perm_expr (loc, (*vec)[0], NULL_TREE, + (*vec)[1], tf_warning_or_error); + else if (vec->length () == 3) + return build_x_vec_perm_expr (loc, (*vec)[0], (*vec)[1], + (*vec)[2], tf_warning_or_error); + error_at (loc, "wrong number of arguments to " + "%<__builtin_shuffle%>"); + return error_mark_node; + + default: + gcc_unreachable (); + } } default: |