+2018-02-28 Martin Sebor <msebor@redhat.com>
+
+ PR testsuite/84617
+ * decl.c (duplicate_decls): Fully merge attributes const, pure,
+ and malloc.
+
2018-02-28 Nathan Sidwell <nathan@acm.org>
PR c++/84602
TREE_NOTHROW (newdecl) |= TREE_NOTHROW (olddecl);
TREE_NOTHROW (olddecl) |= TREE_NOTHROW (newdecl);
TREE_READONLY (newdecl) |= TREE_READONLY (olddecl);
+ TREE_READONLY (olddecl) |= TREE_READONLY (newdecl);
DECL_IS_MALLOC (newdecl) |= DECL_IS_MALLOC (olddecl);
+ DECL_IS_MALLOC (olddecl) |= DECL_IS_MALLOC (newdecl);
DECL_PURE_P (newdecl) |= DECL_PURE_P (olddecl);
+ DECL_PURE_P (olddecl) |= DECL_PURE_P (newdecl);
}
else
{
+2018-02-28 Martin Sebor <msebor@redhat.com>
+
+ PR testsuite/84617
+ * g++.dg/ext/attr-malloc-3.C: New test.
+ * g++.dg/ext/attr-const.C: Adjust. Xfail assertions failing due
+ to pre-existing problems.
+ * g++.dg/ext/attr-pure.C: Same.
+
2018-02-28 Paul Thomas <pault@gcc.gnu.org>
PR fortran/83901
/* PR c++/83871 - wrong code for attribute const and pure on distinct
template specializations
{ dg-do compile }
- { dg-options "-O -Wall" } */
+ { dg-options "-O1 -Wall -fdump-tree-optimized" } */
int __attribute__ ((const)) fconst_none ();
int fconst_none ();
-void test_const_none_failed ();
+void func_const_none_failed ();
void func_const_none ()
{
int i0 = fconst_none ();
int i1 = fconst_none ();
if (i0 != i1)
- test_const_none_failed ();
+ func_const_none_failed ();
- // { dg-final { scan-tree-dump-not "test_const_none_failed" "optimized" } }
+ // { dg-final { scan-tree-dump-not "func_const_none_failed" "optimized" } }
}
int fnone_const ();
int __attribute__ ((const)) fnone_const ();
-void test_none_const_failed ();
+void func_none_const_failed ();
void func_none_const ()
{
int i0 = fnone_const ();
int i1 = fnone_const ();
if (i0 != i1)
- test_none_const_failed ();
+ func_none_const_failed ();
- // { dg-final { scan-tree-dump-not "test_none_const_failed" "optimized" } }
+ // { dg-final { scan-tree-dump-not "func_none_const_failed" "optimized" } }
}
-
template <class T>
int __attribute__ ((const)) fconst_none (T);
template <class T>
int fconst_none (T);
+void templ_const_none_failed ();
+
void template_const_none ()
{
int i0 = fconst_none<int> (0);
int i1 = fconst_none<int> (0);
if (i0 != i1)
- test_const_none_failed ();
+ templ_const_none_failed ();
- // { dg-final { scan-tree-dump-not "test_const_none_failed" "optimized" } }
+ // { dg-final { scan-tree-dump-not "templ_const_none_failed" "optimized" } }
}
template <class T>
int __attribute__ ((const)) fnone_const (T);
+void templ_none_const_failed ();
+
void test_fnone_const ()
{
int i0 = fnone_const<int> (0);
int i1 = fnone_const<int> (0);
if (i0 != i1)
- test_none_const_failed ();
+ templ_none_const_failed ();
- // { dg-final { scan-tree-dump-not "test_none_const_failed" "optimized" } }
+ // The following fails (most likely) due to bug 84294.
+ // { dg-final { scan-tree-dump-not "templ_none_const_failed" "optimized" { xfail *-*-* } } }
}
--- /dev/null
+// Bug c++/84617 - new test cases g++.dg/ext/attr-const.C and
+// g++.dg/ext/attr-pure.C fail
+// { dg-do compile }
+// { dg-options "-O -Wall -fdump-tree-optimized" }
+
+static char a[8];
+
+void* __attribute__ ((malloc))
+func_malloc_none (unsigned);
+
+void*
+func_alloc_none (unsigned); // redeclare with no attribute
+
+void func_malloc_none_failed ();
+
+void test_func_malloc_none (void)
+{
+ void *p = func_malloc_none (1);
+ if (!p)
+ return;
+
+ if (p == a) // must be false
+ func_malloc_none_failed (); // should be eliminated
+
+ // Verify that the call to func_malloc_none_failed() is eliminated.
+ // { dg-final { scan-tree-dump-not "func_malloc_none_failed" "optimized" } }
+}
+
+
+void*
+func_none_malloc (unsigned);
+
+void* __attribute__ ((malloc))
+func_none_malloc (unsigned); // redeclare with an attribute
+
+void func_none_malloc_failed ();
+
+void test_func_none_malloc (void)
+{
+ void *p = func_none_malloc (1);
+ if (!p)
+ return;
+
+ if (p == a) // must be false
+ func_none_malloc_failed (); // should be eliminated
+
+ // Verify that the call to func_none_malloc_failed() is eliminated.
+ // { dg-final { scan-tree-dump-not "func_none_malloc_failed" "optimized" } }
+}
+
+
+template <class>
+void* __attribute__ ((malloc))
+templ_malloc_none (unsigned);
+
+template <class>
+void*
+templ_malloc_none (unsigned); // redeclare with no attribute
+
+void templ_malloc_none_failed ();
+
+void test_templ_malloc_none (void)
+{
+ void *p = templ_malloc_none<void>(1);
+ if (!p)
+ return;
+
+ if (p == a) // must be false
+ templ_malloc_none_failed (); // should be eliminated
+
+ // Verify that the call to templ_malloc_none_failed() is eliminated.
+ // { dg-final { scan-tree-dump-not "templ_malloc_none_failed" "optimized" } }
+}
+
+template <class>
+void*
+templ_none_malloc (unsigned);
+
+template <class>
+void* __attribute__ ((malloc))
+templ_none_malloc (unsigned); // redeclared with an attribute
+
+void templ_none_malloc_failed ();
+
+void test_templ_none_malloc (void)
+{
+ void *p = templ_none_malloc<void>(1);
+ if (!p)
+ return;
+
+ if (p == a) // must be false
+ templ_none_malloc_failed (); // should be eliminated
+
+ // The following fails (most likely) due to bug 84294.
+ // Verify that the call to templ_none_malloc_failed() is eliminated.
+ // { dg-final { scan-tree-dump-not "templ_none_malloc_failed" "optimized" { xfail *-*-* } } }
+}
/* PR c++/83871 - wrong code for attribute const and pure on distinct
template specializations
{ dg-do compile }
- { dg-options "-O -Wall" } */
+ { dg-options "-O -Wall -fdump-tree-optimized" } */
int __attribute__ ((pure)) fpure_none ();
int fpure_none ();
-void test_pure_none_failed ();
+void func_pure_none_failed ();
void func_pure_none ()
{
int i0 = fpure_none ();
int i1 = fpure_none ();
if (i0 != i1)
- test_pure_none_failed ();
+ func_pure_none_failed ();
- // { dg-final { scan-tree-dump-not "test_pure_none_failed" "optimized" } }
+ // { dg-final { scan-tree-dump-not "func_pure_none_failed" "optimized" } }
}
int fnone_pure ();
int __attribute__ ((pure)) fnone_pure ();
-void test_none_pure_failed ();
+void func_none_pure_failed ();
void func_none_pure ()
{
int i0 = fnone_pure ();
int i1 = fnone_pure ();
if (i0 != i1)
- test_none_pure_failed ();
+ func_none_pure_failed ();
- // { dg-final { scan-tree-dump-not "test_none_pure_failed" "optimized" } }
+ // { dg-final { scan-tree-dump-not "func_none_pure_failed" "optimized" } }
}
template <class T>
int fpure_none (T);
+void templ_pure_none_failed ();
+
void template_pure_none ()
{
int i0 = fpure_none<int> (0);
int i1 = fpure_none<int> (0);
if (i0 != i1)
- test_pure_none_failed ();
+ templ_pure_none_failed ();
- // { dg-final { scan-tree-dump-not "test_pure_none_failed" "optimized" } }
+ // { dg-final { scan-tree-dump-not "templ_pure_none_failed" "optimized" } }
}
template <class T>
-int fnone_pure (T);
+int fnone_const (T);
template <class T>
-int __attribute__ ((pure)) fnone_pure (T);
+int __attribute__ ((const)) fnone_const (T);
+
+void templ_none_const_failed ();
-void test_fnone_pure ()
+void test_fnone_const ()
{
- int i0 = fnone_pure<int> (0);
- int i1 = fnone_pure<int> (0);
+ int i0 = fnone_const<int> (0);
+ int i1 = fnone_const<int> (0);
if (i0 != i1)
- test_none_pure_failed ();
+ templ_none_const_failed ();
- // { dg-final { scan-tree-dump-not "test_none_pure_failed" "optimized" } }
+ // The following fails (most likely) due to bug 84294.
+ // { dg-final { scan-tree-dump-not "templ_none_const_failed" "optimized" { xfail *-*-* } } }
}