summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-07 06:17:47 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-07 06:17:47 +0000
commit7946223ee5f94d45b8c8f28fa653853a60f01f59 (patch)
treeb3954c1365c27900e303289a67fbfaf60e6de188
parentcc016fcbf41306d99127c397bc4703614940e341 (diff)
downloadppe42-gcc-7946223ee5f94d45b8c8f28fa653853a60f01f59.tar.gz
ppe42-gcc-7946223ee5f94d45b8c8f28fa653853a60f01f59.zip
PR c++/17256
* decl2.c (cp_finish_file): Fix conditions for undefined warning. Set TREE_NO_WARNING instead of TREE_PUBLIC. * pt.c (instantiate_pending_templates): Set DECL_INITIAL to avoid a warning on a function we didn't instantiate because of excessive recursion. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@106581 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog10
-rw-r--r--gcc/cp/decl2.c8
-rw-r--r--gcc/cp/pt.c11
-rw-r--r--gcc/testsuite/g++.dg/warn/undefined1.C7
4 files changed, 27 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 86b9decf5e2..3d2f36ec767 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,13 @@
+2005-11-06 Jason Merrill <jason@redhat.com>
+ James A. Morrison <phython@gcc.gnu.org>
+
+ PR c++/17256
+ * decl2.c (cp_finish_file): Fix conditions for undefined warning.
+ Set TREE_NO_WARNING instead of TREE_PUBLIC.
+ * pt.c (instantiate_pending_templates): Set DECL_INITIAL to avoid
+ a warning on a function we didn't instantiate because of excessive
+ recursion.
+
2005-11-06 Mark Mitchell <mark@codesourcery.com>
* class.c (record_subobject_offsets): Don't record offsets past
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 77ac5f7ae9e..dcf3217dfb3 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -3062,8 +3062,6 @@ cp_finish_file (void)
{
if (/* Check online inline functions that were actually used. */
TREE_USED (decl) && DECL_DECLARED_INLINE_P (decl)
- /* But not defined. */
- && DECL_REALLY_EXTERN (decl)
/* If the definition actually was available here, then the
fact that the function was not defined merely represents
that for some reason (use of a template repository,
@@ -3076,10 +3074,8 @@ cp_finish_file (void)
&& !DECL_EXPLICIT_INSTANTIATION (decl))
{
warning (0, "inline function %q+D used but never defined", decl);
- /* This symbol is effectively an "extern" declaration now.
- This is not strictly necessary, but removes a duplicate
- warning. */
- TREE_PUBLIC (decl) = 1;
+ /* Avoid a duplicate warning from check_global_declaration_1. */
+ TREE_NO_WARNING (decl) = 1;
}
}
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 0490fd18ba7..c2fc36f2dfd 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -11813,10 +11813,15 @@ instantiate_pending_templates (int retries)
to avoid infinite loop. */
if (pending_templates && retries >= max_tinst_depth)
{
+ tree decl = TREE_VALUE (pending_templates);
+
error ("template instantiation depth exceeds maximum of %d"
- " instantiating %q+D, possibly from virtual table generation"
- " (use -ftemplate-depth-NN to increase the maximum)",
- max_tinst_depth, TREE_VALUE (pending_templates));
+ " instantiating %q+D, possibly from virtual table generation"
+ " (use -ftemplate-depth-NN to increase the maximum)",
+ max_tinst_depth, decl);
+ if (TREE_CODE (decl) == FUNCTION_DECL)
+ /* Pretend that we defined it. */
+ DECL_INITIAL (decl) = error_mark_node;
return;
}
diff --git a/gcc/testsuite/g++.dg/warn/undefined1.C b/gcc/testsuite/g++.dg/warn/undefined1.C
new file mode 100644
index 00000000000..87fa3ec5a62
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/undefined1.C
@@ -0,0 +1,7 @@
+// PR 17256
+
+inline static void f1(void); // { dg-warning "used but never" }
+void g1(void) { if (0) { f1(); } }
+
+inline void f2(void); // { dg-warning "used but never" }
+void g2(void) { if (0) { f2(); } }
OpenPOWER on IntegriCloud