From 2cb0e5d93bd600a6ed3781755c8080f8ae2db74c Mon Sep 17 00:00:00 2001 From: jakub Date: Tue, 22 Jan 2008 17:03:12 +0000 Subject: [PATCH] PR c++/34914 * c-common.c (handle_vector_size_attribute): Only allow integral, scalar float and fixed point types. Handle OFFSET_TYPE the same way as pointer, array etc. types. * tree.c (reconstruct_complex_type): Handle OFFSET_TYPE. * g++.dg/ext/vector10.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@131729 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/c-common.c | 9 +++++---- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/ext/vector10.C | 11 +++++++++++ gcc/tree.c | 5 +++++ 5 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/vector10.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a720103..a428833 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2008-01-22 Jakub Jelinek + PR c++/34914 + * c-common.c (handle_vector_size_attribute): Only allow + integral, scalar float and fixed point types. Handle OFFSET_TYPE + the same way as pointer, array etc. types. + * tree.c (reconstruct_complex_type): Handle OFFSET_TYPE. + PR c++/34917 * tree.c (build_type_attribute_qual_variant): Call build_qualified_type if attributes are equal, but quals are not. diff --git a/gcc/c-common.c b/gcc/c-common.c index 4e5d24c..1ba5c78 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -6031,15 +6031,16 @@ handle_vector_size_attribute (tree *node, tree name, tree args, while (POINTER_TYPE_P (type) || TREE_CODE (type) == FUNCTION_TYPE || TREE_CODE (type) == METHOD_TYPE - || TREE_CODE (type) == ARRAY_TYPE) + || TREE_CODE (type) == ARRAY_TYPE + || TREE_CODE (type) == OFFSET_TYPE) type = TREE_TYPE (type); /* Get the mode of the type being modified. */ orig_mode = TYPE_MODE (type); - if (TREE_CODE (type) == RECORD_TYPE - || TREE_CODE (type) == UNION_TYPE - || TREE_CODE (type) == VECTOR_TYPE + if ((!INTEGRAL_TYPE_P (type) + && !SCALAR_FLOAT_TYPE_P (type) + && !FIXED_POINT_TYPE_P (type)) || (!SCALAR_FLOAT_MODE_P (orig_mode) && GET_MODE_CLASS (orig_mode) != MODE_INT && !ALL_SCALAR_FIXED_POINT_MODE_P (orig_mode)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7447d47..aae550a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2008-01-22 Jakub Jelinek + PR c++/34914 + * g++.dg/ext/vector10.C: New test. + PR c++/34918 * g++.dg/other/error23.C: New test. diff --git a/gcc/testsuite/g++.dg/ext/vector10.C b/gcc/testsuite/g++.dg/ext/vector10.C new file mode 100644 index 0000000..46ea244 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/vector10.C @@ -0,0 +1,11 @@ +// PR c++/34914 +// { dg-do compile } + +struct A { int __attribute ((vector_size (8))) x; }; + +void +foo () +{ + __attribute ((vector_size (8))) int A::*p; + p == 0; +} diff --git a/gcc/tree.c b/gcc/tree.c index b6b3eef..f61e24b 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -7631,6 +7631,11 @@ reconstruct_complex_type (tree type, tree bottom) inner, TREE_CHAIN (TYPE_ARG_TYPES (type))); } + else if (TREE_CODE (type) == OFFSET_TYPE) + { + inner = reconstruct_complex_type (TREE_TYPE (type), bottom); + outer = build_offset_type (TYPE_OFFSET_BASETYPE (type), inner); + } else return bottom; -- 2.7.4