]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/57175 (NRVO and alignment)
authorMarc Glisse <marc.glisse@inria.fr>
Mon, 20 May 2013 07:50:54 +0000 (09:50 +0200)
committerMarc Glisse <glisse@gcc.gnu.org>
Mon, 20 May 2013 07:50:54 +0000 (07:50 +0000)
2013-05-20  Marc Glisse  <marc.glisse@inria.fr>

PR c++/57175
gcc/cp/
* typeck.c (check_return_expr): Reverse the alignment comparison.

gcc/testsuite/
* g++.dg/pr57175.C: New testcase.

From-SVN: r199093

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/pr57175.C [new file with mode: 0644]

index 14093eb935f7efb97bcdb4af29555cfafb1ffa1e..73b8debbf047b7394b71042473972ee36997b1c3 100644 (file)
@@ -1,3 +1,8 @@
+2013-05-20  Marc Glisse  <marc.glisse@inria.fr>
+
+       PR c++/57175
+       * typeck.c (check_return_expr): Reverse the alignment comparison.
+
 2013-05-17  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/18126
index fb758474a45e6f392d2011d472cdbb4a8114eae7..a531d03028bca9eaaa12bf40bec5684031ea1538 100644 (file)
@@ -8369,7 +8369,7 @@ check_return_expr (tree retval, bool *no_warning)
      && DECL_CONTEXT (retval) == current_function_decl
      && ! TREE_STATIC (retval)
      && ! DECL_ANON_UNION_VAR_P (retval)
-     && (DECL_ALIGN (retval) >= DECL_ALIGN (result))
+     && (DECL_ALIGN (retval) <= DECL_ALIGN (result))
      /* The cv-unqualified type of the returned value must be the
         same as the cv-unqualified return type of the
         function.  */
index 6fd1b2ed3a680fd282371d4263fb270ce9a8ac8e..5a113d714296104da07e9fa4627c2b9a6df07c87 100644 (file)
@@ -1,3 +1,8 @@
+2013-05-20  Marc Glisse  <marc.glisse@inria.fr>
+
+       PR c++/57175
+       * g++.dg/pr57175.C: New testcase.
+
 2013-05-17   Easwaran Raman  <eraman@google.com>
 
        * gcc.dg/tree-ssa/reassoc-28.c: New testcase.
diff --git a/gcc/testsuite/g++.dg/pr57175.C b/gcc/testsuite/g++.dg/pr57175.C
new file mode 100644 (file)
index 0000000..f54162f
--- /dev/null
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-std=c++11" } */
+
+extern "C" void do_not_remove ();
+
+struct A
+{
+  A () { }
+  A (A const&) { do_not_remove (); }
+};
+
+A
+f ()
+{
+  alignas (2 * alignof (A)) A x;
+  return x;
+}
+
+/* { dg-final { scan-assembler "do_not_remove" } } */