mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-24 21:11:19 +08:00
analyzer: testsuite fixes for alloca, getpass, and setjmp (PR 93316)
PR analyzer/93316 reports various testsuite failures where I accidentally relied on properties of x86_64-pc-linux-gnu. The following patch fixes them on sparc-sun-solaris2.11 (gcc211 in the GCC compile farm), and, I hope, the other configurations showing failures. There may still be other failures for pattern-test-2.c, which I'm tracking separately as PR analyzer/93291. gcc/analyzer/ChangeLog: PR analyzer/93316 * analyzer.cc (is_setjmp_call_p): Check for "setjmp" as well as "_setjmp". gcc/testsuite/ChangeLog: 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.
This commit is contained in:
parent
75038aa6aa
commit
da7cf663b7
@ -1,3 +1,9 @@
|
||||
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
|
||||
|
@ -91,7 +91,8 @@ is_setjmp_call_p (const gimple *stmt)
|
||||
{
|
||||
/* 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;
|
||||
|
@ -1,3 +1,25 @@
|
||||
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.
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <alloca.h>
|
||||
#include "analyzer-decls.h"
|
||||
|
||||
struct foo
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include <alloca.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -12,7 +12,9 @@ get_malloc (void)
|
||||
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))
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* { dg-additional-options "-fanalyzer-transitivity" } */
|
||||
|
||||
#include <stddef.h>
|
||||
#include <alloca.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
extern void do_stuff (const void *);
|
||||
|
@ -1,5 +1,9 @@
|
||||
#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)
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* { 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"
|
||||
|
||||
@ -9,7 +9,7 @@ extern void foo (int);
|
||||
|
||||
void test_1 (void)
|
||||
{
|
||||
setjmp (NULL);
|
||||
SETJMP (NULL);
|
||||
}
|
||||
|
||||
void test_2 (void)
|
||||
@ -19,7 +19,7 @@ void test_2 (void)
|
||||
|
||||
foo (0);
|
||||
|
||||
i = setjmp(env);
|
||||
i = SETJMP(env);
|
||||
|
||||
foo (1);
|
||||
|
||||
@ -39,7 +39,7 @@ void test_2 (void)
|
||||
| ^~~~~~~~~~~~~~~~~~~~~~~
|
||||
'test_2': event 1
|
||||
|
|
||||
| NN | i = setjmp(env);
|
||||
| NN | i = SETJMP(env);
|
||||
| | ^~~~~~
|
||||
| | |
|
||||
| | (1) 'setjmp' called here
|
||||
@ -59,7 +59,7 @@ void test_2 (void)
|
||||
|
|
||||
'test_2': event 5
|
||||
|
|
||||
| NN | i = setjmp(env);
|
||||
| NN | i = SETJMP(env);
|
||||
| | ^~~~~~
|
||||
| | |
|
||||
| | (5) ...to 'setjmp' (saved at (1))
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* { 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__));
|
||||
@ -20,7 +20,7 @@ void outer (void)
|
||||
|
||||
foo (0);
|
||||
|
||||
i = setjmp(env);
|
||||
i = SETJMP(env);
|
||||
|
||||
if (i != 0)
|
||||
{
|
||||
@ -47,7 +47,7 @@ void outer (void)
|
||||
|
|
||||
'outer': event 2
|
||||
|
|
||||
| NN | i = setjmp(env);
|
||||
| NN | i = SETJMP(env);
|
||||
| | ^~~~~~
|
||||
| | |
|
||||
| | (2) 'setjmp' called here
|
||||
@ -84,7 +84,7 @@ void outer (void)
|
||||
|
|
||||
'outer': event 8
|
||||
|
|
||||
| NN | i = setjmp(env);
|
||||
| NN | i = SETJMP(env);
|
||||
| | ^~~~~~
|
||||
| | |
|
||||
| | (8) ...to 'setjmp' in 'outer' (saved at (2))
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* { 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__));
|
||||
@ -23,7 +23,7 @@ void outer (int y)
|
||||
|
||||
int main (void)
|
||||
{
|
||||
if (!setjmp(buf))
|
||||
if (!SETJMP(buf))
|
||||
outer (42);
|
||||
else
|
||||
__analyzer_dump_path (); /* { dg-message "path" } */
|
||||
@ -42,14 +42,14 @@ int main (void)
|
||||
|
|
||||
'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...
|
||||
@ -87,14 +87,14 @@ int main (void)
|
||||
|
|
||||
'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...
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* { 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"
|
||||
|
||||
@ -9,7 +9,7 @@ static jmp_buf env;
|
||||
|
||||
static void inner (void)
|
||||
{
|
||||
setjmp (env);
|
||||
SETJMP (env);
|
||||
}
|
||||
|
||||
void outer (void)
|
||||
@ -45,7 +45,7 @@ void outer (void)
|
||||
|
|
||||
'inner': event 4
|
||||
|
|
||||
| NN | setjmp (env);
|
||||
| NN | SETJMP (env);
|
||||
| | ^~~~~~
|
||||
| | |
|
||||
| | (4) 'setjmp' called here
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <setjmp.h>
|
||||
#include "test-setjmp.h"
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -19,7 +19,7 @@ void outer (void)
|
||||
|
||||
foo (0);
|
||||
|
||||
i = setjmp(env);
|
||||
i = SETJMP(env);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <setjmp.h>
|
||||
#include "test-setjmp.h"
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -24,7 +24,7 @@ void outer (void)
|
||||
|
||||
foo (0);
|
||||
|
||||
i = setjmp(env);
|
||||
i = SETJMP(env);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* { 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__));
|
||||
@ -26,7 +26,7 @@ void outer (void)
|
||||
|
||||
foo (0);
|
||||
|
||||
i = setjmp(env);
|
||||
i = SETJMP(env);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
@ -49,7 +49,7 @@ void outer (void)
|
||||
|
|
||||
'outer': event 2
|
||||
|
|
||||
| NN | i = setjmp(env);
|
||||
| NN | i = SETJMP(env);
|
||||
| | ^~~~~~
|
||||
| | |
|
||||
| | (2) 'setjmp' called here
|
||||
@ -103,7 +103,7 @@ void outer (void)
|
||||
|
|
||||
'outer': event 12
|
||||
|
|
||||
| NN | i = setjmp(env);
|
||||
| NN | i = SETJMP(env);
|
||||
| | ^~~~~~
|
||||
| | |
|
||||
| | (12) ...to 'setjmp' in 'outer' (saved at (2))
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* { 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"
|
||||
|
||||
@ -21,7 +21,7 @@ void outer (void)
|
||||
|
||||
foo (0);
|
||||
|
||||
i = setjmp(env);
|
||||
i = SETJMP(env);
|
||||
|
||||
if (i != 0)
|
||||
{
|
||||
@ -48,7 +48,7 @@ void outer (void)
|
||||
|
|
||||
'outer': event 2
|
||||
|
|
||||
| NN | i = setjmp(env);
|
||||
| NN | i = SETJMP(env);
|
||||
| | ^~~~~~
|
||||
| | |
|
||||
| | (2) 'setjmp' called here
|
||||
@ -85,7 +85,7 @@ void outer (void)
|
||||
|
|
||||
'outer': event 8
|
||||
|
|
||||
| NN | i = setjmp(env);
|
||||
| NN | i = SETJMP(env);
|
||||
| | ^~~~~~
|
||||
| | |
|
||||
| | (8) ...to 'setjmp' in 'outer' (saved at (2))
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* { 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"
|
||||
|
||||
@ -23,7 +23,7 @@ void outer (void)
|
||||
|
||||
foo (0);
|
||||
|
||||
i = setjmp(env);
|
||||
i = SETJMP(env);
|
||||
|
||||
if (i != 0)
|
||||
{
|
||||
@ -50,7 +50,7 @@ void outer (void)
|
||||
|
|
||||
'outer': event 2
|
||||
|
|
||||
| NN | i = setjmp(env);
|
||||
| NN | i = SETJMP(env);
|
||||
| | ^~~~~~
|
||||
| | |
|
||||
| | (2) 'setjmp' called here
|
||||
@ -87,7 +87,7 @@ void outer (void)
|
||||
|
|
||||
'outer': event 8
|
||||
|
|
||||
| NN | i = setjmp(env);
|
||||
| NN | i = SETJMP(env);
|
||||
| | ^~~~~~
|
||||
| | |
|
||||
| | (8) ...to 'setjmp' in 'outer' (saved at (2))
|
||||
|
16
gcc/testsuite/gcc.dg/analyzer/test-setjmp.h
Normal file
16
gcc/testsuite/gcc.dg/analyzer/test-setjmp.h
Normal file
@ -0,0 +1,16 @@
|
||||
/* 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)
|
Loading…
x
Reference in New Issue
Block a user