aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2009-11-01 01:07:00 -0400
committerJason Merrill <jason@gcc.gnu.org>2009-11-01 01:07:00 -0400
commit164247b0e22af8e62b10596e74fe1778e46e18d0 (patch)
tree26911dba08cb0a7db0e486c6601e5761fb0de7d0
parentc86f25e8ea6708147f15f4e80fca192ff2e81c19 (diff)
downloadgcc-164247b0e22af8e62b10596e74fe1778e46e18d0.zip
gcc-164247b0e22af8e62b10596e74fe1778e46e18d0.tar.gz
gcc-164247b0e22af8e62b10596e74fe1778e46e18d0.tar.bz2
tree.c (cv_unqualified): New fn.
* tree.c (cv_unqualified): New fn. * cp-tree.h: Declare it. * typeck.c (decay_conversion): Use it instead of TYPE_MAIN_VARIANT. From-SVN: r153790
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/tree.c10
-rw-r--r--gcc/cp/typeck.c2
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/restrict1.C20
6 files changed, 40 insertions, 1 deletions
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 <jason@redhat.com>
+ * 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 <jason@redhat.com>
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 <rguenther@suse.de>
+
+ * g++.dg/tree-ssa/restrict1.C: New.
+
2009-10-31 Jason Merrill <jason@redhat.com>
* 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" } } */