[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Bug c++/13081] [3.3 regression] forward template declarations in <complex> let inlining fail



------- Additional Comments From doko at cs dot tu-berlin dot de  2003-12-29 17:00 -------
Subject: Re:  [3.3/3.4 regression] forward template declarations in <complex> let inlining fail

> Module name:	gcc
> Changes by:	mmitchel@gcc.gnu.org	2003-12-29 02:42:17
> 
> Modified files:
> 	gcc/cp         : ChangeLog decl.c 
> 	gcc/testsuite  : ChangeLog 
> Added files:
> 	gcc/testsuite/g++.dg/opt: inline6.C 
> 	gcc/testsuite/g++.dg/parse: error9.C 
> 
> Log message:
> 	PR c++/13081
> 	* decl.c (duplicate_decls): Preserve inline-ness when redeclaring
> 	a function template.
> 	
> 	PR c++/13081
> 	* g++.dg/opt/inline6.C: New test.

backported to the gcc-3_3-branch, no regressions on an i486-linux
bootstrap. Ok for the branch?

2003-12-28  Mark Mitchell  <mark@codesourcery.com>

	PR c++/13081
 	* decl.c (duplicate_decls): Preserve inline-ness when redeclaring
 	a function template.
 
 	PR c++/13081
 	* g++.dg/opt/inline6.C: New test.

--- gcc/testsuite/g++.dg/opt/inline6.C
+++ gcc/testsuite/g++.dg/opt/inline6.C	2003-12-29 09:12:36.000000000 +0000
@@ -0,0 +1,14 @@
+// PR c++/13081
+// { dg-options "-O2" }
+// { dg-final { scan-assembler-not "foo" } }
+
+template<typename T> T foo(T);
+ 
+template<typename T> inline T foo(T t)
+{
+  return t;
+}
+
+void bar (long& l) {
+  l = foo(l);
+}

--- gcc/cp/decl.c~	2003-12-29 10:18:13.000000000 +0100
+++ gcc/cp/decl.c	2003-12-29 10:25:57.000000000 +0100
@@ -3737,6 +3737,14 @@
 	    = DECL_SOURCE_LOCATION (newdecl);
 	}
 
+      if (DECL_FUNCTION_TEMPLATE_P (newdecl))
+	{
+	  DECL_INLINE (DECL_TEMPLATE_RESULT (olddecl)) 
+	    |= DECL_INLINE (DECL_TEMPLATE_RESULT (newdecl));
+	  DECL_DECLARED_INLINE_P (DECL_TEMPLATE_RESULT (olddecl))
+	    |= DECL_DECLARED_INLINE_P (DECL_TEMPLATE_RESULT (newdecl));
+	}
+
       return 1;
     }
 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13081

------- You are receiving this mail because: -------
You reported the bug, or are watching the reporter.



Reply to: