From 8209297f0cde69559f751eb3614584e69d834a2a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 10 Jun 2015 16:51:12 +0300 Subject: Add test 6. --- test/Makefile | 8 ++- test/test6-01.txt | 198 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/test6-02.txt | 0 test/test6-03.txt | 8 +++ test/test6.c | 24 +++++++ 5 files changed, 236 insertions(+), 2 deletions(-) create mode 100644 test/test6-01.txt create mode 100644 test/test6-02.txt create mode 100644 test/test6-03.txt create mode 100644 test/test6.c diff --git a/test/Makefile b/test/Makefile index 3ecddb3..6164dfd 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,4 +1,4 @@ -.PHONY: test1 test2 test3 test4 test5 crashtest1 crashtest2 all crashes clean +.PHONY: test1 test2 test3 test4 test5 test6 crashtest1 crashtest2 all crashes clean .NOTPARALLEL: all allcrash CC := gcc-5 @@ -7,7 +7,7 @@ CXX := g++-5 PLUGIN = ../build/src/.libs/astdumper.so CMD = LANG=C ${CXX} -c -fplugin=${PLUGIN} -fplugin-arg-astdumper-command=${1} ${2} -o a.out 2>${3} -all: test1 test2 test3 test4 test5 clean +all: test1 test2 test3 test4 test5 test6 clean crashes: crashtest1 crashtest2 clean clean: @@ -33,6 +33,10 @@ test5: $(call CMD,findargs,test5.c,test5-02.txt) $(call CMD,detectnullpointers,test5.c,test5-03.txt) $(call CMD,dumpunsupported,test5.c,test5-04.txt) +test6: + $(call CMD,dump,test6.c,test6-01.txt) + $(call CMD,dumpunsupported,test6.c,test6-02.txt) + $(call CMD,detectnullpointers,test6.c,test6-03.txt) crashtest1: $(call CMD,dump,crashtest1.h,crashtest1-01.txt) diff --git a/test/test6-01.txt b/test/test6-01.txt new file mode 100644 index 0000000..2b4c032 --- /dev/null +++ b/test/test6-01.txt @@ -0,0 +1,198 @@ +function_decl func1 test6.c 5:6 +- isPublic: 1 + function_type - function type + void_type - function return type + type_decl void 0:0 - type name + - isAutogenerated: 1 + tree_list - arg types + pointer_type - value + integer_type - nested type + - precisionBits: 32 + - signed + type_decl int 0:0 - type name + - isAutogenerated: 1 + integer_cst 32 - type size + integer_cst -2147483648 - min value + integer_cst 2147483647 - max value + tree_list - chain + void_type - value + type_decl void 0:0 - type name + - isAutogenerated: 1 + result_decl test6.c 5:18 - function result + - isAutogenerated: 1 + void_type - result type + type_decl void 0:0 - type name + - isAutogenerated: 1 + - isUsed: 1 + parm_decl a test6.c 5:17 - argument + pointer_type - decl type + integer_type - nested type + - precisionBits: 32 + - signed + type_decl int 0:0 - type name + - isAutogenerated: 1 + integer_cst 32 - type size + integer_cst -2147483648 - min value + integer_cst 2147483647 - max value + integer_cst 64 - parm size + cleanup_point_expr test6.c 7:13 - code + expr_stmt - operand + convert_expr - expresssion + modify_expr - operand + indirect_ref - operand + - isUsed: 1 + parm_decl a test6.c 5:17 - operand + pointer_type - decl type + integer_type - nested type + - precisionBits: 32 + - signed + type_decl int 0:0 - type name + - isAutogenerated: 1 + integer_cst 32 - type size + integer_cst -2147483648 - min value + integer_cst 2147483647 - max value + integer_cst 64 - parm size + integer_cst 100 - operand +function_decl func2 test6.c 10:6 +- isPublic: 1 + function_type - function type + void_type - function return type + type_decl void 0:0 - type name + - isAutogenerated: 1 + tree_list - arg types + pointer_type - value + integer_type - nested type + - precisionBits: 32 + - signed + type_decl int 0:0 - type name + - isAutogenerated: 1 + integer_cst 32 - type size + integer_cst -2147483648 - min value + integer_cst 2147483647 - max value + tree_list - chain + void_type - value + type_decl void 0:0 - type name + - isAutogenerated: 1 + result_decl test6.c 10:18 - function result + - isAutogenerated: 1 + void_type - result type + type_decl void 0:0 - type name + - isAutogenerated: 1 + - isUsed: 1 + parm_decl a test6.c 10:17 - argument + pointer_type - decl type + integer_type - nested type + - precisionBits: 32 + - signed + type_decl int 0:0 - type name + - isAutogenerated: 1 + integer_cst 32 - type size + integer_cst -2147483648 - min value + integer_cst 2147483647 - max value + integer_cst 64 - parm size + if_stmt - code + eq_expr test6.c 12:10 - condition + - isUsed: 1 + parm_decl a test6.c 10:17 - operand + pointer_type - decl type + integer_type - nested type + - precisionBits: 32 + - signed + type_decl int 0:0 - type name + - isAutogenerated: 1 + integer_cst 32 - type size + integer_cst -2147483648 - min value + integer_cst 2147483647 - max value + integer_cst 64 - parm size + integer_cst 0 - operand + return_expr test6.c 13:9 - then + cleanup_point_expr test6.c 15:17 - else + expr_stmt - operand + convert_expr - expresssion + modify_expr - operand + indirect_ref - operand + - isUsed: 1 + parm_decl a test6.c 10:17 - operand + pointer_type - decl type + integer_type - nested type + - precisionBits: 32 + - signed + type_decl int 0:0 - type name + - isAutogenerated: 1 + integer_cst 32 - type size + integer_cst -2147483648 - min value + integer_cst 2147483647 - max value + integer_cst 64 - parm size + integer_cst 200 - operand +function_decl func3 test6.c 18:6 +- isPublic: 1 + function_type - function type + void_type - function return type + type_decl void 0:0 - type name + - isAutogenerated: 1 + tree_list - arg types + pointer_type - value + integer_type - nested type + - precisionBits: 32 + - signed + type_decl int 0:0 - type name + - isAutogenerated: 1 + integer_cst 32 - type size + integer_cst -2147483648 - min value + integer_cst 2147483647 - max value + tree_list - chain + void_type - value + type_decl void 0:0 - type name + - isAutogenerated: 1 + result_decl test6.c 18:21 - function result + - isAutogenerated: 1 + void_type - result type + type_decl void 0:0 - type name + - isAutogenerated: 1 + - isUsed: 1 + parm_decl aptr test6.c 18:17 - argument + pointer_type - decl type + integer_type - nested type + - precisionBits: 32 + - signed + type_decl int 0:0 - type name + - isAutogenerated: 1 + integer_cst 32 - type size + integer_cst -2147483648 - min value + integer_cst 2147483647 - max value + integer_cst 64 - parm size + statement_list - code + if_stmt - statement + eq_expr test6.c 20:10 - condition + - isUsed: 1 + parm_decl aptr test6.c 18:17 - operand + pointer_type - decl type + integer_type - nested type + - precisionBits: 32 + - signed + type_decl int 0:0 - type name + - isAutogenerated: 1 + integer_cst 32 - type size + integer_cst -2147483648 - min value + integer_cst 2147483647 - max value + integer_cst 64 - parm size + integer_cst 0 - operand + return_expr test6.c 21:9 - then + cleanup_point_expr test6.c 23:16 - statement + expr_stmt - operand + convert_expr - expresssion + modify_expr - operand + indirect_ref - operand + - isUsed: 1 + parm_decl aptr test6.c 18:17 - operand + pointer_type - decl type + integer_type - nested type + - precisionBits: 32 + - signed + type_decl int 0:0 - type name + - isAutogenerated: 1 + integer_cst 32 - type size + integer_cst -2147483648 - min value + integer_cst 2147483647 - max value + integer_cst 64 - parm size + integer_cst 300 - operand diff --git a/test/test6-02.txt b/test/test6-02.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/test6-03.txt b/test/test6-03.txt new file mode 100644 index 0000000..b1f3abe --- /dev/null +++ b/test/test6-03.txt @@ -0,0 +1,8 @@ +test6.c: In function 'void func1(int*)': +test6.c:7:13: warning: Using variable without check for NULL + *a = 100; + ^ +test6.c: In function 'void func3(int*)': +test6.c:23:16: warning: Using variable without check for NULL + *aptr = 300; + ^ diff --git a/test/test6.c b/test/test6.c new file mode 100644 index 0000000..d9203b2 --- /dev/null +++ b/test/test6.c @@ -0,0 +1,24 @@ +void func1(int *a); +void func2(int *a); +void func3(int *a); + +void func1(int *a) +{ + *a = 100; +} + +void func2(int *a) +{ + if (!a) + return; + else + *a = 200; +} + +void func3(int *aptr) +{ + if (!aptr) + return; + + *aptr = 300; +} -- cgit v1.2.3-70-g09d2