From: Eric Botcazou Date: Mon, 9 Nov 2015 22:40:44 +0000 (+0000) Subject: re PR middle-end/68259 ([sso] tree checking failure in reverse_storage_order_for_comp... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a91c72e2141bbad97e7017a467d80ae0cdcd8eaf;p=gcc.git re PR middle-end/68259 ([sso] tree checking failure in reverse_storage_order_for_component_p, at tree.h:4392) PR middle-end/68259 * tree.h (reverse_storage_order_for_component_p) : Check that the type of the first operand is an aggregate type. From-SVN: r230056 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1f513ecdab6..3c764de4a89 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-11-09 Eric Botcazou + + PR middle-end/68259 + * tree.h (reverse_storage_order_for_component_p) : + Check that the type of the first operand is an aggregate type. + 2015-11-09 Nathan Sidwell * omp-low.c: Fix some OpenACC comment typos. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 37ce460ebcd..d5942e49f96 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-11-09 Eric Botcazou + + * g++.dg/ubsan/pr68259.C: New test. + 2015-11-09 Uros Bizjak * g++.dg/cilk-plus/CK/pr66326.cc: Do not include cilk.h. diff --git a/gcc/testsuite/g++.dg/ubsan/pr68259.C b/gcc/testsuite/g++.dg/ubsan/pr68259.C new file mode 100644 index 00000000000..5137edd1f8b --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr68259.C @@ -0,0 +1,54 @@ +// PR middle-end/68259 + +// { dg-do compile } +// { dg-options "-fsanitize=undefined -w" } + +namespace std { + template < typename _Tp > class allocator { }; + template < typename _Tp, typename _Alloc += std::allocator < _Tp > +>class vector { + public: +typedef _Tp value_type; + void push_back (const value_type & __x) { } + }; +} +class Foo; +class FooBar { +public: +Foo * primitive_context; + FooBar () { } + FooBar (const FooBar & pnhp); +}; +template < class KEY, class CONTENT > class AVLTreeNode { }; +template < class KEY, class CONTENT > class FooTree final +{ + FooBar insertPrimitive (); +public: +AVLTreeNode < KEY, CONTENT > *seek_no_lock (const KEY & key) { } + void primitive_patterns ( std::vector < FooBar > &patterns); +}; +template < class KEY, class CONTENT > void FooTree < KEY, + CONTENT >::primitive_patterns ( std::vector &patterns) +{ + patterns.push_back (insertPrimitive()); +} +template < class KEY, class CONTENT > +FooBar FooTree < KEY, CONTENT >::insertPrimitive () +{ + FooBar place; + seek_no_lock (place.primitive_context); + return place; +} +class ManuverResults { }; +class opc_info_t +{ +public: +FooTree < Foo *, ManuverResults > *primitivecache; +}; +static void +do_optical_prox_corr_tsafe (opc_info_t * opc_info) +{ + std::vector < FooBar > patterns; + opc_info->primitivecache->primitive_patterns (patterns); +} diff --git a/gcc/tree.h b/gcc/tree.h index 2a5ccfc6802..1bb59f2ac8c 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4387,8 +4387,9 @@ reverse_storage_order_for_component_p (tree t) { case ARRAY_REF: case COMPONENT_REF: - /* ??? Fortran can take COMPONENT_REF of a void type. */ - return !VOID_TYPE_P (TREE_TYPE (TREE_OPERAND (t, 0))) + /* ??? Fortran can take COMPONENT_REF of a VOID_TYPE. */ + /* ??? UBSan can take COMPONENT_REF of a REFERENCE_TYPE. */ + return AGGREGATE_TYPE_P (TREE_TYPE (TREE_OPERAND (t, 0))) && TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (TREE_OPERAND (t, 0))); case BIT_FIELD_REF: