From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 393CF388F062; Tue, 5 May 2020 13:34:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 393CF388F062 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1588685644; bh=/F1VsD06KoJTt+nnGndynJjumSup8OCKAvmDoWnmeCI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dViVEFl31kGFkbqUD8vNrV6g+kbLtGfUwZ8nC3Q3uCBnb+zHh7SZ4cGto2uj/k/Et ixrEJb6O2uKxV/4b2TO7shcepfxogSihKSRfOJhIgDJ8tvOhOxQahZAJ6o1xFUEXue 3gmr5gEH4M6A/5DKgWfPEpns6YrJsCXPUlRAMhBo= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug bootstrap/91972] Bootstrap should use -Wmissing-declarations Date: Tue, 05 May 2020 13:34:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: bootstrap X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 May 2020 13:34:04 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D91972 --- Comment #3 from Richard Biener --- (In reply to Jonathan Wakely from comment #2) > (In reply to Alexander Monakov from comment #0) > > Transition to C++ did not change -Wmissing-prototypes to > > -Wmissing-declarations, so over time several violations crept in. In > > particular this penalizes optimization during non-LTO bootstrap (the > > compiler has to assume the function might be used in another TU, even t= hough > > in reality all uses are in current file and it simply misses the 'stati= c' > > keyword). >=20 > Why is it missing the static keyword then? (Or alternatively, why isn't it > in an anonymous namespace?) >=20 >=20 > (In reply to Alexander Monakov from comment #1) > > Another reason to have -Wmissing-declarations is that otherwise mismatc= hes > > of unused functions are not caught until it's too late (mismatching > > definition is assumed to be an overload of the function declared in the > > header file). >=20 > A more robust way to avoid that problem is to declare the function in a > namespace, and define it using a qualified name: >=20 > // declaration > namespace targ > { > void foo(void*); > } >=20 > // definition > void targ::foo(class vec_info*); // ERROR >=20 > Because no foo with that signature was declared in namespace targ it's an > error, not just a warning. >=20 > Should the coding convention be adjusted to avoid this problem? Ah, I like the namespace thing for target hooks (possibly langhooks as well= ).=