From: Jason Merrill Date: Wed, 20 Apr 2011 00:06:19 +0000 (-0400) Subject: re PR c++/45267 (inlining fails with -m32) X-Git-Tag: releases/gcc-4.5.3~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0aa0d88c52b4a1cb7c1862a87aac19e1f3040682;p=thirdparty%2Fgcc.git re PR c++/45267 (inlining fails with -m32) PR c++/45267 * decl.c (duplicate_decls): Keep always_inline attribute in sync with DECL_DISREGARD_INLINE_LIMITS. From-SVN: r172745 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2a4dbb826c63..d7cd00707ad0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-04-19 Jason Merrill + + PR c++/45267 + * decl.c (duplicate_decls): Keep always_inline attribute + in sync with DECL_DISREGARD_INLINE_LIMITS. + 2011-04-18 Richard Guenther Backported from 4.6 branch diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index b347c93423fb..d2e3d29615f1 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 97b381221eda..7ac925410bfc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-04-19 Jason Merrill + + * g++.dg/ext/attrib41.C: New. + 2011-04-18 Richard Guenther 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 index 000000000000..368554a1b1dd --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attrib41.C @@ -0,0 +1,19 @@ +// PR c++/45267 +// { dg-options "-O" } + +template struct Vector { + Vector(long long x); + inline Vector operator<<(int x) const __attribute__((always_inline)); +}; +long long bar (long long); +template<> inline Vector Vector::operator<<(int x) const { + return bar(x); +} +bool b; +int main() { + Vector a(1); + if ((a << 2), b) { + a << 2; + throw 1; + } +}