re PR c++/10047 (-fno-default-inline produces bogus warnings)
authorNathan Sidwell <nathan@codesourcery.com>
Fri, 28 Mar 2003 08:02:15 +0000 (08:02 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Fri, 28 Mar 2003 08:02:15 +0000 (08:02 +0000)
cp:
PR c++/10047
* decl2.c (finish_file): Don't warn about explicitly instantiated
inline decls.
testsuite:
PR c++/10047
* g++.dg/template/inline1.C: New test.

From-SVN: r64953

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/inline1.C [new file with mode: 0644]

index c74767904997b23ebde4eb0b0cb21c886e35e3cf..888d4dcc5128f06c95e30f1381f8321325494ce7 100644 (file)
@@ -1,3 +1,9 @@
+2003-03-28  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/10047
+       * decl2.c (finish_file): Don't warn about explicitly instantiated
+       inline decls.
+
 2003-03-27  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/10224
index 9f5e27eec903c09e7c13b2924c5a4579a2a7b1a0..77b9636a570bc361d01ad8aca62eeb770c69f6d2 100644 (file)
@@ -2814,7 +2814,11 @@ finish_file ()
       tree decl = VARRAY_TREE (deferred_fns, i);
 
       if (TREE_USED (decl) && DECL_DECLARED_INLINE_P (decl)
-         && !(TREE_ASM_WRITTEN (decl) || DECL_SAVED_TREE (decl)))
+         && !(TREE_ASM_WRITTEN (decl) || DECL_SAVED_TREE (decl)
+              /* An explicit instantiation can be used to specify
+                 that the body is in another unit. It will have
+                 already verified there was a definition.  */
+              || DECL_EXPLICIT_INSTANTIATION (decl)))
        {
          cp_warning_at ("inline function `%D' used but never defined", decl);
          /* This symbol is effectively an "extern" declaration now.
index 3794bdd2f6b34855dd37710c43f5371c65a6734b..ce854a354abdab590552774e0f0b25ca6a0e91e4 100644 (file)
@@ -1,3 +1,8 @@
+2003-03-28  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/10047
+       * g++.dg/template/inline1.C: New test.
+
 2003-03-28  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * gcc.dg/sparc-dwarf2.c: New test.
diff --git a/gcc/testsuite/g++.dg/template/inline1.C b/gcc/testsuite/g++.dg/template/inline1.C
new file mode 100644 (file)
index 0000000..c5e39bb
--- /dev/null
@@ -0,0 +1,20 @@
+// { dg-do compile }
+// { dg-options "-fno-default-inline -O0" }
+// { dg-final { scan-assembler-not _ZN1X3FooIiEEvT_: } }
+
+// Copyright (C) 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 27 Mar 2003 <nathan@codesourcery.com>
+
+// PR 10047. bogus warning.
+
+struct X 
+{
+  template <typename T> static void Foo (T)  {}
+};
+
+extern template void X::Foo<int> (int); // extern, so don't emit it
+
+int main () {
+  X::Foo (1);  // ok, we've seen the defn
+}
+