Bug 20145 - [4.0/4.1 Regression] template "class has virtual functions ... " is not suppressed with -isystem
Summary: [4.0/4.1 Regression] template "class has virtual functions ... " is not suppr...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic, rejects-valid
Depends on:
Blocks:
 
Reported: 2005-02-22 15:59 UTC by Michael Cieslinski
Modified: 2005-04-08 19:41 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-02-23 12:30:26


Attachments
preprocessed source (98.60 KB, text/plain)
2005-02-23 11:16 UTC, Michael Cieslinski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Cieslinski 2005-02-22 15:59:06 UTC
When an include dir is given to gcc with the -isystem option the 
warning: 'class CppUnit::ConcretTestFixtureFactory<ErrorValueTest>' has virtual 
functions but non-virtual destructor is not suppressed as other warnings are.

This warning is new, with gcc34 or snapshot 20050116 this warning does not show 
up.

Michael Cieslinski
Comment 1 Andrew Pinski 2005-02-22 17:24:43 UTC
I cannot reproduce this with 4.0 (20050222).
tin:~/src/gnu/gcctest/pr20145>cat include/t.h
class t
{
  virtual void f();
};
tin:~/src/gnu/gcctest/pr20145>cat t.cc
#include <t.h>

class t1
{
  virtual void f();
};

void f(void)
{
  t h;
  t1 h1;
}

tin:~/src/gnu/gcctest/pr20145>gcc t.cc -isystem include/ -W -Wall -S
t.cc:4: warning: ‘class t1’ has virtual functions but non-virtual destructor

Comment 2 Andrew Pinski 2005-02-22 17:25:23 UTC
Oh, one more thing:
tin:~/src/gnu/gcctest/pr20145>gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /home/peshtigo/pinskia/src/gnu/gcc/src/configure --target=i686-pc-linux-gnu --
host=i686-pc-linux-gnu --enable-__cxa_atexit --enable-languages=c++,objc,java,f95 --prefix=/
home/gates/pinskia/linux --enable-threads=posix --enable-shared
Thread model: posix
gcc version 4.0.0 20050222 (experimental)
Comment 3 Andrew Pinski 2005-02-22 17:26:43 UTC
Can you include the preprocessed source (the preprocessed source will have the thing if a header is a 
system header or not)?
Comment 4 Michael Cieslinski 2005-02-23 11:16:31 UTC
Created attachment 8261 [details]
preprocessed source

Command line for gcc:
/usr/local/gcc40d/bin/g++40d -O2 -g -march=opteron
 -Wall -DALTIVEC -DUSEACE -c
 -o ../../../../LinuxExec/arrilib/ArriutilTest.o
 ../../../Portabel/arrilib/compile/ArriutilTest.cpp
 -I../../../Portabel/arrilib
 -isystem/home/cie019/ace542-gcc40/ACE_wrappers
 -DHAVE_ACE_NULL_MUTEX_H -isystem/usr/local/cppunit-gcc40/include
 -I../../../../include/arrilib

Output from gcc:
/usr/local/cppunit-gcc40/include/cppunit/extensions/TestFixtureFactory.h:
 In instantiation of 'CppUnit::ConcretTestFixtureFactory<ArriutilTest>':
../../../Portabel/arrilib/compile/ArriutilTest.h:32:   instantiated from here
/usr/local/cppunit-gcc40/include/cppunit/extensions/TestFixtureFactory.h:30:
warning: 'class CppUnit::ConcretTestFixtureFactory<ArriutilTest>' has virtual
functions but non-virtual destructor

This gcc was snapshot 20050213, but 20050220 makes no difference.

Michael Cieslinski
Comment 5 Andrew Pinski 2005-02-23 12:30:26 UTC
Ok, it is only a bug with templates.
And here is the shortest testcase:
# 1 "t.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "t.cc"
# 1 "include/t.h" 1 3 4
template <int> class t
{
  virtual void f();
};
# 2 "t.cc" 2

