From: jason Date: Sun, 1 Nov 2009 05:07:00 +0000 (+0000) Subject: * tree.c (cv_unqualified): New fn. X-Git-Tag: upstream/4.9.2~32827 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=749ecbf670139a223544beca3160e1ce86d8a440;p=platform%2Fupstream%2Flinaro-gcc.git * tree.c (cv_unqualified): New fn. * cp-tree.h: Declare it. * typeck.c (decay_conversion): Use it instead of TYPE_MAIN_VARIANT. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153790 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8ea0001..2182bb1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2009-10-31 Jason Merrill + * tree.c (cv_unqualified): New fn. + * cp-tree.h: Declare it. + * typeck.c (decay_conversion): Use it instead of TYPE_MAIN_VARIANT. + * rtti.c (tinfo_name): Fix lengths for private case. 2009-10-31 Jason Merrill diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 4ffd899..7965514 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5146,6 +5146,7 @@ extern tree move (tree); extern tree cp_build_qualified_type_real (tree, int, tsubst_flags_t); #define cp_build_qualified_type(TYPE, QUALS) \ cp_build_qualified_type_real ((TYPE), (QUALS), tf_warning_or_error) +extern tree cv_unqualified (tree); extern special_function_kind special_function_p (const_tree); extern int count_trees (tree); extern int char_type_p (tree); diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 99ce656..b79093a 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -946,6 +946,16 @@ cp_build_qualified_type_real (tree type, return result; } +/* Return TYPE with const and volatile removed. */ + +tree +cv_unqualified (tree type) +{ + int quals = TYPE_QUALS (type); + quals &= ~(TYPE_QUAL_CONST|TYPE_QUAL_VOLATILE); + return cp_build_qualified_type (type, quals); +} + /* Builds a qualified variant of T that is not a typedef variant. E.g. consider the following declarations: typedef const int ConstInt; diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 3392fac..25c257f 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1691,7 +1691,7 @@ decay_conversion (tree exp) Non-class rvalues always have cv-unqualified types. */ type = TREE_TYPE (exp); if (!CLASS_TYPE_P (type) && cp_type_quals (type)) - exp = build_nop (TYPE_MAIN_VARIANT (type), exp); + exp = build_nop (cv_unqualified (type), exp); return exp; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index aedb60b..6e3a9d8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2009-10-31 Richard Guenther + + * g++.dg/tree-ssa/restrict1.C: New. + 2009-10-31 Jason Merrill * g++.dg/rtti/typeid9.C: New. diff --git a/gcc/testsuite/g++.dg/tree-ssa/restrict1.C b/gcc/testsuite/g++.dg/tree-ssa/restrict1.C new file mode 100644 index 0000000..dc120b1 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/restrict1.C @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-lim-details" } */ + +struct Foo +{ + Foo(); + Foo(const Foo&); + int n; + int * __restrict__ p; +}; +void bar(Foo f, int * __restrict__ q) +{ + for (int i = 0; i < f.n; ++i) + { + *q += f.p[i]; + } +} + +/* { dg-final { scan-tree-dump "Executing store motion" "lim1" } } */ +/* { dg-final { cleanup-tree-dump "lim1" } } */