diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-10-31 18:08:36 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-10-31 18:08:36 +0100 |
commit | c5fed5c6f272f99c9a86eaa63f6c8c142cce0e86 (patch) | |
tree | ae96439c0919731e3e449e96f7e324ec170d665f | |
parent | f04c1e0a56efa150b061810437f14bec45e85783 (diff) | |
download | gcc-c5fed5c6f272f99c9a86eaa63f6c8c142cce0e86.zip gcc-c5fed5c6f272f99c9a86eaa63f6c8c142cce0e86.tar.gz gcc-c5fed5c6f272f99c9a86eaa63f6c8c142cce0e86.tar.bz2 |
re PR c++/78089 (__builtin_shuffle parsing bug)
PR c++/78089
* parser.c (cp_parser_postfix_expression): Replace return statement in
the first switch with setting postfix_expression to the return
expression and break;.
* c-c++-common/builtin-shuffle-1.c: New test.
* g++.dg/cpp0x/addressof3.C: New test.
From-SVN: r241710
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/parser.c | 45 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/builtin-shuffle-1.c | 22 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/addressof3.C | 9 |
5 files changed, 73 insertions, 14 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 39da99e..b657f62 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2016-10-31 Jakub Jelinek <jakub@redhat.com> + PR c++/78089 + * parser.c (cp_parser_postfix_expression): Replace return statement in + the first switch with setting postfix_expression to the return + expression and break;. + PR c++/77886 * g++.dg/warn/Wimplicit-fallthrough-2.C: New test. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 53eafa7..e443648 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -6441,7 +6441,10 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, can be used in constant-expressions. */ if (!cast_valid_in_integral_constant_expression_p (type) && cp_parser_non_integral_constant_expression (parser, NIC_CAST)) - return error_mark_node; + { + postfix_expression = error_mark_node; + break; + } switch (keyword) { @@ -6521,7 +6524,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, parser->type_definition_forbidden_message = saved_message; /* `typeid' may not appear in an integral constant expression. */ if (cp_parser_non_integral_constant_expression (parser, NIC_TYPEID)) - return error_mark_node; + postfix_expression = error_mark_node; } break; @@ -6615,7 +6618,10 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, /*cast_p=*/false, /*allow_expansion_p=*/true, /*non_constant_p=*/NULL); if (vec == NULL) - return error_mark_node; + { + postfix_expression = error_mark_node; + break; + } FOR_EACH_VEC_ELT (*vec, i, p) mark_exp_read (p); @@ -6624,10 +6630,15 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, { 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; + postfix_expression + = cp_build_addressof (loc, (*vec)[0], tf_warning_or_error); + else + { + error_at (loc, "wrong number of arguments to " + "%<__builtin_addressof%>"); + postfix_expression = error_mark_node; + } + break; case RID_BUILTIN_LAUNDER: if (vec->length () == 1) @@ -6643,14 +6654,20 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, 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); + postfix_expression + = 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; + postfix_expression + = 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%>"); + postfix_expression = error_mark_node; + } + break; default: gcc_unreachable (); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 58d5ce2..0d1a013 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-10-31 Jakub Jelinek <jakub@redhat.com> + + PR c++/78089 + * c-c++-common/builtin-shuffle-1.c: New test. + * g++.dg/cpp0x/addressof3.C: New test. + 2016-10-31 Ville Voutilainen <ville.voutilainen@gmail.com> Add tests for a const member and a reference member for launder. diff --git a/gcc/testsuite/c-c++-common/builtin-shuffle-1.c b/gcc/testsuite/c-c++-common/builtin-shuffle-1.c new file mode 100644 index 0000000..30fd690 --- /dev/null +++ b/gcc/testsuite/c-c++-common/builtin-shuffle-1.c @@ -0,0 +1,22 @@ +/* PR c++/78089 */ +/* { dg-do run } */ + +typedef int V __attribute__((vector_size (16))); +V a, b, c; + +int +foo () +{ + return __builtin_shuffle (a, b, c)[3]; +} + +int +main () +{ + a = (V) { 1, 2, 3, 4 }; + b = (V) { 5, 6, 7, 8 }; + c = (V) { 7, 2, 5, 6 }; + if (foo () != 7) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/addressof3.C b/gcc/testsuite/g++.dg/cpp0x/addressof3.C new file mode 100644 index 0000000..fa51790 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/addressof3.C @@ -0,0 +1,9 @@ +// { dg-do compile } + +struct S { int foo (); int s; }; +int a[10]; +int b; +S c; +int d = __builtin_addressof (a)[0][0]; +int e = __builtin_addressof (b)[0]; +int f = __builtin_addressof (c)->foo (); |