aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/analyzer')
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/errno-1.c23
-rw-r--r--gcc/testsuite/gcc.dg/analyzer/strchr-1.c3
2 files changed, 25 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/analyzer/errno-1.c b/gcc/testsuite/gcc.dg/analyzer/errno-1.c
new file mode 100644
index 0000000..6b9d28c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/errno-1.c
@@ -0,0 +1,23 @@
+#include <errno.h>
+#include "analyzer-decls.h"
+
+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" } */
+}
diff --git a/gcc/testsuite/gcc.dg/analyzer/strchr-1.c b/gcc/testsuite/gcc.dg/analyzer/strchr-1.c
index dfe1bc9..bfa4891 100644
--- a/gcc/testsuite/gcc.dg/analyzer/strchr-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/strchr-1.c
@@ -3,12 +3,13 @@
const char* test_literal (int x)
{
- char *p = __builtin_strchr ("123", x);
+ char *p = __builtin_strchr ("123", x); /* { dg-message "when '__builtin_strchr' returns non-NULL" } */
if (p)
{
__analyzer_eval (*p == x); /* { dg-message "UNKNOWN" } */
/* TODO: this ought to be TRUE, but it's unclear that it's
worth stashing this constraint. */
+ *p = 'A'; /* { dg-warning "write to string literal" } */
}
return p;
}