void f(void)
{
  t<1> h;
}
Comment 6 Andrew Pinski 2005-03-07 07:24:58 UTC
I think this caused by the patch which fixed PR 19733.
Comment 7 Mark Mitchell 2005-04-06 05:44:06 UTC
The fact that something is in a system header does not in general cause the
compiler not to warn about it.  G++ does not issue certain pedantic warnings
when in a system header, but this is not one of those.
Comment 8 Andrew Pinski 2005-04-06 06:48:52 UTC
(In reply to comment #7)
> The fact that something is in a system header does not in general cause the
> compiler not to warn about it.  G++ does not issue certain pedantic warnings
> when in a system header, but this is not one of those.

Why does the non-template version does not warn then?
Comment 9 Mark Mitchell 2005-04-07 22:57:48 UTC
Andrew is correct.  

I missed the magic bit that disables warnings in system headers.  (There are
other pedwarns that we carefully guard with !in_system_header, but ordinary
warnings are not so guarded.)

I've reopened the bug.
Comment 10 GCC Commits 2005-04-08 19:36:17 UTC
Subject: Bug 20145

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	mmitchel@gcc.gnu.org	2005-04-08 19:36:12

Modified files:
	gcc/cp         : ChangeLog cp-tree.def cp-tree.h tree.c pt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/warn: Wdtor1.C 

Log message:
	* cp-tree.def (TINST_LEVEL): Document TINST_IN_SYSTEM_HEADER_P.
	* cp-tree.h (struct tinst_level): Add in_system_header_p.
	(TINST_IN_SYSTEM_HEADER_P): New macro.
	(make_tinst_level): Remove.
	* pt.c (lookup_template_class): Preserve DECL_IN_SYSTEM_HEADER on
	the instantiated class.
	(push_tinst_level): Do not use make_tinst_level.  Set
	TINST_IN_SYSTEM_HEADER_P.
	(pop_tinst_level): Likewise.
	(instantiate_class_template): Set in_system_header.
	(instantiate_pending_templates): Likewise.
	* tree.c (make_tinst_level): Remove.
	
	PR c++/20145
	* g++.dg/warn/Wdtor1.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4648.2.29&r2=1.4648.2.30
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.def.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.94.4.1&r2=1.94.4.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1106.2.2&r2=1.1106.2.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/tree.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.427.2.1&r2=1.427.2.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.978.2.6&r2=1.978.2.7
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.117&r2=1.5084.2.118
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Wdtor1.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1

Comment 11 GCC Commits 2005-04-08 19:40:11 UTC
Subject: Bug 20145

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2005-04-08 19:39:59

Modified files:
	gcc/cp         : ChangeLog cp-tree.def cp-tree.h tree.c pt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/warn: Wdtor1.C 

Log message:
	* cp-tree.def (TINST_LEVEL): Document TINST_IN_SYSTEM_HEADER_P.
	* cp-tree.h (struct tinst_level): Add in_system_header_p.
	(TINST_IN_SYSTEM_HEADER_P): New macro.
	(make_tinst_level): Remove.
	* pt.c (lookup_template_class): Preserve DECL_IN_SYSTEM_HEADER on
	the instantiated class.
	(push_tinst_level): Do not use make_tinst_level.  Set
	TINST_IN_SYSTEM_HEADER_P.
	(pop_tinst_level): Likewise.
	(instantiate_class_template): Set in_system_header.
	(instantiate_pending_templates): Likewise.
	* tree.c (make_tinst_level): Remove.
	
	PR c++/20145
	* g++.dg/warn/Wdtor1.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4694&r2=1.4695
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.def.diff?cvsroot=gcc&r1=1.95&r2=1.96
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.1116&r2=1.1117
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/tree.c.diff?cvsroot=gcc&r1=1.430&r2=1.431
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.991&r2=1.992
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5304&r2=1.5305
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Wdtor1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2

Comment 12 Mark Mitchell 2005-04-08 19:41:35 UTC
Fixed in 4.0.