+2020-01-22 David Malcolm <dmalcolm@redhat.com>
+
+ PR analyzer/93316
+ * analyzer.cc (is_setjmp_call_p): Check for "setjmp" as well as
+ "_setjmp".
+
2020-01-22 David Malcolm <dmalcolm@redhat.com>
PR analyzer/93307
{
/* TODO: is there a less hacky way to check for "setjmp"? */
if (const gcall *call = dyn_cast <const gcall *> (stmt))
- if (is_special_named_call_p (call, "_setjmp", 1))
+ if (is_special_named_call_p (call, "setjmp", 1)
+ || is_special_named_call_p (call, "_setjmp", 1))
return true;
return false;
+2020-01-22 David Malcolm <dmalcolm@redhat.com>
+
+ PR analyzer/93316
+ * gcc.dg/analyzer/data-model-1.c: Include <alloca.h>.
+ * gcc.dg/analyzer/malloc-1.c: Likewise.
+ * gcc.dg/analyzer/malloc-callbacks.c (get_alloca): Return
+ __builtin_alloca rather than alloca.
+ * gcc.dg/analyzer/malloc-paths-8.c: Include <alloca.h>.
+ * gcc.dg/analyzer/sensitive-1.c: Define __EXTENSIONS__ before
+ including unistd.h.
+ * gcc.dg/analyzer/setjmp-2.c: Replace include of <setjmp.h>
+ with "test-setjmp.h" and usage of setjmp with new SETJMP macro.
+ * gcc.dg/analyzer/setjmp-3.c: Likewise.
+ * gcc.dg/analyzer/setjmp-4.c: Likewise.
+ * gcc.dg/analyzer/setjmp-5.c: Likewise.
+ * gcc.dg/analyzer/setjmp-6.c: Likewise.
+ * gcc.dg/analyzer/setjmp-7.c: Likewise.
+ * gcc.dg/analyzer/setjmp-7a.c: Likewise.
+ * gcc.dg/analyzer/setjmp-8.c: Likewise.
+ * gcc.dg/analyzer/setjmp-9.c: Likewise.
+ * gcc.dg/analyzer/test-setjmp.h: New header.
+
2020-01-22 Marek Polacek <polacek@redhat.com>
PR c++/92907 - noexcept does not consider "const" in member functions.
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+#include <alloca.h>
#include "analyzer-decls.h"
struct foo
+#include <alloca.h>
#include <stdlib.h>
#include <string.h>
static allocator_t __attribute__((noinline))
get_alloca (void)
{
- return alloca;
+ /* On e.g. Solaris, alloca is a macro so we can't take its address;
+ use __builtin_alloca instead. */
+ return __builtin_alloca;
}
static deallocator_t __attribute__((noinline))
/* { dg-additional-options "-fanalyzer-transitivity" } */
#include <stddef.h>
+#include <alloca.h>
#include <stdlib.h>
extern void do_stuff (const void *);
#include <stdio.h>
+
+/* Solaris needs this for <unistd.h> to declare getpass. */
+#define __EXTENSIONS__
#include <unistd.h>
+
#include <string.h>
char test_1 (FILE *logfile)
/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
/* { dg-enable-nn-line-numbers "" } */
-#include <setjmp.h>
+#include "test-setjmp.h"
#include <stddef.h>
#include "analyzer-decls.h"
void test_1 (void)
{
- setjmp (NULL);
+ SETJMP (NULL);
}
void test_2 (void)
foo (0);
- i = setjmp(env);
+ i = SETJMP(env);
foo (1);
| ^~~~~~~~~~~~~~~~~~~~~~~
'test_2': event 1
|
- | NN | i = setjmp(env);
+ | NN | i = SETJMP(env);
| | ^~~~~~
| | |
| | (1) 'setjmp' called here
|
'test_2': event 5
|
- | NN | i = setjmp(env);
+ | NN | i = SETJMP(env);
| | ^~~~~~
| | |
| | (5) ...to 'setjmp' (saved at (1))
/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
/* { dg-enable-nn-line-numbers "" } */
-#include <setjmp.h>
#include <stddef.h>
+#include "test-setjmp.h"
#include "analyzer-decls.h"
extern int foo (int) __attribute__ ((__pure__));
foo (0);
- i = setjmp(env);
+ i = SETJMP(env);
if (i != 0)
{
|
'outer': event 2
|
- | NN | i = setjmp(env);
+ | NN | i = SETJMP(env);
| | ^~~~~~
| | |
| | (2) 'setjmp' called here
|
'outer': event 8
|
- | NN | i = setjmp(env);
+ | NN | i = SETJMP(env);
| | ^~~~~~
| | |
| | (8) ...to 'setjmp' in 'outer' (saved at (2))
/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
/* { dg-enable-nn-line-numbers "" } */
-#include <setjmp.h>
+#include "test-setjmp.h"
#include "analyzer-decls.h"
extern int foo (int) __attribute__ ((__pure__));
int main (void)
{
- if (!setjmp(buf))
+ if (!SETJMP(buf))
outer (42);
else
__analyzer_dump_path (); /* { dg-message "path" } */
|
'main': event 2
|
- | NN | if (!setjmp(buf))
+ | NN | if (!SETJMP(buf))
| | ^~~~~~
| | |
| | (2) 'setjmp' called here
|
'main': events 3-5
|
- | NN | if (!setjmp(buf))
+ | NN | if (!SETJMP(buf))
| | ^
| | |
| | (3) following 'true' branch...
|
'main': event 10
|
- | NN | if (!setjmp(buf))
+ | NN | if (!SETJMP(buf))
| | ^~~~~~
| | |
| | (10) ...to 'setjmp' in 'main' (saved at (2))
|
'main': events 11-13
|
- | NN | if (!setjmp(buf))
+ | NN | if (!SETJMP(buf))
| | ^
| | |
| | (11) following 'false' branch...
/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
/* { dg-enable-nn-line-numbers "" } */
-#include <setjmp.h>
+#include "test-setjmp.h"
#include <stddef.h>
#include "analyzer-decls.h"
static void inner (void)
{
- setjmp (env);
+ SETJMP (env);
}
void outer (void)
|
'inner': event 4
|
- | NN | setjmp (env);
+ | NN | SETJMP (env);
| | ^~~~~~
| | |
| | (4) 'setjmp' called here
-#include <setjmp.h>
+#include "test-setjmp.h"
#include <stddef.h>
#include <stdlib.h>
foo (0);
- i = setjmp(env);
+ i = SETJMP(env);
if (i == 0)
{
-#include <setjmp.h>
+#include "test-setjmp.h"
#include <stddef.h>
#include <stdlib.h>
foo (0);
- i = setjmp(env);
+ i = SETJMP(env);
if (i == 0)
{
/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
/* { dg-enable-nn-line-numbers "" } */
-#include <setjmp.h>
+#include "test-setjmp.h"
#include <stdlib.h>
extern int foo (int) __attribute__ ((__pure__));
foo (0);
- i = setjmp(env);
+ i = SETJMP(env);
if (i == 0)
{
|
'outer': event 2
|
- | NN | i = setjmp(env);
+ | NN | i = SETJMP(env);
| | ^~~~~~
| | |
| | (2) 'setjmp' called here
|
'outer': event 12
|
- | NN | i = setjmp(env);
+ | NN | i = SETJMP(env);
| | ^~~~~~
| | |
| | (12) ...to 'setjmp' in 'outer' (saved at (2))
/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
/* { dg-enable-nn-line-numbers "" } */
-#include <setjmp.h>
+#include "test-setjmp.h"
#include <stddef.h>
#include "analyzer-decls.h"
foo (0);
- i = setjmp(env);
+ i = SETJMP(env);
if (i != 0)
{
|
'outer': event 2
|
- | NN | i = setjmp(env);
+ | NN | i = SETJMP(env);
| | ^~~~~~
| | |
| | (2) 'setjmp' called here
|
'outer': event 8
|
- | NN | i = setjmp(env);
+ | NN | i = SETJMP(env);
| | ^~~~~~
| | |
| | (8) ...to 'setjmp' in 'outer' (saved at (2))
/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
/* { dg-enable-nn-line-numbers "" } */
-#include <setjmp.h>
+#include "test-setjmp.h"
#include <stddef.h>
#include "analyzer-decls.h"
foo (0);
- i = setjmp(env);
+ i = SETJMP(env);
if (i != 0)
{
|
'outer': event 2
|
- | NN | i = setjmp(env);
+ | NN | i = SETJMP(env);
| | ^~~~~~
| | |
| | (2) 'setjmp' called here
|
'outer': event 8
|
- | NN | i = setjmp(env);
+ | NN | i = SETJMP(env);
| | ^~~~~~
| | |
| | (8) ...to 'setjmp' in 'outer' (saved at (2))
--- /dev/null
+/* Various integration tests for setjmp-handling expect a precise
+ multiline output.
+
+ The outputs from -fdiagnostics-path-format=inline-events for such
+ setjmp tests are dependent on whether setjmp is a macro or a function
+ (and whether that macro is defined in a system header).
+
+ setjmp is a function on some systems and a macro on others.
+ This header provides a SETJMP macro in a (fake) system header,
+ for consistency of output across such systems. */
+
+#include <setjmp.h>
+
+#pragma GCC system_header
+
+#define SETJMP(E) setjmp(E)