aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2013-06-27 23:29:22 +0200
committerMarc Glisse <glisse@gcc.gnu.org>2013-06-27 21:29:22 +0000
commitbedc293e87af0c0322a9dac004dc7b7c86a7579b (patch)
tree37a7ba1615b56c5f026c57c7156e10579e63abcb /gcc/c-family
parent4a197d64cbb29606c45e52b66dcab8ba287c9177 (diff)
downloadgcc-bedc293e87af0c0322a9dac004dc7b7c86a7579b.zip
gcc-bedc293e87af0c0322a9dac004dc7b7c86a7579b.tar.gz
gcc-bedc293e87af0c0322a9dac004dc7b7c86a7579b.tar.bz2
re PR c++/57509 (Segmentation fault when using __builtin_shuffle in templated class.)
2013-06-27 Marc Glisse <marc.glisse@inria.fr> PR c++/57509 gcc/c-family/ * c-common.h (c_build_vec_perm_expr): New complain argument. * c-common.c (c_build_vec_perm_expr): Likewise. Use save_expr also in C++. gcc/cp/ * typeck.c (cp_build_vec_perm_expr): New function. * cp-tree.h: Declare it. * parser.c (cp_parser_postfix_expression): Call it. * pt.c (tsubst_copy): Handle VEC_PERM_EXPR. (tsubst_copy_and_build): Likewise. gcc/testsuite/ * g++.dg/ext/pr57509.C: New file. From-SVN: r200495
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/ChangeLog7
-rw-r--r--gcc/c-family/c-common.c30
-rw-r--r--gcc/c-family/c-common.h2
3 files changed, 27 insertions, 12 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index bc73a80..c9a4f70 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,10 @@
+2013-06-27 Marc Glisse <marc.glisse@inria.fr>
+
+ PR c++/57509
+ * c-common.h (c_build_vec_perm_expr): New complain argument.
+ * c-common.c (c_build_vec_perm_expr): Likewise.
+ Use save_expr also in C++.
+
2013-06-22 Gabriel Dos Reis <gdr@integrable-solutions.net>
* c-common.c (c_common_nodes_and_builtins): Use cxx11 in lieu of cxx0x.
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 8b780c2..8f7f5e5 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -2260,7 +2260,8 @@ vector_types_convertible_p (const_tree t1, const_tree t2, bool emit_lax_note)
an implementation accident and this semantics is not guaranteed to
the user. */
tree
-c_build_vec_perm_expr (location_t loc, tree v0, tree v1, tree mask)
+c_build_vec_perm_expr (location_t loc, tree v0, tree v1, tree mask,
+ bool complain)
{
tree ret;
bool wrap = true;
@@ -2280,22 +2281,25 @@ c_build_vec_perm_expr (location_t loc, tree v0, tree v1, tree mask)
if (TREE_CODE (TREE_TYPE (mask)) != VECTOR_TYPE
|| TREE_CODE (TREE_TYPE (TREE_TYPE (mask))) != INTEGER_TYPE)
{
- error_at (loc, "__builtin_shuffle last argument must "
- "be an integer vector");
+ if (complain)
+ error_at (loc, "__builtin_shuffle last argument must "
+ "be an integer vector");
return error_mark_node;
}
if (TREE_CODE (TREE_TYPE (v0)) != VECTOR_TYPE
|| TREE_CODE (TREE_TYPE (v1)) != VECTOR_TYPE)
{
- error_at (loc, "__builtin_shuffle arguments must be vectors");
+ if (complain)
+ error_at (loc, "__builtin_shuffle arguments must be vectors");
return error_mark_node;
}
if (TYPE_MAIN_VARIANT (TREE_TYPE (v0)) != TYPE_MAIN_VARIANT (TREE_TYPE (v1)))
{
- error_at (loc, "__builtin_shuffle argument vectors must be of "
- "the same type");
+ if (complain)
+ error_at (loc, "__builtin_shuffle argument vectors must be of "
+ "the same type");
return error_mark_node;
}
@@ -2304,17 +2308,19 @@ c_build_vec_perm_expr (location_t loc, tree v0, tree v1, tree mask)
&& TYPE_VECTOR_SUBPARTS (TREE_TYPE (v1))
!= TYPE_VECTOR_SUBPARTS (TREE_TYPE (mask)))
{
- error_at (loc, "__builtin_shuffle number of elements of the "
- "argument vector(s) and the mask vector should "
- "be the same");
+ if (complain)
+ error_at (loc, "__builtin_shuffle number of elements of the "
+ "argument vector(s) and the mask vector should "
+ "be the same");
return error_mark_node;
}
if (GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE (v0))))
!= GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE (mask)))))
{
- error_at (loc, "__builtin_shuffle argument vector(s) inner type "
- "must have the same size as inner type of the mask");
+ if (complain)
+ error_at (loc, "__builtin_shuffle argument vector(s) inner type "
+ "must have the same size as inner type of the mask");
return error_mark_node;
}
@@ -2335,6 +2341,8 @@ c_build_vec_perm_expr (location_t loc, tree v0, tree v1, tree mask)
mask = c_fully_fold (mask, false, &maybe_const);
wrap &= maybe_const;
}
+ else if (two_arguments)
+ v1 = v0 = save_expr (v0);
ret = build3_loc (loc, VEC_PERM_EXPR, TREE_TYPE (v0), v0, v1, mask);
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 625c301..6dfcffd 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -911,7 +911,7 @@ extern bool lvalue_p (const_tree);
extern bool vector_targets_convertible_p (const_tree t1, const_tree t2);
extern bool vector_types_convertible_p (const_tree t1, const_tree t2, bool emit_lax_note);
-extern tree c_build_vec_perm_expr (location_t, tree, tree, tree);
+extern tree c_build_vec_perm_expr (location_t, tree, tree, tree, bool = true);
extern rtx c_expand_expr (tree, rtx, enum machine_mode, int, rtx *);