aboutsummaryrefslogtreecommitdiff
path: root/gcc/analyzer
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2022-11-22 17:29:21 -0500
committerDavid Malcolm <dmalcolm@redhat.com>2022-11-22 17:29:21 -0500
commit7c9717fcb5cf94ce1e7ef5c903058adf9980ff28 (patch)
tree9e72e9f6a5423412cd7714ee825fa2ad68c6fae1 /gcc/analyzer
parent6bd31b33daa3c7635d886ff2cebd915748db2084 (diff)
downloadgcc-7c9717fcb5cf94ce1e7ef5c903058adf9980ff28.zip
gcc-7c9717fcb5cf94ce1e7ef5c903058adf9980ff28.tar.gz
gcc-7c9717fcb5cf94ce1e7ef5c903058adf9980ff28.tar.bz2
analyzer: fix 'errno' on Solaris and OS X [PR107807]
gcc/analyzer/ChangeLog: PR analyzer/107807 * region-model-impl-calls.cc (register_known_functions): Register "___errno" and "__error" as synonyms for "__errno_location". gcc/testsuite/ChangeLog: PR analyzer/107807 * gcc.dg/analyzer/errno-___errno.c: New test. * gcc.dg/analyzer/errno-__error.c: New test. * gcc.dg/analyzer/errno-global-var.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/analyzer')
-rw-r--r--gcc/analyzer/region-model-impl-calls.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/analyzer/region-model-impl-calls.cc b/gcc/analyzer/region-model-impl-calls.cc
index 6962ffd..23a21d7 100644
--- a/gcc/analyzer/region-model-impl-calls.cc
+++ b/gcc/analyzer/region-model-impl-calls.cc
@@ -1953,6 +1953,20 @@ register_known_functions (known_function_manager &kfm)
kfm.add ("error_at_line", make_unique<kf_error> (5));
}
+ /* Other implementations of C standard library. */
+ {
+ /* According to PR 107807 comment #2, Solaris implements "errno"
+ like this:
+ extern int *___errno(void) __attribute__((__const__));
+ #define errno (*(___errno()))
+ and OS X like this:
+ extern int * __error(void);
+ #define errno (*__error())
+ Add these as synonyms for "__errno_location". */
+ kfm.add ("___errno", make_unique<kf_errno_location> ());
+ kfm.add ("__error", make_unique<kf_errno_location> ());
+ }
+
/* C++ support functions. */
{
kfm.add ("operator new", make_unique<kf_operator_new> ());