OSDN Git Service

* tree.c (cv_unqualified): New fn.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 1 Nov 2009 05:07:00 +0000 (05:07 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 1 Nov 2009 05:07:00 +0000 (05:07 +0000)
* 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

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/tree.c
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tree-ssa/restrict1.C [new file with mode: 0644]

index 8ea0001..2182bb1 100644 (file)
@@ -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>
index 4ffd899..7965514 100644 (file)
@@ -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);
index 99ce656..b79093a 100644 (file)
@@ -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;
index 3392fac..25c257f 100644 (file)
@@ -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;
 }
index aedb60b..6e3a9d8 100644 (file)
@@ -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 (file)
index 0000000..dc120b1
--- /dev/null
@@ -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" } } */