PR c++/70209
authormpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 15 Mar 2016 21:10:11 +0000 (21:10 +0000)
committermpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 15 Mar 2016 21:10:11 +0000 (21:10 +0000)
* tree.c (strip_typedefs): Call strip_typedefs again on the
DECL_ORIGINAL_TYPE result.

* g++.dg/ext/attribute-may-alias-4.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234234 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/attribute-may-alias-4.C [new file with mode: 0644]

index eff989b..4499284 100644 (file)
@@ -1,3 +1,9 @@
+2016-03-15  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/70209
+       * tree.c (strip_typedefs): Call strip_typedefs again on the
+       DECL_ORIGINAL_TYPE result.
+
 2016-03-15  Jason Merrill  <jason@redhat.com>
 
        PR c++/70095
index aaf9a4f..f784952 100644 (file)
@@ -1460,9 +1460,12 @@ strip_typedefs (tree t, bool *remove_attributes)
   if (!result)
     {
       if (typedef_variant_p (t))
-       /* Explicitly get the underlying type, as TYPE_MAIN_VARIANT doesn't
-          strip typedefs with attributes.  */
-       result = TYPE_MAIN_VARIANT (DECL_ORIGINAL_TYPE (TYPE_NAME (t)));
+       {
+         /* Explicitly get the underlying type, as TYPE_MAIN_VARIANT doesn't
+            strip typedefs with attributes.  */
+         result = TYPE_MAIN_VARIANT (DECL_ORIGINAL_TYPE (TYPE_NAME (t)));
+         result = strip_typedefs (result);
+       }
       else
        result = TYPE_MAIN_VARIANT (t);
     }
index 2a76ef0..3eb5710 100644 (file)
@@ -1,3 +1,8 @@
+2016-03-15  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/70209
+       * g++.dg/ext/attribute-may-alias-4.C: New test.
+
 2016-03-15  Alexander Monakov  <amonakov@ispras.ru>
 
        * g++.dg/pr63384.C: Add -w to dg-options.  Remove '-toggle' in
diff --git a/gcc/testsuite/g++.dg/ext/attribute-may-alias-4.C b/gcc/testsuite/g++.dg/ext/attribute-may-alias-4.C
new file mode 100644 (file)
index 0000000..a459d49
--- /dev/null
@@ -0,0 +1,17 @@
+// PR c++/70209
+
+struct V {
+  typedef float F;
+  template <typename S> void m_fn1(S);
+};
+
+template <typename> struct A {
+  typedef V::F Ta __attribute__((__may_alias__));
+  Ta *m_data;
+  void m_fn2(V &);
+};
+
+template <>
+void A<int>::m_fn2(V &p) {
+  p.m_fn1(m_data);
+}