]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/45267 (inlining fails with -m32)
authorJason Merrill <jason@redhat.com>
Wed, 20 Apr 2011 00:06:19 +0000 (20:06 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 20 Apr 2011 00:06:19 +0000 (20:06 -0400)
PR c++/45267
* decl.c (duplicate_decls): Keep always_inline attribute
in sync with DECL_DISREGARD_INLINE_LIMITS.

From-SVN: r172745

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/attrib41.C [new file with mode: 0644]

index 2a4dbb826c6399923b9412cc8790fb79cdbdd5e9..d7cd00707ad0e91678aef720375383ed6b41aaba 100644 (file)
@@ -1,3 +1,9 @@
+2011-04-19  Jason Merrill  <jason@redhat.com>
+
+       PR c++/45267
+       * decl.c (duplicate_decls): Keep always_inline attribute
+       in sync with DECL_DISREGARD_INLINE_LIMITS.
+
 2011-04-18  Richard Guenther  <rguenther@suse.de>
 
        Backported from 4.6 branch 
index b347c93423fbdc97e96f5279683bf8b8efd40ca4..d2e3d29615f1a53d8a0bd3e97bdd4e8b60b2b78d 100644 (file)
@@ -1975,6 +1975,19 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
 
          /* [temp.expl.spec/14] We don't inline explicit specialization
             just because the primary template says so.  */
+
+         /* But still keep DECL_DISREGARD_INLINE_LIMITS in sync with
+            the always_inline attribute.  */
+         if (DECL_DISREGARD_INLINE_LIMITS (olddecl)
+             && !DECL_DISREGARD_INLINE_LIMITS (newdecl))
+           {
+             if (DECL_DECLARED_INLINE_P (newdecl))
+               DECL_DISREGARD_INLINE_LIMITS (newdecl) = true;
+             else
+               DECL_ATTRIBUTES (newdecl)
+                 = remove_attribute ("always_inline",
+                                     DECL_ATTRIBUTES (newdecl));
+           }
        }
       else if (new_defines_function && DECL_INITIAL (olddecl))
        {
index 97b381221edafac5b7c6123e7e8395d5d9c55813..7ac925410bfcfc6e31ed9413e80f39ca38a6eecb 100644 (file)
@@ -1,3 +1,7 @@
+2011-04-19  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/ext/attrib41.C: New.
+
 2011-04-18  Richard Guenther  <rguenther@suse.de>
 
        Backported from 4.6 branch
diff --git a/gcc/testsuite/g++.dg/ext/attrib41.C b/gcc/testsuite/g++.dg/ext/attrib41.C
new file mode 100644 (file)
index 0000000..368554a
--- /dev/null
@@ -0,0 +1,19 @@
+// PR c++/45267
+// { dg-options "-O" }
+
+template<typename T> struct Vector {
+  Vector(long long x);
+  inline Vector<T> operator<<(int x) const __attribute__((always_inline));
+};
+long long bar (long long);
+template<> inline Vector<int> Vector<int>::operator<<(int x) const {
+  return bar(x);
+}
+bool b;
+int main() {
+  Vector<int> a(1);
+  if ((a << 2), b) {
+    a << 2;
+    throw 1;
+  }
+}