aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Pinski <andrew_pinski@playstation.sony.com>2008-02-22 21:21:11 +0000
committerAndrew Pinski <pinskia@gcc.gnu.org>2008-02-22 13:21:11 -0800
commit1eea53dfef7c181187c6d1c8556740ae9c407cc4 (patch)
tree2e28932094f40b110cf5d60e656e39a948ee722c
parent5114c2a3200bce2c19d95a26b02c7b0b37c7a137 (diff)
downloadgcc-1eea53dfef7c181187c6d1c8556740ae9c407cc4.zip
gcc-1eea53dfef7c181187c6d1c8556740ae9c407cc4.tar.gz
gcc-1eea53dfef7c181187c6d1c8556740ae9c407cc4.tar.bz2
re PR c++/34715 (always_inline with templates and not declared as always_inline but definition has it)
2008-02-22 Andrew Pinski <andrew_pinski@playstation.sony.com> PR C++/34715 * decl.c (duplicate_decls): Merge DECL_DISREGARD_INLINE_LIMITS for template decls' function decl. 2008-02-22 Andrew Pinski <andrew_pinski@playstation.sony.com> PR C++/34715 * g++.dg/ext/always_inline-1.C: New test. * g++.dg/ext/always_inline-2.C: New test. * g++.dg/ext/always_inline-3.C: New test. * g++.dg/ext/always_inline-4.C: New test. From-SVN: r132558
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c5
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/g++.dg/ext/always_inline-1.C26
-rw-r--r--gcc/testsuite/g++.dg/ext/always_inline-2.C26
-rw-r--r--gcc/testsuite/g++.dg/ext/always_inline-3.C26
-rw-r--r--gcc/testsuite/g++.dg/ext/always_inline-4.C20
7 files changed, 117 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 19c34ba..19709c1 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2008-02-22 Andrew Pinski <andrew_pinski@playstation.sony.com>
+
+ PR C++/34715
+ * decl.c (duplicate_decls): Merge DECL_DISREGARD_INLINE_LIMITS for
+ template decls' function decl.
+
2008-02-22 Paolo Carlini <pcarlini@suse.de>
PR c++/35282
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 7294930..82c55e0 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1675,6 +1675,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
= DECL_INTERFACE_KNOWN (new_result);
DECL_DECLARED_INLINE_P (old_result)
= DECL_DECLARED_INLINE_P (new_result);
+ DECL_DISREGARD_INLINE_LIMITS (old_result)
+ |= DECL_DISREGARD_INLINE_LIMITS (new_result);
+
}
else
{
@@ -1682,6 +1685,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
|= DECL_INLINE (new_result);
DECL_DECLARED_INLINE_P (old_result)
|= DECL_DECLARED_INLINE_P (new_result);
+ DECL_DISREGARD_INLINE_LIMITS (old_result)
+ |= DECL_DISREGARD_INLINE_LIMITS (new_result);
check_redeclaration_exception_specification (newdecl, olddecl);
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9842305..378f04b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2008-02-22 Andrew Pinski <andrew_pinski@playstation.sony.com>
+
+ PR C++/34715
+ * g++.dg/ext/always_inline-1.C: New test.
+ * g++.dg/ext/always_inline-2.C: New test.
+ * g++.dg/ext/always_inline-3.C: New test.
+ * g++.dg/ext/always_inline-4.C: New test.
+
2008-02-22 Hans-Peter Nilsson <hp@axis.com>
* gcc.target/cris/asm-b-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/ext/always_inline-1.C b/gcc/testsuite/g++.dg/ext/always_inline-1.C
new file mode 100644
index 0000000..284fd17
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/always_inline-1.C
@@ -0,0 +1,26 @@
+// { dg-options "-O0" }
+// { dg-do compile }
+// PR C++/34715
+
+
+namespace X
+{
+ template <class T>
+ const T& min(const T& a, const T& b);
+
+ template <class T>
+ inline __attribute__ ((always_inline)) const T& min(const T& a, const T& b)
+ {
+ return a < b ? a : b;
+ }
+}
+template <class T>
+inline __attribute__ ((always_inline)) T y(const T& a, const T& b)
+{
+ return X::min(a, b);
+}
+int main()
+{
+ int a = 0, b = 0;
+ return y(a, b);
+}
diff --git a/gcc/testsuite/g++.dg/ext/always_inline-2.C b/gcc/testsuite/g++.dg/ext/always_inline-2.C
new file mode 100644
index 0000000..31123c1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/always_inline-2.C
@@ -0,0 +1,26 @@
+// { dg-options "-O0" }
+// { dg-do compile }
+// PR C++/34715
+
+
+namespace X
+{
+ template <class T>
+ const T& min123(const T& a, const T& b);
+}
+
+
+template <class T>
+inline __attribute__ ((always_inline)) const T& X::min123(const T& a, const T& b)
+{
+ return a < b ? a : b;
+}
+int main()
+{
+ int a, b;
+ return X::min123(a, b);
+}
+
+
+
+// { dg-final { scan-assembler-not "min123" } }
diff --git a/gcc/testsuite/g++.dg/ext/always_inline-3.C b/gcc/testsuite/g++.dg/ext/always_inline-3.C
new file mode 100644
index 0000000..e008932
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/always_inline-3.C
@@ -0,0 +1,26 @@
+// { dg-options "-O0" }
+// { dg-do compile }
+// PR C++/34715
+
+
+namespace X
+{
+ template <class T>
+ inline __attribute__ ((always_inline)) const T& min123(const T& a, const T& b);
+}
+
+
+template <class T>
+inline __attribute__ ((always_inline)) const T& X::min123(const T& a, const T& b)
+{
+ return a < b ? a : b;
+}
+int main()
+{
+ int a, b;
+ return X::min123(a, b);
+}
+
+
+
+// { dg-final { scan-assembler-not "min123" } }
diff --git a/gcc/testsuite/g++.dg/ext/always_inline-4.C b/gcc/testsuite/g++.dg/ext/always_inline-4.C
new file mode 100644
index 0000000..e950761
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/always_inline-4.C
@@ -0,0 +1,20 @@
+// { dg-options "-O0" }
+// { dg-do compile }
+// PR C++/34715
+
+ template <class T>
+ const T& min123(const T& a, const T& b);
+template <class T>
+inline __attribute__ ((always_inline)) const T&
+min123(const T& a, const T& b)
+{
+ return a < b ? a : b;
+}
+int main()
+{
+ int a, b;
+ return min123(a, b);
+}
+
+
+// { dg-final { scan-assembler-not "min123" } }