> From: David Malcolm <dmalc...@redhat.com> > Date: Tue, 28 Feb 2023 21:25:34 -0500
> On Wed, 2023-03-01 at 01:59 +0100, Hans-Peter Nilsson wrote: > > > From: David Malcolm <dmalc...@redhat.com> > > > Date: Tue, 28 Feb 2023 14:12:47 -0500 > > > > > On Tue, 2023-02-28 at 19:47 +0100, Hans-Peter Nilsson wrote: > > > > Ok to commit? > > > > -- >8 -- > > > > Investigating analyzer tesstsuite errors for cris-elf. The same > > > > are > > > > seen for pru-elf according to posts to gcc-testresults@. > > > > > > > > For glibc, errno is #defined as: > > > > extern int *__errno_location (void) __THROW __attribute_const__; > > > > # define errno (*__errno_location ()) > > > > while for newlib in its default configuration, it's: > > > > #define errno (*__errno()) > > > > extern int *__errno (void); > > > > > > We're already handling ___errno (three underscores) for Solaris as > > > of > > > 7c9717fcb5cf94ce1e7ef5c903058adf9980ff28; does it fix the issue if > > > you > > > add __errno (two underscores) to analyzer/kf.cc's > > > register_known_functions in an analogous way to that commit? (i.e. > > > wiring it up to kf_errno_location, "teaching" the analyzer that > > > that > > > function returns a pointer to the "errno region") > > > > But...there's already "support" for two underscores since > > the commit you quote, so I guess not. > > Is there? That commit adds support for: > __error > but not for: > __errno > unless there's something I'm missing. No, it's me. Apparently I can't spot the difference between error and errno. Sorry. It's nice to know that the const-attribute (to signal that the pointer points to a constant location) works automatically, i.e. the Solaris and glibc definitions should not (no longer?) be needed - unless there's other errno-analyzing magic elsewhere too. Either way, since there's specific support for this errno kind of thing, that certainly works for me. The patch gets smaller too. :) So, how's this instead, pending full testing (only analyzer.exp spot-tested)? -- >8 -- analyzer: Support errno for newlib Without this definition, the errno definition for newlib isn't recognized as such, and these tests fail for newlib targets: FAIL: gcc.dg/analyzer/call-summaries-errno.c (test for warnings, line 16) FAIL: gcc.dg/analyzer/call-summaries-errno.c (test for excess errors) FAIL: gcc.dg/analyzer/errno-1.c (test for warnings, line 20) FAIL: gcc.dg/analyzer/errno-1.c (test for excess errors) FAIL: gcc.dg/analyzer/isatty-1.c (test for warnings, line 31) FAIL: gcc.dg/analyzer/isatty-1.c (test for warnings, line 35) FAIL: gcc.dg/analyzer/isatty-1.c (test for warnings, line 46) FAIL: gcc.dg/analyzer/isatty-1.c (test for warnings, line 56) FAIL: gcc.dg/analyzer/isatty-1.c (test for excess errors) gcc/analyzer: * kf.cc (register_known_functions): Add __errno function for newlib. --- gcc/analyzer/kf.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/analyzer/kf.cc b/gcc/analyzer/kf.cc index 3a91b6bd6ebb..bfb9148f9ae7 100644 --- a/gcc/analyzer/kf.cc +++ b/gcc/analyzer/kf.cc @@ -1036,6 +1036,7 @@ register_known_functions (known_function_manager &kfm) Add these as synonyms for "__errno_location". */ kfm.add ("___errno", make_unique<kf_errno_location> ()); kfm.add ("__error", make_unique<kf_errno_location> ()); + kfm.add ("__errno", make_unique<kf_errno_location> ()); } /* Language-specific support functions. */ -- 2.30.2