aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2022-03-26 08:11:58 +0100
committerJakub Jelinek <jakub@redhat.com>2022-03-26 08:11:58 +0100
commit1806829e08f14e4cacacec43d7845cc2dad2ddc8 (patch)
tree910f52f8dacb211d7f8c331db8f691ca1c9bff74 /gcc/cp
parent75d1c8fea9541dee5a4ce0aa7d8c199574fd42b9 (diff)
downloadgcc-1806829e08f14e4cacacec43d7845cc2dad2ddc8.zip
gcc-1806829e08f14e4cacacec43d7845cc2dad2ddc8.tar.gz
gcc-1806829e08f14e4cacacec43d7845cc2dad2ddc8.tar.bz2
c++: Fix up __builtin_{bit_cast,convertvector} parsing
Jonathan reported on IRC that we don't parse __builtin_bit_cast (type, val).field etc. The problem is that for these 2 builtins we return from cp_parser_postfix_expression instead of setting postfix_expression to the cp_build_* value and falling through into the postfix regression suffix handling loop. 2022-03-26 Jakub Jelinek <jakub@redhat.com> * parser.cc (cp_parser_postfix_expression) <case RID_BILTIN_CONVERTVECTOR, case RID_BUILTIN_BIT_CAST>: Don't return cp_build_{vec,convert,bit_cast} result right away, instead set postfix_expression to it and break. * c-c++-common/builtin-convertvector-3.c: New test. * g++.dg/cpp2a/bit-cast15.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/parser.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 15ad640..d3c22ee 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -7525,8 +7525,10 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
}
/* Look for the closing `)'. */
parens.require_close (parser);
- return cp_build_vec_convert (expression, type_location, type,
- tf_warning_or_error);
+ postfix_expression
+ = cp_build_vec_convert (expression, type_location, type,
+ tf_warning_or_error);
+ break;
}
case RID_BUILTIN_BIT_CAST:
@@ -7551,8 +7553,10 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
expression = cp_parser_assignment_expression (parser);
/* Look for the closing `)'. */
parens.require_close (parser);
- return cp_build_bit_cast (type_location, type, expression,
- tf_warning_or_error);
+ postfix_expression
+ = cp_build_bit_cast (type_location, type, expression,
+ tf_warning_or_error);
+ break;
}
default: