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> ());
--- /dev/null
+#include "analyzer-decls.h"
+
+/* According to PR 107807 comment #2, Solaris implements "errno"
+ like this: */
+
+extern int *___errno(void) __attribute__((__const__));
+#define errno (*(___errno()))
+
+
+extern void external_fn (void);
+
+int test_reading_errno (void)
+{
+ return errno;
+}
+
+void test_setting_errno (int val)
+{
+ errno = val;
+}
+
+void test_storing_to_errno (int val)
+{
+ __analyzer_eval (errno == val); /* { dg-warning "UNKNOWN" } */
+ errno = val;
+ __analyzer_eval (errno == val); /* { dg-warning "TRUE" } */
+ external_fn ();
+ __analyzer_eval (errno == val); /* { dg-warning "UNKNOWN" } */
+}
--- /dev/null
+#include "analyzer-decls.h"
+
+/* According to PR 107807 comment #2, OS X implements "errno"
+ like this: */
+
+extern int * __error(void);
+#define errno (*__error())
+
+extern void external_fn (void);
+
+int test_reading_errno (void)
+{
+ return errno;
+}
+
+void test_setting_errno (int val)
+{
+ errno = val;
+}
+
+void test_storing_to_errno (int val)
+{
+ __analyzer_eval (errno == val); /* { dg-warning "UNKNOWN" } */
+ errno = val;
+ __analyzer_eval (errno == val); /* { dg-warning "TRUE" } */
+ external_fn ();
+ __analyzer_eval (errno == val); /* { dg-warning "UNKNOWN" } */
+}
--- /dev/null
+#include "analyzer-decls.h"
+
+/* "errno" declared as a global var. */
+
+extern int errno;
+
+extern void external_fn (void);
+
+int test_reading_errno (void)
+{
+ return errno;
+}
+
+void test_setting_errno (int val)
+{
+ errno = val;
+}
+
+void test_storing_to_errno (int val)
+{
+ __analyzer_eval (errno == val); /* { dg-warning "UNKNOWN" } */
+ errno = val;
+ __analyzer_eval (errno == val); /* { dg-warning "TRUE" } */
+ external_fn ();
+ __analyzer_eval (errno == val); /* { dg-warning "UNKNOWN" } */
+}