diff --git a/Makefile b/Makefile index 43992d3..146b2b8 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,10 @@ dcc.1: dcc help2man_include.txt help2man --include=help2man_include.txt ./dcc >dcc.1 tests: dcc - tests/do_tests.sh + tests/do_tests.sh ./dcc + +tests_all_clang_versions: dcc + set -x ; for compiler in /usr/bin/clang-[1-24-9]* ; do tests/do_tests.sh ./dcc $$compiler; done debian: dcc rm -rf debian diff --git a/compile.py b/compile.py index 30d1b14..4dc5e89 100755 --- a/compile.py +++ b/compile.py @@ -10,8 +10,9 @@ COMMON_WARNING_ARGS = "-Wall -Wno-unused -Wunused-variable -Wunused-value -Wno-unused-result".split() COMMON_COMPILER_ARGS = COMMON_WARNING_ARGS + "-std=gnu11 -g -lm".split() -EXTRA_C_COMPILER_ARGS = COMMON_COMPILER_ARGS + "-Wunused-comparison -fcolor-diagnostics -fno-omit-frame-pointer -fno-common -funwind-tables -fno-optimize-sibling-calls -Qunused-arguments".split() -GCC_ARGS = COMMON_COMPILER_ARGS + "-Wunused-but-set-variable -O -fdiagnostics-color -o /dev/null".split() +CLANG_ONLY_ARGS = "-Wunused-comparison -fno-omit-frame-pointer -fno-common -funwind-tables -fno-optimize-sibling-calls -Qunused-arguments".split() + +GCC_ARGS = COMMON_COMPILER_ARGS + "-Wunused-but-set-variable -O -o /dev/null".split() MAXIMUM_SOURCE_FILE_EMBEDDED_BYTES = 1000000 @@ -25,7 +26,13 @@ def compile(debug=False): os.environ['PATH'] = os.path.dirname(os.path.realpath(sys.argv[0])) + ':/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:' + os.environ.get('PATH', '') args = parse_args(sys.argv[1:]) - + + # we have to set these explicitly because + clang_args = COMMON_COMPILER_ARGS + CLANG_ONLY_ARGS + if args.colorize_output: + clang_args += ['-fcolor-diagnostics'] + clang_args += ['-fdiagnostics-color'] + if args.which_sanitizer == "memory" and platform.architecture()[0][0:2] == '32': if search_path('valgrind'): # -fsanitize=memory requires 64-bits so we fallback to embedding valgrind @@ -37,18 +44,21 @@ def compile(debug=False): clang_version = None try: - clang_version = subprocess.check_output(["clang", "--version"], universal_newlines=True) + clang_version = subprocess.check_output([args.c_compiler, "--version"], universal_newlines=True) if debug: print("clang version:", clang_version) - m = re.search("clang version (\d+\.\d+\.\d+)", clang_version, flags=re.I) + m = re.search("clang version ((\d+)\.(\d+)\.\d+)", clang_version, flags=re.I) if m is not None: clang_version = m.group(1) + clang_version_major = m.group(2) + clang_version_minor = m.group(3) + clang_version_float = float(m.group(2) + "." + m.group(3)) except OSError as e: if debug: print(e) if not clang_version: - print("Can not get clang version", file=sys.stderr) + print("Can not get version information for '%s'" % args.c_compiler, file=sys.stderr) sys.exit(1) if args.which_sanitizer == "address" and platform.architecture()[0][0:2] == '32': @@ -66,7 +76,7 @@ def compile(debug=False): if debug: print(e) - if clang_version and libc_version and clang_version[0] in "345" and libc_version >= 2.27: + if libc_version and clang_version_float < 6 and libc_version >= 2.27: print("incompatible clang libc versions, disabling error detection by sanitiziers", file=sys.stderr) sanitizer_args = [] @@ -79,8 +89,6 @@ def compile(debug=False): tar_n_bytes, tar_source = source_for_embedded_tarfile(args) if args.which_sanitizer == "valgrind": - sanitizer_args = [] - sanitizer_args = ['-fsanitize=undefined', '-fno-sanitize-recover=undefined,integer'] wrapper_source = wrapper_source.replace('__DCC_SANITIZER_IS_VALGRIND__', '1') if args.embed_source: watcher = fr"python3 -E -c \"import os,sys,tarfile,tempfile\n\ @@ -92,27 +100,36 @@ def compile(debug=False): else: watcher = dcc_path + "--watch-stdin-for-valgrind-errors" wrapper_source = wrapper_source.replace('__DCC_MONITOR_VALGRIND__', watcher) + sanitizer_args = [] elif args.which_sanitizer == "memory": wrapper_source = wrapper_source.replace('__DCC_SANITIZER_IS_MEMORY__', '1') - # FIXME if we enable '-fsanitize=undefined', '-fno-sanitize-recover=undefined,integer' - # which would be preferable here we get uninitialized variable error message for undefined errors + args.which_sanitizer = "memory" sanitizer_args = ['-fsanitize=memory'] else: wrapper_source = wrapper_source.replace('__DCC_SANITIZER_IS_ADDRESS__', '1') # fixme add code to check version supports these - sanitizer_args = ['-fsanitize=address', '-fsanitize=undefined', '-fno-sanitize-recover=undefined,integer'] + sanitizer_args = ['-fsanitize=address'] args.which_sanitizer = "address" + + if args.which_sanitizer != "memory": + # FIXME if we enable '-fsanitize=undefined', '-fno-sanitize-recover=undefined,integer' for memory + # which would be preferable here we get uninitialized variable error message for undefined errors + sanitizer_args += ['-fsanitize=undefined'] + if clang_version_float >= 3.6: + sanitizer_args += ['-fno-sanitize-recover=undefined,integer'] wrapper_source = wrapper_source.replace('__DCC_LEAK_CHECK_YES_NO__', "yes" if args.leak_check else "no") wrapper_source = wrapper_source.replace('__DCC_LEAK_CHECK_1_0__', "1" if args.leak_check else "0") wrapper_source = wrapper_source.replace('__DCC_SUPRESSIONS_FILE__', args.suppressions_file) wrapper_source = wrapper_source.replace('__DCC_STACK_USE_AFTER_RETURN__', "1" if args.stack_use_after_return else "0") wrapper_source = wrapper_source.replace('__DCC_NO_WRAP_MAIN__', "1" if args.no_wrap_main else "0") + wrapper_source = wrapper_source.replace('__DCC_CLANG_VERSION_MAJOR__', clang_version_major) + wrapper_source = wrapper_source.replace('__DCC_CLANG_VERSION_MINOR__', clang_version_minor) # shared_libasan breaks easily ,e.g if there are libraries in /etc/ld.so.preload # and we can't override with verify_asan_link_order=0 for clang version < 5 # and with clang-6 on debian __asan_default_options not called with shared_libasan - if args.shared_libasan is None and clang_version[0] not in "3456": + if args.shared_libasan is None and clang_version_float >= 7.0: args.shared_libasan = True if args.shared_libasan and args.which_sanitizer == "address": @@ -124,7 +141,7 @@ def compile(debug=False): wrapper_source = wrapper_source.replace('__DCC_EMBED_SOURCE__', '1') wrapper_source = tar_source + wrapper_source - incremental_compilation_args = sanitizer_args + EXTRA_C_COMPILER_ARGS + args.user_supplied_compiler_args + incremental_compilation_args = sanitizer_args + clang_args + args.user_supplied_compiler_args command = [args.c_compiler] + incremental_compilation_args if args.incremental_compilation: if args.debug: @@ -132,7 +149,7 @@ def compile(debug=False): sys.exit(subprocess.call(command)) # -x - must come after any filenames but before ld options - command = [args.c_compiler] + args.user_supplied_compiler_args + ['-x', 'c', '-', ] + sanitizer_args + EXTRA_C_COMPILER_ARGS + command = [args.c_compiler] + args.user_supplied_compiler_args + ['-x', 'c', '-', ] + sanitizer_args + clang_args if args.ifdef_main: command += ['-Dmain=__real_main'] wrapper_source = wrapper_source.replace('__wrap_main', 'main') @@ -141,10 +158,16 @@ def compile(debug=False): if args.debug: print(" ".join(command), file=sys.stderr) + if args.debug > 1: - print(" ".join(command), '<= 6 extern char *__asan_get_report_description(); extern int __asan_report_present(); if (__asan_report_present()) { @@ -244,17 +257,18 @@ char *__msan_default_options() { return "verbosity=0:print_stacktrace=1:halt_on_error=1:detect_leaks=__DCC_LEAK_CHECK_1_0__"; } -extern void __ubsan_get_current_report_data(char **OutIssueKind, char **OutMessage, char **OutFilename, unsigned int *OutLine, unsigned int *OutCol, char **OutMemoryAddr); - void __ubsan_on_report(void) { if (debug) fprintf(stderr, "__ubsan_on_report\n"); +#if __DCC_CLANG_VERSION_MAJOR__ >= 7 && !__DCC_SANITIZER_IS_MEMORY__ char *OutIssueKind; char *OutMessage; char *OutFilename; unsigned int OutLine; unsigned int OutCol; char *OutMemoryAddr; + extern void __ubsan_get_current_report_data(char **OutIssueKind, char **OutMessage, char **OutFilename, unsigned int *OutLine, unsigned int *OutCol, char **OutMemoryAddr); + __ubsan_get_current_report_data(&OutIssueKind, &OutMessage, &OutFilename, &OutLine, &OutCol, &OutMemoryAddr); // buffer + putenv is ugly - but safer? @@ -267,7 +281,7 @@ void __ubsan_on_report(void) { snprintf(buffer[5], sizeof buffer[5], "DCC_UBSAN_ERROR_MEMORYADDR=%s", OutMemoryAddr); for (int i = 0; i < sizeof buffer/sizeof buffer[0]; i++) putenv(buffer[i]); - +#endif _explain_error(); // not reached } diff --git a/packaging/debian/debian/control b/packaging/debian/debian/control index 5934322..85bafc6 100644 --- a/packaging/debian/debian/control +++ b/packaging/debian/debian/control @@ -7,7 +7,7 @@ Build-Depends: debhelper (>= 9) Package: dcc Architecture: all Depends: python3 (>= 3.6), gdb(>= 7.12), clang(>= 4.0) -Recommends: valgrind(>= 1:3.13) +Recommends: valgrind(>= 1:3.13), clang(>= 7.0) Homepage: https://github.com/COMP1511UNSW/dcc Description: compiler for novice C programmers dcc compiles C programs using clang and adds explanations suitable diff --git a/tests/do_tests.sh b/tests/do_tests.sh index 2868454..386a4d3 100755 --- a/tests/do_tests.sh +++ b/tests/do_tests.sh @@ -39,15 +39,16 @@ for src_file in tests/extracted_compile_time_tests/*.c tests/compile_time/*.c te do rm -f a.out - compile_options_list=$(egrep '^//dcc_flags=' "$src_file"|sed 's?//??;s? ?#?g') + compile_options_list=$(egrep '^//dcc_flags=' "$src_file"|sed 's?//??;s/ /#/g') compile_options_list=${compile_options_list:-'dcc_flags=""'} for compile_options in $compile_options_list do + compile_options=$(echo "$compile_options"|sed 's/#/ /g') case "$src_file" in *.c) dcc_flags= - suffix=`echo $compile_options|sed 's/^dcc_flags=//;s/["$]//g;s/src_file//'` + suffix=`echo $compile_options|sed 's/^dcc_flags=//;s/ /_/g;s/["$]//g;s/src_file//'` eval $compile_options expected_stderr_file="$expected_output_dir/`basename $src_file .c`$suffix.txt" #echo "$dcc" --c-compiler=$c_compiler $dcc_flags "$src_file" diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/add_int_to_string.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/add_int_to_string.txt index d4529f9..7a55406 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/add_int_to_string.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/add_int_to_string.txt @@ -1,10 +1,10 @@ -tests/compile_time/add_int_to_string.c:4:17: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int] +tests/compile_time/add_int_to_string.c:4:17: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int] printf("hello" + argc); - ~~~~~~~~^~~~~~ -tests/compile_time/add_int_to_string.c:4:17: note: use array indexing to silence this warning + ~~~~~~~~^~~~~~ +tests/compile_time/add_int_to_string.c:4:17: note: use array indexing to silence this warning printf("hello" + argc); - ^ - & [ ] + ^ + & [ ] dcc explanation: Careful, you can't concatenate values and strings in C using the `+` operator, as you seem to be trying to do on line 4 of `tests/compile_time/add_int_to_string.c`. Odds are you want to provide `printf` with a format code for that value and pass that value to `printf` as an argument. diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/array_static_illegal_index.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/array_static_illegal_index.txt index 4df6927..6c57383 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/array_static_illegal_index.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/array_static_illegal_index.txt @@ -1,9 +1,9 @@ -tests/compile_time/array_static_illegal_index.c:3:2: warning: array index 5 is past the end of the array (which contains 5 elements) [-Warray-bounds] +tests/compile_time/array_static_illegal_index.c:3:2: warning: array index 5 is past the end of the array (which contains 5 elements) [-Warray-bounds] a[5] = 0; - ^ ~ -tests/compile_time/array_static_illegal_index.c:2:2: note: array 'a' declared here + ^ ~ +tests/compile_time/array_static_illegal_index.c:2:2: note: array 'a' declared here int a[5]; - ^ + ^ dcc explanation: Careful, on line 3 of `tests/compile_time/array_static_illegal_index.c`, it looks like you're trying to access location 5 of `a`, which doesn't exist; `a` isn't that long. Keep in mind that arrays are 0-indexed. diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/array_string_index.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/array_string_index.txt index 032d25a..d6a80e1 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/array_string_index.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/array_string_index.txt @@ -1,6 +1,6 @@ -tests/compile_time/array_string_index.c:3:3: error: array subscript is not an integer +tests/compile_time/array_string_index.c:3:3: error: array subscript is not an integer a["0"] = 0; - ^~~~ + ^~~~ dcc explanation: Looks like you're trying to access an element of the array `a` on line 3 of `tests/compile_time/array_string_index.c`, but your index (`"0"`) is not of type `int`. Right now, your index is of type `string` instead. Make sure your index (the value between square brackets) is an `int`. diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assert_without_closing_parenthesis.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assert_without_closing_parenthesis.txt index 79e6381..46274ec 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assert_without_closing_parenthesis.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assert_without_closing_parenthesis.txt @@ -1,4 +1,4 @@ -tests/extracted_compile_time_tests/assert_without_closing_parenthesis.c:5:2: error: unterminated function-like macro invocation +tests/extracted_compile_time_tests/assert_without_closing_parenthesis.c:5:2: error: unterminated function-like macro invocation assert(argc == 1; - ^ + ^ dcc explanation: it looks like there is a missing closing bracket on the assert on line 5 of tests/extracted_compile_time_tests/assert_without_closing_parenthesis.c diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assign_array_to_int.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assign_array_to_int.txt index 4b980e4..7d1d337 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assign_array_to_int.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assign_array_to_int.txt @@ -1,5 +1,5 @@ -tests/extracted_compile_time_tests/assign_array_to_int.c:4:10: warning: incompatible pointer to integer conversion assigning to 'int' from 'int [3]' [-Wint-conversion] +tests/extracted_compile_time_tests/assign_array_to_int.c:4:10: warning: incompatible pointer to integer conversion assigning to 'int' from 'int [3]' [-Wint-conversion] a[0][0] = a[1]; - ^ ~~~~ + ^ ~~~~ dcc explanation: you are attempting to assign a[1] which is an array to an int variable. diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assign_function_to_int.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assign_function_to_int.txt index 80f0a01..40c5492 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assign_function_to_int.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assign_function_to_int.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/assign_function_to_int.c:3:6: warning: incompatible pointer to integer conversion initializing 'int' with an expression of type 'int (int, char **)' [-Wint-conversion] +tests/extracted_compile_time_tests/assign_function_to_int.c:3:6: warning: incompatible pointer to integer conversion initializing 'int' with an expression of type 'int (int, char **)' [-Wint-conversion] int a = main; - ^ ~~~~ + ^ ~~~~ dcc explanation: you are attempting to assign main which is a function to an int variable. Perhaps you are trying to call the function and have forgotten the round brackets and any parameter values. See more information here: https://comp1511unsw.github.io/dcc/assign_function_to_int.html diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assign_pointer_to_int.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assign_pointer_to_int.txt index 9d40b18..d6d56f4 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assign_pointer_to_int.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assign_pointer_to_int.txt @@ -1,5 +1,5 @@ -tests/extracted_compile_time_tests/assign_pointer_to_int.c:4:4: warning: incompatible pointer to integer conversion assigning to 'int' from 'int *'; remove & [-Wint-conversion] +tests/extracted_compile_time_tests/assign_pointer_to_int.c:4:4: warning: incompatible pointer to integer conversion assigning to 'int' from 'int *'; remove & [-Wint-conversion] a = &a; - ^ ~~ + ^ ~~ dcc explanation: you are attempting to assign &a which is not an int to an int variable. diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assign_to_array.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assign_to_array.txt index d154e58..e946f75 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assign_to_array.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assign_to_array.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/assign_to_array.c:4:4: error: array type 'int [1]' is not assignable +tests/extracted_compile_time_tests/assign_to_array.c:4:4: error: array type 'int [1]' is not assignable a = b; - ~ ^ + ~ ^ dcc explanation: you are trying to assign to 'a' which is an array with 1 element. You can not assign to a whole array. You can use a loop to assign to each array element individually. diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assign_to_multidimensional_array.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assign_to_multidimensional_array.txt index 5ca6087..c230d82 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assign_to_multidimensional_array.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/assign_to_multidimensional_array.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/assign_to_multidimensional_array.c:4:4: error: array type 'int [3][1]' is not assignable +tests/extracted_compile_time_tests/assign_to_multidimensional_array.c:4:4: error: array type 'int [3][1]' is not assignable a = b; - ~ ^ + ~ ^ dcc explanation: you are trying to assign to 'a' which is an array. You can not assign to a whole array. You can use a nested loop to assign to each array element individually. diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dcc-function-variable-clash.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dcc-function-variable-clash.txt new file mode 100644 index 0000000..b14c286 --- /dev/null +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dcc-function-variable-clash.txt @@ -0,0 +1,7 @@ +tests/extracted_compile_time_tests/dcc-function-variable-clash.c:4:13: error: called object type 'int' is not a function or function pointer + return main(); + ~~~~^ +dcc explanation: 'main' is the name of a variable but you are trying to call it as a function. + If 'main' is also the name of a function, you can avoid the clash, + by changing the name of the variable 'main' to something else. + See more information here: https://comp1511unsw.github.io/dcc/dcc-function-variable-clash.html diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dcc-uninitialized-local-variable.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dcc-uninitialized-local-variable.txt index 929afc9..4393267 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dcc-uninitialized-local-variable.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dcc-uninitialized-local-variable.txt @@ -1,10 +1,6 @@ -tests/extracted_compile_time_tests/dcc-uninitialized-local-variable.c:4:9: runtime error: index 0 out of bounds for type 'int [0]' - -Execution stopped here in main() in tests/extracted_compile_time_tests/dcc-uninitialized-local-variable.c at line 4: - -int main(void) { - int a[0]; ---> return a[0]; -} - +tests/extracted_compile_time_tests/dcc-uninitialized-local-variable.c: In function ‘main’: +tests/extracted_compile_time_tests/dcc-uninitialized-local-variable.c:4:10: warning: ‘a[0]’ is used uninitialized in this function [-Wuninitialized] + return a[0]; + ~^~~ +dcc explanation: You are using the value of the variable a[0] before assigning a value to a[0]. diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_null_with_arrow.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_null_with_arrow.txt new file mode 100644 index 0000000..0530354 --- /dev/null +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_null_with_arrow.txt @@ -0,0 +1,13 @@ +tests/run_time/dereference_null_with_arrow.c:8:8: runtime error: member access within null pointer of type 'struct list_node' + +Execution stopped here in main() in tests/run_time/dereference_null_with_arrow.c at line 8: + +int main(void) { + struct list_node *a = NULL; +--> a->data = 42; +} + +Values when execution stopped: + +a = + diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_null_with_arrow_arrow.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_null_with_arrow_arrow.txt new file mode 100644 index 0000000..33f8b26 --- /dev/null +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_null_with_arrow_arrow.txt @@ -0,0 +1,14 @@ +tests/run_time/dereference_null_with_arrow_arrow.c:9:14: runtime error: member access within null pointer of type 'struct list_node' + +Execution stopped here in main() in tests/run_time/dereference_null_with_arrow_arrow.c at line 9: + + struct list_node s = {0}; + struct list_node *a = &s; +--> a->next->next->data = 42; +} + +Values when execution stopped: + +s = {next = NULL, data = +a->next = + diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_null_with_arrow_arrow_arrow.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_null_with_arrow_arrow_arrow.txt new file mode 100644 index 0000000..f183ce7 --- /dev/null +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_null_with_arrow_arrow_arrow.txt @@ -0,0 +1,15 @@ +tests/run_time/dereference_null_with_arrow_arrow_arrow.c:10:20: runtime error: member access within null pointer of type 'struct list_node' + +Execution stopped here in main() in tests/run_time/dereference_null_with_arrow_arrow_arrow.c at line 10: + + struct list_node *a = &s1; + s1.next = &s2; +--> a->next->next->data = 42; +} + +Values when execution stopped: + +s1 = {next = 0x, data = +s2 = {next = NULL, data = +a->next->next = + diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_null.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_null_with_asterisk.txt similarity index 55% rename from tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_null.txt rename to tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_null_with_asterisk.txt index 0f8b5e8..fad0db2 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_null.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_null_with_asterisk.txt @@ -1,6 +1,6 @@ -tests/run_time/dereference_null.c:5:2: runtime error: store to null pointer of type 'int' +tests/run_time/dereference_null_with_asterisk.c:4:2: runtime error: store to null pointer of type 'int' -Execution stopped here in main() in tests/run_time/dereference_null.c at line 5: +Execution stopped here in main() in tests/run_time/dereference_null_with_asterisk.c at line 4: int main(void) { int *a = NULL; diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_null_with_index.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_null_with_index.txt new file mode 100644 index 0000000..ec4a8f0 --- /dev/null +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_null_with_index.txt @@ -0,0 +1,13 @@ +tests/run_time/dereference_null_with_index.c:4:12: runtime error: load of null pointer of type 'int' + +Execution stopped here in main() in tests/run_time/dereference_null_with_index.c at line 4: + +int main(void) { + int *a = NULL; +--> return a[0]; +} + +Values when execution stopped: + +a = + diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_uninitialized_char_star_with_asterisk.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_uninitialized_char_star_with_asterisk.txt new file mode 100644 index 0000000..b976e64 --- /dev/null +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_uninitialized_char_star_with_asterisk.txt @@ -0,0 +1,10 @@ + +Execution terminated by signal 11 +Execution stopped here in main() in tests/run_time/dereference_uninitialized_char_star_with_asterisk.c at line 4: + +int main(void) { + char **a = malloc(sizeof *a); +--> return **a; +} + + diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_arrow.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_arrow.txt new file mode 100644 index 0000000..6e13018 --- /dev/null +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_arrow.txt @@ -0,0 +1,15 @@ +tests/run_time/dereference_uninitialized_with_arrow.c:9:14: runtime error: member access within misaligned address 0x for type 'struct list_node', which requires 8 byte alignment +0x: note: pointer points here + + +Execution stopped here in main() in tests/run_time/dereference_uninitialized_with_arrow.c at line 9: + +int main(void) { + struct list_node *a = malloc(sizeof *a); +--> a->next->data = 42; +} + +Values when execution stopped: + +a->next = + diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_arrow_arrow_arrow.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_arrow_arrow_arrow.txt new file mode 100644 index 0000000..1dc57aa --- /dev/null +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_arrow_arrow_arrow.txt @@ -0,0 +1,15 @@ +tests/run_time/dereference_uninitialized_with_arrow_arrow_arrow.c:10:20: runtime error: member access within misaligned address 0x for type 'struct list_node', which requires 8 byte alignment +0x: note: pointer points here + + +Execution stopped here in main() in tests/run_time/dereference_uninitialized_with_arrow_arrow_arrow.c at line 10: + + struct list_node *a = malloc(sizeof *a); + a->next = malloc(sizeof *a); +--> a->next->next->data = 42; +} + +Values when execution stopped: + +a->next->next = + diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_asterisk.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_asterisk.txt new file mode 100644 index 0000000..871e90e --- /dev/null +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_asterisk.txt @@ -0,0 +1,12 @@ +tests/run_time/dereference_uninitialized_with_asterisk.c:4:12: runtime error: load of misaligned address 0x for type 'int', which requires 4 byte alignment +0x: note: pointer points here + + +Execution stopped here in main() in tests/run_time/dereference_uninitialized_with_asterisk.c at line 4: + +int main(void) { + int **a = malloc(sizeof *a); +--> return **a; +} + + diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_index.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_index.txt new file mode 100644 index 0000000..4edec00 --- /dev/null +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_index.txt @@ -0,0 +1,12 @@ +tests/run_time/dereference_uninitialized_with_index.c:4:12: runtime error: load of misaligned address 0x for type 'int', which requires 4 byte alignment +0x: note: pointer points here + + +Execution stopped here in main() in tests/run_time/dereference_uninitialized_with_index.c at line 4: + +int main(void) { + int **a = malloc(sizeof *a); +--> return a[0][0]; +} + + diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/double_int_literal_conversion.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/double_int_literal_conversion.txt index e929558..a8a10d8 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/double_int_literal_conversion.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/double_int_literal_conversion.txt @@ -1,5 +1,5 @@ -tests/extracted_compile_time_tests/double_int_literal_conversion.c:3:10: warning: implicit conversion from 'double' to 'int' changes value from 6.7 to 6 [-Wliteral-conversion] +tests/extracted_compile_time_tests/double_int_literal_conversion.c:3:10: warning: implicit conversion from 'double' to 'int' changes value from 6.7 to 6 [-Wliteral-conversion] int i = 6.7; - ~ ^~~ + ~ ^~~ dcc explanation: you are assigning the floating point number 6.7 to the int variable i , if this is what you want, change 6.7 to 6 diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/expression_not_assignable.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/expression_not_assignable.txt index 65b55bf..c2cc0aa 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/expression_not_assignable.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/expression_not_assignable.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/expression_not_assignable.c:3:23: error: expression is not assignable +tests/extracted_compile_time_tests/expression_not_assignable.c:3:23: error: expression is not assignable if (argc = 1 || argc = 2) { - ~~~~~~~~~ ^ + ~~~~~~~~~ ^ dcc explanation: You are using = Reminder: you use = to assign to a variable. You use == to compare values. diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/format_type_mismatch.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/format_type_mismatch.txt index bb2ca87..0a7cc95 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/format_type_mismatch.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/format_type_mismatch.txt @@ -1,14 +1,14 @@ -tests/extracted_compile_time_tests/format_type_mismatch.c:5:9: warning: missing terminating '"' character [-Winvalid-pp-token] +tests/extracted_compile_time_tests/format_type_mismatch.c:5:9: warning: missing terminating '"' character [-Winvalid-pp-token] printf("%d - ^ -tests/extracted_compile_time_tests/format_type_mismatch.c:5:9: error: expected expression -tests/extracted_compile_time_tests/format_type_mismatch.c:6:11: warning: missing terminating '"' character [-Winvalid-pp-token] + ^ +tests/extracted_compile_time_tests/format_type_mismatch.c:5:9: error: expected expression +tests/extracted_compile_time_tests/format_type_mismatch.c:6:11: warning: missing terminating '"' character [-Winvalid-pp-token] ", "hello!"); - ^ -tests/extracted_compile_time_tests/format_type_mismatch.c:7:2: error: expected '}' + ^ +tests/extracted_compile_time_tests/format_type_mismatch.c:7:2: error: expected '}' } - ^ -tests/extracted_compile_time_tests/format_type_mismatch.c:4:16: note: to match this '{' + ^ +tests/extracted_compile_time_tests/format_type_mismatch.c:4:16: note: to match this '{' int main(void) { - ^ + ^ dcc explanation: Make sure that all opening brace symbols `{` are matched with a closing brace `}`. diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/hash_define.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/hash_define.txt index 2ce23ac..3a63987 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/hash_define.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/hash_define.txt @@ -6,7 +6,8 @@ Execution stopped here in main() in tests/run_time/hash_define.c at line 10: for (i = 0; i < ARRAY_SIZE; i++) { --> a[i+argc] = i+argc; } -} + return a[0]; + Values when execution stopped: argc = diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/illegal_vla_index.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/illegal_vla_index.txt index 71349cc..5ad9fea 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/illegal_vla_index.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/illegal_vla_index.txt @@ -5,6 +5,7 @@ Execution stopped here in main() in tests/run_time/illegal_vla_index.c at line 3 int main(int argc, char **argv) { int a[600+argc]; --> a[1000] = argc; + return a[1000]; } Values when execution stopped: diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/implicit_function_declaration.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/implicit_function_declaration.txt index dc96660..4c3f690 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/implicit_function_declaration.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/implicit_function_declaration.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/implicit_function_declaration.c:3:2: warning: implicit declaration of function 'f' is invalid in C99 [-Wimplicit-function-declaration] +tests/extracted_compile_time_tests/implicit_function_declaration.c:3:2: warning: implicit declaration of function 'f' is invalid in C99 [-Wimplicit-function-declaration] f(); - ^ + ^ dcc explanation: you are calling a function named f line 3 of tests/extracted_compile_time_tests/implicit_function_declaration.c but dcc does not recognize f as a function. There are several possible causes: a) You might have misspelt the function name. @@ -9,4 +9,4 @@ There are several possible causes: undefined reference to `f' -clang: error: linker command failed with exit code 1 (use -v to see invocation) +clang: error: linker command failed with exit code 1 (use -v to see invocation) diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/incremental_compilation.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/incremental_compilation.txt new file mode 100644 index 0000000..d44a7eb --- /dev/null +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/incremental_compilation.txt @@ -0,0 +1,2 @@ +incremental compilation works +incremental compilation works diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/leak_valgrind--valgrind#--leak-check.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/leak_valgrind--valgrind#--leak-check.txt deleted file mode 100644 index 8e6a2aa..0000000 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/leak_valgrind--valgrind#--leak-check.txt +++ /dev/null @@ -1,2 +0,0 @@ -clang: error: unsupported option '--valgrind#--leak-check' - diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/leak_valgrind--valgrind_--leak-check.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/leak_valgrind--valgrind_--leak-check.txt new file mode 100644 index 0000000..3805d19 --- /dev/null +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/leak_valgrind--valgrind_--leak-check.txt @@ -0,0 +1 @@ +Error: free not called for memory allocated with malloc in function main in leak_valgrind.c at line 6. diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/main_wrong_type.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/main_wrong_type.txt index 6b09fce..c12a4a7 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/main_wrong_type.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/main_wrong_type.txt @@ -1,5 +1,5 @@ -tests/compile_time/main_wrong_type.c:1:5: error: second parameter of 'main' (argument array) must be of type 'char **' +tests/compile_time/main_wrong_type.c:1:5: error: second parameter of 'main' (argument array) must be of type 'char **' int main(int argc, int argv[]) { - ^ + ^ dcc explanation: Looks like your declaration of `main` isn't quite right. Be sure its second parameter is `char *argv[]` or some equivalent! diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/missing_library_include.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/missing_library_include.txt index b178b83..0a460ac 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/missing_library_include.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/missing_library_include.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/missing_library_include.c:3:2: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)' [-Wimplicit-function-declaration] +tests/extracted_compile_time_tests/missing_library_include.c:3:2: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)' [-Wimplicit-function-declaration] printf("hello"); - ^ + ^ dcc explanation: You are calling the function printf on line 3 of tests/extracted_compile_time_tests/missing_library_include.c but dcc does not recognize printf as a function because you have forgotten to #include diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/missing_semicolon_line_before_assert.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/missing_semicolon_line_before_assert.txt index 7143dd9..7fa5017 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/missing_semicolon_line_before_assert.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/missing_semicolon_line_before_assert.txt @@ -1,7 +1,7 @@ -tests/extracted_compile_time_tests/missing_semicolon_line_before_assert.c:6:2: error: called object type 'int' is not a function or function pointer +tests/extracted_compile_time_tests/missing_semicolon_line_before_assert.c:6:2: error: called object type 'int' is not a function or function pointer assert(i == 10); - ^ -/usr/include/assert.h:108:3: note: expanded from macro 'assert' + ^ + expanded from macro 'assert' ((void) sizeof ((expr) ? 1 : 0), __extension__ ({ \ - ^ + ^ dcc explanation: there is probably a syntax error such as missing semi-colon on line 5 of tests/extracted_compile_time_tests/missing_semicolon_line_before_assert.c or an earlier line diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/misspelt_printf.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/misspelt_printf.txt index be0ded3..0ec6788 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/misspelt_printf.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/misspelt_printf.txt @@ -1,9 +1,9 @@ -tests/extracted_compile_time_tests/misspelt_printf.c:4:2: warning: implicit declaration of function 'print' is invalid in C99 [-Wimplicit-function-declaration] +tests/extracted_compile_time_tests/misspelt_printf.c:4:2: warning: implicit declaration of function 'print' is invalid in C99 [-Wimplicit-function-declaration] print("hello"); - ^ + ^ dcc explanation: you are calling a function named print on line 4 of tests/extracted_compile_time_tests/misspelt_printf.c but dcc does not recognize print as a function. Maybe you meant printf? undefined reference to `print' -clang: error: linker command failed with exit code 1 (use -v to see invocation) +clang: error: linker command failed with exit code 1 (use -v to see invocation) diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/no_main_function.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/no_main_function.txt index 6d5fa91..1c0b7ca 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/no_main_function.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/no_main_function.txt @@ -1,5 +1,5 @@ undefined reference to `main' -clang: error: linker command failed with exit code 1 (use -v to see invocation) +clang: error: linker command failed with exit code 1 (use -v to see invocation) dcc explanation: Your program does not contain a main function - a C program must contain a main function. diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/printf_int_string_mismatch.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/printf_int_string_mismatch.txt index 380307f..5742fbb 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/printf_int_string_mismatch.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/printf_int_string_mismatch.txt @@ -1,6 +1,6 @@ -tests/compile_time/printf_int_string_mismatch.c:4:17: warning: format specifies type 'int' but the argument has type 'char *' [-Wformat] +tests/compile_time/printf_int_string_mismatch.c:4:17: warning: format specifies type 'int' but the argument has type 'char *' [-Wformat] printf("%d\n", "hello!"); - ~~ ^~~~~~~~ - %s + ~~ ^~~~~~~~ + %s dcc explanation: make sure you are using the correct format code (e.g., `%d` for integers, `%lf` for floating-point values) in your format string on line 4 diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/relational_expression_with_comma.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/relational_expression_with_comma.txt index bb6fdad..902a595 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/relational_expression_with_comma.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/relational_expression_with_comma.txt @@ -1,5 +1,5 @@ -tests/compile_time/relational_expression_with_comma.c:2:11: warning: relational comparison result unused [-Wunused-comparison] +tests/compile_time/relational_expression_with_comma.c:2:11: warning: relational comparison result unused [-Wunused-comparison] if (argc < 1, argc < 2) - ~~~~~^~~ + ~~~~~^~~ dcc explanation: Looks like you're comparing two values on line 2 of `tests/compile_time/relational_expression_with_comma.c` but not using the result? diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/scanf_missing_ampersand.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/scanf_missing_ampersand.txt index a8e8112..303d69a 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/scanf_missing_ampersand.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/scanf_missing_ampersand.txt @@ -1,5 +1,5 @@ -tests/extracted_compile_time_tests/scanf_missing_ampersand.c:6:14: warning: format specifies type 'int *' but the argument has type 'int' [-Wformat] +tests/extracted_compile_time_tests/scanf_missing_ampersand.c:6:14: warning: format specifies type 'int *' but the argument has type 'int' [-Wformat] scanf("%d", i); - ~~ ^ + ~~ ^ dcc explanation: Perhaps you have forgotten an '&' before 'i' on line 6. diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/stack_use_after_return.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/stack_use_after_return.txt index cf22e68..f68c42b 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/stack_use_after_return.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/stack_use_after_return.txt @@ -1,5 +1,5 @@ -tests/extracted_compile_time_tests/stack_use_after_return.c: In function ‘main’: -tests/extracted_compile_time_tests/stack_use_after_return.c:4:9: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] - return (int)&i; - ^ +tests/extracted_compile_time_tests/stack_use_after_return.c: In function ‘main’: +tests/extracted_compile_time_tests/stack_use_after_return.c:4:9: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] + return (int)&i; + ^ diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/two_main_functions.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/two_main_functions.txt index 07ac542..0b103fc 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/two_main_functions.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/two_main_functions.txt @@ -1,5 +1,5 @@ first defined here -clang: error: linker command failed with exit code 1 (use -v to see invocation) +clang: error: linker command failed with exit code 1 (use -v to see invocation) dcc explanation: Your program contains more than one main function - a C program can only contain one main function. diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/uninitialized-array-element-if--valgrind.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/uninitialized-array-element-if--valgrind.txt index 33381ad..69d2b9b 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/uninitialized-array-element-if--valgrind.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/uninitialized-array-element-if--valgrind.txt @@ -11,6 +11,7 @@ Execution stopped here in main() in tests/run_time/uninitialized-array-element-i Values when execution stopped: +a = argc = a[42] = a[43] = diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/uninitialized-array-element-printf--valgrind.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/uninitialized-array-element-printf--valgrind.txt index 9949ece..05084e9 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/uninitialized-array-element-printf--valgrind.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/uninitialized-array-element-printf--valgrind.txt @@ -10,6 +10,7 @@ Execution stopped here in main() in tests/run_time/uninitialized-array-element-p Values when execution stopped: +a = argc = a[42] = a[argc] = diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/uninitialized-array-element-sum--memory.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/uninitialized-array-element-sum--memory.txt index c7dfae2..5d2b248 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/uninitialized-array-element-sum--memory.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/uninitialized-array-element-sum--memory.txt @@ -3,7 +3,7 @@ tests/run_time/uninitialized-array-element-sum.c:9 runtime error uninitialized v Execution stopped here in main() in tests/run_time/uninitialized-array-element-sum.c at line 9: for (i = 0; i < 1000; i++) - sum += a[i]; + sum += a[i] % 2; --> if (sum < 1000) { return sum; } diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/uninitialized-array-element-sum--valgrind.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/uninitialized-array-element-sum--valgrind.txt index bcdfd2f..b7ac68a 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/uninitialized-array-element-sum--valgrind.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/uninitialized-array-element-sum--valgrind.txt @@ -5,12 +5,13 @@ Execution stopped here in main() in tests/run_time/uninitialized-array-element-s a[42] = 42; for (i = 0; i < 1000; i++) ---> sum += a[i]; +--> sum += a[i] % 2; if (sum < 1000) { return sum; Values when execution stopped: +a = i = sum = a[42] = diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/uninitialized_local_variable.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/uninitialized_local_variable.txt index b01a8a3..be95379 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/uninitialized_local_variable.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/uninitialized_local_variable.txt @@ -1,14 +1,14 @@ -tests/compile_time/uninitialized_local_variable.c:5:13: warning: variable 's' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] +tests/compile_time/uninitialized_local_variable.c:5:13: warning: variable 's' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] else if (argc < 2) - ^~~~~~~~ -tests/compile_time/uninitialized_local_variable.c:8:9: note: uninitialized use occurs here + ^~~~~~~~ +tests/compile_time/uninitialized_local_variable.c:8:9: note: uninitialized use occurs here return s; - ^ -tests/compile_time/uninitialized_local_variable.c:5:9: note: remove the 'if' if its condition is always true + ^ +tests/compile_time/uninitialized_local_variable.c:5:9: note: remove the 'if' if its condition is always true else if (argc < 2) - ^~~~~~~~~~~~~ -tests/compile_time/uninitialized_local_variable.c:2:7: note: initialize the variable 's' to silence this warning + ^~~~~~~~~~~~~ +tests/compile_time/uninitialized_local_variable.c:2:7: note: initialize the variable 's' to silence this warning int s; - ^ - = 0 + ^ + = 0 diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/variable_used_in_own_initialization.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/variable_used_in_own_initialization.txt index 7a1e50a..0d03238 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/variable_used_in_own_initialization.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/variable_used_in_own_initialization.txt @@ -1,6 +1,6 @@ -tests/compile_time/variable_used_in_own_initialization.c:2:10: warning: variable 'x' is uninitialized when used within its own initialization [-Wuninitialized] +tests/compile_time/variable_used_in_own_initialization.c:2:10: warning: variable 'x' is uninitialized when used within its own initialization [-Wuninitialized] int x = x + 1; - ~ ^ + ~ ^ dcc explanation: Looks like you have `x` on both the left- and right-hand side of the `=` on line 2 of `tests/compile_time/variable_used_in_own_initialization.c`, but `x` doesn't yet have a value. Be sure not to initialize `x` with itself. diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/write_null_stream.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/write_null_stream.txt index 3f39588..e4a51a9 100644 --- a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/write_null_stream.txt +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/write_null_stream.txt @@ -1,5 +1,5 @@ -tests/run_time/write_null_stream.c: In function ‘main’: -tests/run_time/write_null_stream.c:4:2: warning: null argument where non-null required (argument 1) [-Wnonnull] - fprintf(NULL, "Hello world\n"); - ^~~~~~~ +tests/run_time/write_null_stream.c: In function ‘main’: +tests/run_time/write_null_stream.c:4:2: warning: null argument where non-null required (argument 1) [-Wnonnull] + fprintf(NULL, "Hello world\n"); + ^~~~~~~ diff --git a/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/zero_size_array.txt b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/zero_size_array.txt new file mode 100644 index 0000000..4e40b51 --- /dev/null +++ b/tests/expected_output/clang-6.0-x86_64-pc-linux-gnu/zero_size_array.txt @@ -0,0 +1,10 @@ +tests/run_time/zero_size_array.c:3:8: runtime error: index 0 out of bounds for type 'int [0]' + +Execution stopped here in main() in tests/run_time/zero_size_array.c at line 3: + +int main(void) { + int a[0]; +-->return a[0]; +} + + diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/add_int_to_string.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/add_int_to_string.txt index d4529f9..7a55406 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/add_int_to_string.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/add_int_to_string.txt @@ -1,10 +1,10 @@ -tests/compile_time/add_int_to_string.c:4:17: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int] +tests/compile_time/add_int_to_string.c:4:17: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int] printf("hello" + argc); - ~~~~~~~~^~~~~~ -tests/compile_time/add_int_to_string.c:4:17: note: use array indexing to silence this warning + ~~~~~~~~^~~~~~ +tests/compile_time/add_int_to_string.c:4:17: note: use array indexing to silence this warning printf("hello" + argc); - ^ - & [ ] + ^ + & [ ] dcc explanation: Careful, you can't concatenate values and strings in C using the `+` operator, as you seem to be trying to do on line 4 of `tests/compile_time/add_int_to_string.c`. Odds are you want to provide `printf` with a format code for that value and pass that value to `printf` as an argument. diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/array_static_illegal_index.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/array_static_illegal_index.txt index 4df6927..6c57383 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/array_static_illegal_index.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/array_static_illegal_index.txt @@ -1,9 +1,9 @@ -tests/compile_time/array_static_illegal_index.c:3:2: warning: array index 5 is past the end of the array (which contains 5 elements) [-Warray-bounds] +tests/compile_time/array_static_illegal_index.c:3:2: warning: array index 5 is past the end of the array (which contains 5 elements) [-Warray-bounds] a[5] = 0; - ^ ~ -tests/compile_time/array_static_illegal_index.c:2:2: note: array 'a' declared here + ^ ~ +tests/compile_time/array_static_illegal_index.c:2:2: note: array 'a' declared here int a[5]; - ^ + ^ dcc explanation: Careful, on line 3 of `tests/compile_time/array_static_illegal_index.c`, it looks like you're trying to access location 5 of `a`, which doesn't exist; `a` isn't that long. Keep in mind that arrays are 0-indexed. diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/array_string_index.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/array_string_index.txt index 032d25a..d6a80e1 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/array_string_index.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/array_string_index.txt @@ -1,6 +1,6 @@ -tests/compile_time/array_string_index.c:3:3: error: array subscript is not an integer +tests/compile_time/array_string_index.c:3:3: error: array subscript is not an integer a["0"] = 0; - ^~~~ + ^~~~ dcc explanation: Looks like you're trying to access an element of the array `a` on line 3 of `tests/compile_time/array_string_index.c`, but your index (`"0"`) is not of type `int`. Right now, your index is of type `string` instead. Make sure your index (the value between square brackets) is an `int`. diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assert_without_closing_parenthesis.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assert_without_closing_parenthesis.txt index 79e6381..46274ec 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assert_without_closing_parenthesis.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assert_without_closing_parenthesis.txt @@ -1,4 +1,4 @@ -tests/extracted_compile_time_tests/assert_without_closing_parenthesis.c:5:2: error: unterminated function-like macro invocation +tests/extracted_compile_time_tests/assert_without_closing_parenthesis.c:5:2: error: unterminated function-like macro invocation assert(argc == 1; - ^ + ^ dcc explanation: it looks like there is a missing closing bracket on the assert on line 5 of tests/extracted_compile_time_tests/assert_without_closing_parenthesis.c diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assign_array_to_int.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assign_array_to_int.txt index 4b980e4..7d1d337 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assign_array_to_int.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assign_array_to_int.txt @@ -1,5 +1,5 @@ -tests/extracted_compile_time_tests/assign_array_to_int.c:4:10: warning: incompatible pointer to integer conversion assigning to 'int' from 'int [3]' [-Wint-conversion] +tests/extracted_compile_time_tests/assign_array_to_int.c:4:10: warning: incompatible pointer to integer conversion assigning to 'int' from 'int [3]' [-Wint-conversion] a[0][0] = a[1]; - ^ ~~~~ + ^ ~~~~ dcc explanation: you are attempting to assign a[1] which is an array to an int variable. diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assign_function_to_int.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assign_function_to_int.txt index 80f0a01..40c5492 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assign_function_to_int.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assign_function_to_int.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/assign_function_to_int.c:3:6: warning: incompatible pointer to integer conversion initializing 'int' with an expression of type 'int (int, char **)' [-Wint-conversion] +tests/extracted_compile_time_tests/assign_function_to_int.c:3:6: warning: incompatible pointer to integer conversion initializing 'int' with an expression of type 'int (int, char **)' [-Wint-conversion] int a = main; - ^ ~~~~ + ^ ~~~~ dcc explanation: you are attempting to assign main which is a function to an int variable. Perhaps you are trying to call the function and have forgotten the round brackets and any parameter values. See more information here: https://comp1511unsw.github.io/dcc/assign_function_to_int.html diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assign_pointer_to_int.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assign_pointer_to_int.txt index 9d40b18..d6d56f4 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assign_pointer_to_int.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assign_pointer_to_int.txt @@ -1,5 +1,5 @@ -tests/extracted_compile_time_tests/assign_pointer_to_int.c:4:4: warning: incompatible pointer to integer conversion assigning to 'int' from 'int *'; remove & [-Wint-conversion] +tests/extracted_compile_time_tests/assign_pointer_to_int.c:4:4: warning: incompatible pointer to integer conversion assigning to 'int' from 'int *'; remove & [-Wint-conversion] a = &a; - ^ ~~ + ^ ~~ dcc explanation: you are attempting to assign &a which is not an int to an int variable. diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assign_to_array.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assign_to_array.txt index d154e58..e946f75 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assign_to_array.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assign_to_array.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/assign_to_array.c:4:4: error: array type 'int [1]' is not assignable +tests/extracted_compile_time_tests/assign_to_array.c:4:4: error: array type 'int [1]' is not assignable a = b; - ~ ^ + ~ ^ dcc explanation: you are trying to assign to 'a' which is an array with 1 element. You can not assign to a whole array. You can use a loop to assign to each array element individually. diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assign_to_multidimensional_array.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assign_to_multidimensional_array.txt index 5ca6087..c230d82 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assign_to_multidimensional_array.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/assign_to_multidimensional_array.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/assign_to_multidimensional_array.c:4:4: error: array type 'int [3][1]' is not assignable +tests/extracted_compile_time_tests/assign_to_multidimensional_array.c:4:4: error: array type 'int [3][1]' is not assignable a = b; - ~ ^ + ~ ^ dcc explanation: you are trying to assign to 'a' which is an array. You can not assign to a whole array. You can use a nested loop to assign to each array element individually. diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/dcc-function-variable-clash.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/dcc-function-variable-clash.txt index e002be5..b14c286 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/dcc-function-variable-clash.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/dcc-function-variable-clash.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/dcc-function-variable-clash.c:4:13: error: called object type 'int' is not a function or function pointer +tests/extracted_compile_time_tests/dcc-function-variable-clash.c:4:13: error: called object type 'int' is not a function or function pointer return main(); - ~~~~^ + ~~~~^ dcc explanation: 'main' is the name of a variable but you are trying to call it as a function. If 'main' is also the name of a function, you can avoid the clash, by changing the name of the variable 'main' to something else. diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/dcc-uninitialized-local-variable.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/dcc-uninitialized-local-variable.txt index 46452e1..4393267 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/dcc-uninitialized-local-variable.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/dcc-uninitialized-local-variable.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/dcc-uninitialized-local-variable.c: In function ‘main’: -tests/extracted_compile_time_tests/dcc-uninitialized-local-variable.c:4:10: warning: ‘a[0]’ is used uninitialized in this function [-Wuninitialized] - return a[0]; - ~^~~ +tests/extracted_compile_time_tests/dcc-uninitialized-local-variable.c: In function ‘main’: +tests/extracted_compile_time_tests/dcc-uninitialized-local-variable.c:4:10: warning: ‘a[0]’ is used uninitialized in this function [-Wuninitialized] + return a[0]; + ~^~~ dcc explanation: You are using the value of the variable a[0] before assigning a value to a[0]. diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/dereference_null.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/dereference_null.txt deleted file mode 100644 index d787cfb..0000000 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/dereference_null.txt +++ /dev/null @@ -1,12 +0,0 @@ -tests/run_time/dereference_null.c:4:2: runtime error: store to null pointer of type 'int' - -Execution stopped here in main() in tests/run_time/dereference_null.c at line 4: - -int main(void) { - int *a = NULL; ---> *a = 42; -} -Values when execution stopped: - -a = - diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/dereference_uninitialized.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/dereference_uninitialized.txt deleted file mode 100644 index 0eee4ed..0000000 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/dereference_uninitialized.txt +++ /dev/null @@ -1,12 +0,0 @@ -tests/run_time/dereference_uninitialized.c:9:14: runtime error: member access within misaligned address 0x for type 'struct list_node', which requires 8 byte alignment -0x: note: pointer points here - - -Execution stopped here in main() in tests/run_time/dereference_uninitialized.c at line 9: - -int main(void) { - struct list_node *a = malloc(sizeof *a); ---> a->next->data = 42; -} - - diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/double_int_literal_conversion.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/double_int_literal_conversion.txt index e929558..a8a10d8 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/double_int_literal_conversion.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/double_int_literal_conversion.txt @@ -1,5 +1,5 @@ -tests/extracted_compile_time_tests/double_int_literal_conversion.c:3:10: warning: implicit conversion from 'double' to 'int' changes value from 6.7 to 6 [-Wliteral-conversion] +tests/extracted_compile_time_tests/double_int_literal_conversion.c:3:10: warning: implicit conversion from 'double' to 'int' changes value from 6.7 to 6 [-Wliteral-conversion] int i = 6.7; - ~ ^~~ + ~ ^~~ dcc explanation: you are assigning the floating point number 6.7 to the int variable i , if this is what you want, change 6.7 to 6 diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/expression_not_assignable.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/expression_not_assignable.txt index 65b55bf..c2cc0aa 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/expression_not_assignable.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/expression_not_assignable.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/expression_not_assignable.c:3:23: error: expression is not assignable +tests/extracted_compile_time_tests/expression_not_assignable.c:3:23: error: expression is not assignable if (argc = 1 || argc = 2) { - ~~~~~~~~~ ^ + ~~~~~~~~~ ^ dcc explanation: You are using = Reminder: you use = to assign to a variable. You use == to compare values. diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/format_type_mismatch.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/format_type_mismatch.txt index bb2ca87..0a7cc95 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/format_type_mismatch.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/format_type_mismatch.txt @@ -1,14 +1,14 @@ -tests/extracted_compile_time_tests/format_type_mismatch.c:5:9: warning: missing terminating '"' character [-Winvalid-pp-token] +tests/extracted_compile_time_tests/format_type_mismatch.c:5:9: warning: missing terminating '"' character [-Winvalid-pp-token] printf("%d - ^ -tests/extracted_compile_time_tests/format_type_mismatch.c:5:9: error: expected expression -tests/extracted_compile_time_tests/format_type_mismatch.c:6:11: warning: missing terminating '"' character [-Winvalid-pp-token] + ^ +tests/extracted_compile_time_tests/format_type_mismatch.c:5:9: error: expected expression +tests/extracted_compile_time_tests/format_type_mismatch.c:6:11: warning: missing terminating '"' character [-Winvalid-pp-token] ", "hello!"); - ^ -tests/extracted_compile_time_tests/format_type_mismatch.c:7:2: error: expected '}' + ^ +tests/extracted_compile_time_tests/format_type_mismatch.c:7:2: error: expected '}' } - ^ -tests/extracted_compile_time_tests/format_type_mismatch.c:4:16: note: to match this '{' + ^ +tests/extracted_compile_time_tests/format_type_mismatch.c:4:16: note: to match this '{' int main(void) { - ^ + ^ dcc explanation: Make sure that all opening brace symbols `{` are matched with a closing brace `}`. diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/implicit_function_declaration.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/implicit_function_declaration.txt index dc96660..4c3f690 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/implicit_function_declaration.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/implicit_function_declaration.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/implicit_function_declaration.c:3:2: warning: implicit declaration of function 'f' is invalid in C99 [-Wimplicit-function-declaration] +tests/extracted_compile_time_tests/implicit_function_declaration.c:3:2: warning: implicit declaration of function 'f' is invalid in C99 [-Wimplicit-function-declaration] f(); - ^ + ^ dcc explanation: you are calling a function named f line 3 of tests/extracted_compile_time_tests/implicit_function_declaration.c but dcc does not recognize f as a function. There are several possible causes: a) You might have misspelt the function name. @@ -9,4 +9,4 @@ There are several possible causes: undefined reference to `f' -clang: error: linker command failed with exit code 1 (use -v to see invocation) +clang: error: linker command failed with exit code 1 (use -v to see invocation) diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/leak_valgrind--valgrind#--leak-check.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/leak_valgrind--valgrind#--leak-check.txt deleted file mode 100644 index 8e6a2aa..0000000 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/leak_valgrind--valgrind#--leak-check.txt +++ /dev/null @@ -1,2 +0,0 @@ -clang: error: unsupported option '--valgrind#--leak-check' - diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/leak_valgrind--valgrind_--leak-check.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/leak_valgrind--valgrind_--leak-check.txt new file mode 100644 index 0000000..3805d19 --- /dev/null +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/leak_valgrind--valgrind_--leak-check.txt @@ -0,0 +1 @@ +Error: free not called for memory allocated with malloc in function main in leak_valgrind.c at line 6. diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/main_wrong_type.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/main_wrong_type.txt index 6b09fce..c12a4a7 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/main_wrong_type.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/main_wrong_type.txt @@ -1,5 +1,5 @@ -tests/compile_time/main_wrong_type.c:1:5: error: second parameter of 'main' (argument array) must be of type 'char **' +tests/compile_time/main_wrong_type.c:1:5: error: second parameter of 'main' (argument array) must be of type 'char **' int main(int argc, int argv[]) { - ^ + ^ dcc explanation: Looks like your declaration of `main` isn't quite right. Be sure its second parameter is `char *argv[]` or some equivalent! diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/missing_library_include.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/missing_library_include.txt index b178b83..0a460ac 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/missing_library_include.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/missing_library_include.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/missing_library_include.c:3:2: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)' [-Wimplicit-function-declaration] +tests/extracted_compile_time_tests/missing_library_include.c:3:2: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)' [-Wimplicit-function-declaration] printf("hello"); - ^ + ^ dcc explanation: You are calling the function printf on line 3 of tests/extracted_compile_time_tests/missing_library_include.c but dcc does not recognize printf as a function because you have forgotten to #include diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/missing_semicolon_line_before_assert.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/missing_semicolon_line_before_assert.txt index 7143dd9..7fa5017 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/missing_semicolon_line_before_assert.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/missing_semicolon_line_before_assert.txt @@ -1,7 +1,7 @@ -tests/extracted_compile_time_tests/missing_semicolon_line_before_assert.c:6:2: error: called object type 'int' is not a function or function pointer +tests/extracted_compile_time_tests/missing_semicolon_line_before_assert.c:6:2: error: called object type 'int' is not a function or function pointer assert(i == 10); - ^ -/usr/include/assert.h:108:3: note: expanded from macro 'assert' + ^ + expanded from macro 'assert' ((void) sizeof ((expr) ? 1 : 0), __extension__ ({ \ - ^ + ^ dcc explanation: there is probably a syntax error such as missing semi-colon on line 5 of tests/extracted_compile_time_tests/missing_semicolon_line_before_assert.c or an earlier line diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/misspelt_printf.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/misspelt_printf.txt index be0ded3..0ec6788 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/misspelt_printf.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/misspelt_printf.txt @@ -1,9 +1,9 @@ -tests/extracted_compile_time_tests/misspelt_printf.c:4:2: warning: implicit declaration of function 'print' is invalid in C99 [-Wimplicit-function-declaration] +tests/extracted_compile_time_tests/misspelt_printf.c:4:2: warning: implicit declaration of function 'print' is invalid in C99 [-Wimplicit-function-declaration] print("hello"); - ^ + ^ dcc explanation: you are calling a function named print on line 4 of tests/extracted_compile_time_tests/misspelt_printf.c but dcc does not recognize print as a function. Maybe you meant printf? undefined reference to `print' -clang: error: linker command failed with exit code 1 (use -v to see invocation) +clang: error: linker command failed with exit code 1 (use -v to see invocation) diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/no_main_function.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/no_main_function.txt index 6d5fa91..1c0b7ca 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/no_main_function.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/no_main_function.txt @@ -1,5 +1,5 @@ undefined reference to `main' -clang: error: linker command failed with exit code 1 (use -v to see invocation) +clang: error: linker command failed with exit code 1 (use -v to see invocation) dcc explanation: Your program does not contain a main function - a C program must contain a main function. diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/printf_int_string_mismatch.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/printf_int_string_mismatch.txt index 380307f..5742fbb 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/printf_int_string_mismatch.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/printf_int_string_mismatch.txt @@ -1,6 +1,6 @@ -tests/compile_time/printf_int_string_mismatch.c:4:17: warning: format specifies type 'int' but the argument has type 'char *' [-Wformat] +tests/compile_time/printf_int_string_mismatch.c:4:17: warning: format specifies type 'int' but the argument has type 'char *' [-Wformat] printf("%d\n", "hello!"); - ~~ ^~~~~~~~ - %s + ~~ ^~~~~~~~ + %s dcc explanation: make sure you are using the correct format code (e.g., `%d` for integers, `%lf` for floating-point values) in your format string on line 4 diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/relational_expression_with_comma.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/relational_expression_with_comma.txt index bb6fdad..902a595 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/relational_expression_with_comma.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/relational_expression_with_comma.txt @@ -1,5 +1,5 @@ -tests/compile_time/relational_expression_with_comma.c:2:11: warning: relational comparison result unused [-Wunused-comparison] +tests/compile_time/relational_expression_with_comma.c:2:11: warning: relational comparison result unused [-Wunused-comparison] if (argc < 1, argc < 2) - ~~~~~^~~ + ~~~~~^~~ dcc explanation: Looks like you're comparing two values on line 2 of `tests/compile_time/relational_expression_with_comma.c` but not using the result? diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/scanf_missing_ampersand.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/scanf_missing_ampersand.txt index a8e8112..303d69a 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/scanf_missing_ampersand.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/scanf_missing_ampersand.txt @@ -1,5 +1,5 @@ -tests/extracted_compile_time_tests/scanf_missing_ampersand.c:6:14: warning: format specifies type 'int *' but the argument has type 'int' [-Wformat] +tests/extracted_compile_time_tests/scanf_missing_ampersand.c:6:14: warning: format specifies type 'int *' but the argument has type 'int' [-Wformat] scanf("%d", i); - ~~ ^ + ~~ ^ dcc explanation: Perhaps you have forgotten an '&' before 'i' on line 6. diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/stack_use_after_return.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/stack_use_after_return.txt index 55953c3..0490831 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/stack_use_after_return.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/stack_use_after_return.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/stack_use_after_return.c:4:15: warning: address of stack memory associated with local variable 'i' returned [-Wreturn-stack-address] +tests/extracted_compile_time_tests/stack_use_after_return.c:4:15: warning: address of stack memory associated with local variable 'i' returned [-Wreturn-stack-address] return (int)&i; - ^ + ^ dcc explanation: you are trying to return a pointer to the local variable 'i'. You can not do this because i will not exist after the function returns. See more information here: https://comp1511unsw.github.io/dcc/stack_use_after_return.html diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/two_main_functions.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/two_main_functions.txt index 07ac542..0b103fc 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/two_main_functions.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/two_main_functions.txt @@ -1,5 +1,5 @@ first defined here -clang: error: linker command failed with exit code 1 (use -v to see invocation) +clang: error: linker command failed with exit code 1 (use -v to see invocation) dcc explanation: Your program contains more than one main function - a C program can only contain one main function. diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/uninitialized-array-element-if.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/uninitialized-array-element-if.txt deleted file mode 100644 index 1bf8c87..0000000 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/uninitialized-array-element-if.txt +++ /dev/null @@ -1 +0,0 @@ -tests/do_tests.sh: line 55: ./a.out: No such file or directory diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/uninitialized_local_variable.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/uninitialized_local_variable.txt index b01a8a3..be95379 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/uninitialized_local_variable.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/uninitialized_local_variable.txt @@ -1,14 +1,14 @@ -tests/compile_time/uninitialized_local_variable.c:5:13: warning: variable 's' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] +tests/compile_time/uninitialized_local_variable.c:5:13: warning: variable 's' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] else if (argc < 2) - ^~~~~~~~ -tests/compile_time/uninitialized_local_variable.c:8:9: note: uninitialized use occurs here + ^~~~~~~~ +tests/compile_time/uninitialized_local_variable.c:8:9: note: uninitialized use occurs here return s; - ^ -tests/compile_time/uninitialized_local_variable.c:5:9: note: remove the 'if' if its condition is always true + ^ +tests/compile_time/uninitialized_local_variable.c:5:9: note: remove the 'if' if its condition is always true else if (argc < 2) - ^~~~~~~~~~~~~ -tests/compile_time/uninitialized_local_variable.c:2:7: note: initialize the variable 's' to silence this warning + ^~~~~~~~~~~~~ +tests/compile_time/uninitialized_local_variable.c:2:7: note: initialize the variable 's' to silence this warning int s; - ^ - = 0 + ^ + = 0 diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/variable_used_in_own_initialization.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/variable_used_in_own_initialization.txt index 7a1e50a..0d03238 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/variable_used_in_own_initialization.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/variable_used_in_own_initialization.txt @@ -1,6 +1,6 @@ -tests/compile_time/variable_used_in_own_initialization.c:2:10: warning: variable 'x' is uninitialized when used within its own initialization [-Wuninitialized] +tests/compile_time/variable_used_in_own_initialization.c:2:10: warning: variable 'x' is uninitialized when used within its own initialization [-Wuninitialized] int x = x + 1; - ~ ^ + ~ ^ dcc explanation: Looks like you have `x` on both the left- and right-hand side of the `=` on line 2 of `tests/compile_time/variable_used_in_own_initialization.c`, but `x` doesn't yet have a value. Be sure not to initialize `x` with itself. diff --git a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/write_null_stream.txt b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/write_null_stream.txt index 3f39588..e4a51a9 100644 --- a/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/write_null_stream.txt +++ b/tests/expected_output/clang-7.0-x86_64-pc-linux-gnu/write_null_stream.txt @@ -1,5 +1,5 @@ -tests/run_time/write_null_stream.c: In function ‘main’: -tests/run_time/write_null_stream.c:4:2: warning: null argument where non-null required (argument 1) [-Wnonnull] - fprintf(NULL, "Hello world\n"); - ^~~~~~~ +tests/run_time/write_null_stream.c: In function ‘main’: +tests/run_time/write_null_stream.c:4:2: warning: null argument where non-null required (argument 1) [-Wnonnull] + fprintf(NULL, "Hello world\n"); + ^~~~~~~ diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/add_int_to_string.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/add_int_to_string.txt index d4529f9..7a55406 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/add_int_to_string.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/add_int_to_string.txt @@ -1,10 +1,10 @@ -tests/compile_time/add_int_to_string.c:4:17: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int] +tests/compile_time/add_int_to_string.c:4:17: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int] printf("hello" + argc); - ~~~~~~~~^~~~~~ -tests/compile_time/add_int_to_string.c:4:17: note: use array indexing to silence this warning + ~~~~~~~~^~~~~~ +tests/compile_time/add_int_to_string.c:4:17: note: use array indexing to silence this warning printf("hello" + argc); - ^ - & [ ] + ^ + & [ ] dcc explanation: Careful, you can't concatenate values and strings in C using the `+` operator, as you seem to be trying to do on line 4 of `tests/compile_time/add_int_to_string.c`. Odds are you want to provide `printf` with a format code for that value and pass that value to `printf` as an argument. diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/array_static_illegal_index.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/array_static_illegal_index.txt index 4df6927..6c57383 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/array_static_illegal_index.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/array_static_illegal_index.txt @@ -1,9 +1,9 @@ -tests/compile_time/array_static_illegal_index.c:3:2: warning: array index 5 is past the end of the array (which contains 5 elements) [-Warray-bounds] +tests/compile_time/array_static_illegal_index.c:3:2: warning: array index 5 is past the end of the array (which contains 5 elements) [-Warray-bounds] a[5] = 0; - ^ ~ -tests/compile_time/array_static_illegal_index.c:2:2: note: array 'a' declared here + ^ ~ +tests/compile_time/array_static_illegal_index.c:2:2: note: array 'a' declared here int a[5]; - ^ + ^ dcc explanation: Careful, on line 3 of `tests/compile_time/array_static_illegal_index.c`, it looks like you're trying to access location 5 of `a`, which doesn't exist; `a` isn't that long. Keep in mind that arrays are 0-indexed. diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/array_string_index.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/array_string_index.txt index 032d25a..d6a80e1 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/array_string_index.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/array_string_index.txt @@ -1,6 +1,6 @@ -tests/compile_time/array_string_index.c:3:3: error: array subscript is not an integer +tests/compile_time/array_string_index.c:3:3: error: array subscript is not an integer a["0"] = 0; - ^~~~ + ^~~~ dcc explanation: Looks like you're trying to access an element of the array `a` on line 3 of `tests/compile_time/array_string_index.c`, but your index (`"0"`) is not of type `int`. Right now, your index is of type `string` instead. Make sure your index (the value between square brackets) is an `int`. diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assert_without_closing_parenthesis.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assert_without_closing_parenthesis.txt index 79e6381..46274ec 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assert_without_closing_parenthesis.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assert_without_closing_parenthesis.txt @@ -1,4 +1,4 @@ -tests/extracted_compile_time_tests/assert_without_closing_parenthesis.c:5:2: error: unterminated function-like macro invocation +tests/extracted_compile_time_tests/assert_without_closing_parenthesis.c:5:2: error: unterminated function-like macro invocation assert(argc == 1; - ^ + ^ dcc explanation: it looks like there is a missing closing bracket on the assert on line 5 of tests/extracted_compile_time_tests/assert_without_closing_parenthesis.c diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assign_array_to_int.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assign_array_to_int.txt index 4b980e4..7d1d337 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assign_array_to_int.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assign_array_to_int.txt @@ -1,5 +1,5 @@ -tests/extracted_compile_time_tests/assign_array_to_int.c:4:10: warning: incompatible pointer to integer conversion assigning to 'int' from 'int [3]' [-Wint-conversion] +tests/extracted_compile_time_tests/assign_array_to_int.c:4:10: warning: incompatible pointer to integer conversion assigning to 'int' from 'int [3]' [-Wint-conversion] a[0][0] = a[1]; - ^ ~~~~ + ^ ~~~~ dcc explanation: you are attempting to assign a[1] which is an array to an int variable. diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assign_function_to_int.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assign_function_to_int.txt index 80f0a01..40c5492 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assign_function_to_int.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assign_function_to_int.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/assign_function_to_int.c:3:6: warning: incompatible pointer to integer conversion initializing 'int' with an expression of type 'int (int, char **)' [-Wint-conversion] +tests/extracted_compile_time_tests/assign_function_to_int.c:3:6: warning: incompatible pointer to integer conversion initializing 'int' with an expression of type 'int (int, char **)' [-Wint-conversion] int a = main; - ^ ~~~~ + ^ ~~~~ dcc explanation: you are attempting to assign main which is a function to an int variable. Perhaps you are trying to call the function and have forgotten the round brackets and any parameter values. See more information here: https://comp1511unsw.github.io/dcc/assign_function_to_int.html diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assign_pointer_to_int.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assign_pointer_to_int.txt index 9d40b18..d6d56f4 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assign_pointer_to_int.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assign_pointer_to_int.txt @@ -1,5 +1,5 @@ -tests/extracted_compile_time_tests/assign_pointer_to_int.c:4:4: warning: incompatible pointer to integer conversion assigning to 'int' from 'int *'; remove & [-Wint-conversion] +tests/extracted_compile_time_tests/assign_pointer_to_int.c:4:4: warning: incompatible pointer to integer conversion assigning to 'int' from 'int *'; remove & [-Wint-conversion] a = &a; - ^ ~~ + ^ ~~ dcc explanation: you are attempting to assign &a which is not an int to an int variable. diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assign_to_array.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assign_to_array.txt index d154e58..e946f75 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assign_to_array.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assign_to_array.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/assign_to_array.c:4:4: error: array type 'int [1]' is not assignable +tests/extracted_compile_time_tests/assign_to_array.c:4:4: error: array type 'int [1]' is not assignable a = b; - ~ ^ + ~ ^ dcc explanation: you are trying to assign to 'a' which is an array with 1 element. You can not assign to a whole array. You can use a loop to assign to each array element individually. diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assign_to_multidimensional_array.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assign_to_multidimensional_array.txt index 5ca6087..c230d82 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assign_to_multidimensional_array.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/assign_to_multidimensional_array.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/assign_to_multidimensional_array.c:4:4: error: array type 'int [3][1]' is not assignable +tests/extracted_compile_time_tests/assign_to_multidimensional_array.c:4:4: error: array type 'int [3][1]' is not assignable a = b; - ~ ^ + ~ ^ dcc explanation: you are trying to assign to 'a' which is an array. You can not assign to a whole array. You can use a nested loop to assign to each array element individually. diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dcc-function-variable-clash.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dcc-function-variable-clash.txt new file mode 100644 index 0000000..b14c286 --- /dev/null +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dcc-function-variable-clash.txt @@ -0,0 +1,7 @@ +tests/extracted_compile_time_tests/dcc-function-variable-clash.c:4:13: error: called object type 'int' is not a function or function pointer + return main(); + ~~~~^ +dcc explanation: 'main' is the name of a variable but you are trying to call it as a function. + If 'main' is also the name of a function, you can avoid the clash, + by changing the name of the variable 'main' to something else. + See more information here: https://comp1511unsw.github.io/dcc/dcc-function-variable-clash.html diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dcc-uninitialized-local-variable.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dcc-uninitialized-local-variable.txt index 929afc9..4393267 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dcc-uninitialized-local-variable.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dcc-uninitialized-local-variable.txt @@ -1,10 +1,6 @@ -tests/extracted_compile_time_tests/dcc-uninitialized-local-variable.c:4:9: runtime error: index 0 out of bounds for type 'int [0]' - -Execution stopped here in main() in tests/extracted_compile_time_tests/dcc-uninitialized-local-variable.c at line 4: - -int main(void) { - int a[0]; ---> return a[0]; -} - +tests/extracted_compile_time_tests/dcc-uninitialized-local-variable.c: In function ‘main’: +tests/extracted_compile_time_tests/dcc-uninitialized-local-variable.c:4:10: warning: ‘a[0]’ is used uninitialized in this function [-Wuninitialized] + return a[0]; + ~^~~ +dcc explanation: You are using the value of the variable a[0] before assigning a value to a[0]. diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_null.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_null.txt deleted file mode 100644 index 0f8b5e8..0000000 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_null.txt +++ /dev/null @@ -1,12 +0,0 @@ -tests/run_time/dereference_null.c:5:2: runtime error: store to null pointer of type 'int' - -Execution stopped here in main() in tests/run_time/dereference_null.c at line 5: - -int main(void) { - int *a = NULL; ---> *a = 42; -} -Values when execution stopped: - -a = - diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_null_with_arrow.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_null_with_arrow.txt new file mode 100644 index 0000000..ab8be28 --- /dev/null +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_null_with_arrow.txt @@ -0,0 +1,17 @@ + +tests/run_time/dereference_null_with_arrow.c:8:8: runtime error - accessing a field via a NULL pointer + +dcc explanation: You are using a pointer which is NULL + A common error is using p->field when p == NULL. + +Execution stopped here in main() in tests/run_time/dereference_null_with_arrow.c at line 8: + +int main(void) { + struct list_node *a = NULL; +--> a->data = 42; +} + +Values when execution stopped: + +a = + diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_null_with_arrow_arrow.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_null_with_arrow_arrow.txt new file mode 100644 index 0000000..f95b4ec --- /dev/null +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_null_with_arrow_arrow.txt @@ -0,0 +1,18 @@ + +tests/run_time/dereference_null_with_arrow_arrow.c:9:14: runtime error - accessing a field via a NULL pointer + +dcc explanation: You are using a pointer which is NULL + A common error is using p->field when p == NULL. + +Execution stopped here in main() in tests/run_time/dereference_null_with_arrow_arrow.c at line 9: + + struct list_node s = {0}; + struct list_node *a = &s; +--> a->next->next->data = 42; +} + +Values when execution stopped: + +s = {next = NULL, data = +a->next = + diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_null_with_arrow_arrow_arrow.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_null_with_arrow_arrow_arrow.txt new file mode 100644 index 0000000..6044372 --- /dev/null +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_null_with_arrow_arrow_arrow.txt @@ -0,0 +1,19 @@ + +tests/run_time/dereference_null_with_arrow_arrow_arrow.c:10:20: runtime error - accessing a field via a NULL pointer + +dcc explanation: You are using a pointer which is NULL + A common error is using p->field when p == NULL. + +Execution stopped here in main() in tests/run_time/dereference_null_with_arrow_arrow_arrow.c at line 10: + + struct list_node *a = &s1; + s1.next = &s2; +--> a->next->next->data = 42; +} + +Values when execution stopped: + +s1 = {next = 0x, data = +s2 = {next = NULL, data = +a->next->next = + diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_null_with_asterisk.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_null_with_asterisk.txt new file mode 100644 index 0000000..4a89557 --- /dev/null +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_null_with_asterisk.txt @@ -0,0 +1,16 @@ + +tests/run_time/dereference_null_with_asterisk.c:4:2: runtime error - assigning to a value via a NULL pointer + +dcc explanation: You are using a pointer which is NULL + A common error is assigning to *p when p == NULL. + +Execution stopped here in main() in tests/run_time/dereference_null_with_asterisk.c at line 4: + +int main(void) { + int *a = NULL; +--> *a = 42; +} +Values when execution stopped: + +a = + diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_null_with_index.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_null_with_index.txt new file mode 100644 index 0000000..28f4a6d --- /dev/null +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_null_with_index.txt @@ -0,0 +1,17 @@ + +tests/run_time/dereference_null_with_index.c:4:12: runtime error - accessing a value via a NULL pointer + +dcc explanation: You are using a pointer which is NULL + A common error is accessing p[index] when p == NULL. + +Execution stopped here in main() in tests/run_time/dereference_null_with_index.c at line 4: + +int main(void) { + int *a = NULL; +--> return a[0]; +} + +Values when execution stopped: + +a = + diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_uninitialized_char_star_with_asterisk.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_uninitialized_char_star_with_asterisk.txt new file mode 100644 index 0000000..b976e64 --- /dev/null +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_uninitialized_char_star_with_asterisk.txt @@ -0,0 +1,10 @@ + +Execution terminated by signal 11 +Execution stopped here in main() in tests/run_time/dereference_uninitialized_char_star_with_asterisk.c at line 4: + +int main(void) { + char **a = malloc(sizeof *a); +--> return **a; +} + + diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_arrow.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_arrow.txt new file mode 100644 index 0000000..f469466 --- /dev/null +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_arrow.txt @@ -0,0 +1,17 @@ + +tests/run_time/dereference_uninitialized_with_arrow.c:9:14: runtime error - accessing a field via an uninitialized pointer + +dcc explanation: You are using a pointer which has not been initialized + A common error is using p->field without first assigning a value to p. + +Execution stopped here in main() in tests/run_time/dereference_uninitialized_with_arrow.c at line 9: + +int main(void) { + struct list_node *a = malloc(sizeof *a); +--> a->next->data = 42; +} + +Values when execution stopped: + +a->next = + diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_arrow_arrow_arrow.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_arrow_arrow_arrow.txt new file mode 100644 index 0000000..c8e90d2 --- /dev/null +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_arrow_arrow_arrow.txt @@ -0,0 +1,17 @@ + +tests/run_time/dereference_uninitialized_with_arrow_arrow_arrow.c:10:20: runtime error - accessing a field via an uninitialized pointer + +dcc explanation: You are using a pointer which has not been initialized + A common error is using p->field without first assigning a value to p. + +Execution stopped here in main() in tests/run_time/dereference_uninitialized_with_arrow_arrow_arrow.c at line 10: + + struct list_node *a = malloc(sizeof *a); + a->next = malloc(sizeof *a); +--> a->next->next->data = 42; +} + +Values when execution stopped: + +a->next->next = + diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_asterisk.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_asterisk.txt new file mode 100644 index 0000000..d414d3e --- /dev/null +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_asterisk.txt @@ -0,0 +1,14 @@ + +tests/run_time/dereference_uninitialized_with_asterisk.c:4:12: runtime error - accessing a value via a uninitialized pointer + +dcc explanation: You are using a pointer which has not been initialized + A common error is accessing *p without first assigning a value to p. + +Execution stopped here in main() in tests/run_time/dereference_uninitialized_with_asterisk.c at line 4: + +int main(void) { + int **a = malloc(sizeof *a); +--> return **a; +} + + diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_index.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_index.txt new file mode 100644 index 0000000..7a66219 --- /dev/null +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/dereference_uninitialized_with_index.txt @@ -0,0 +1,14 @@ + +tests/run_time/dereference_uninitialized_with_index.c:4:12: runtime error - accessing a value via a uninitialized pointer + +dcc explanation: You are using a pointer which has not been initialized + A common error is accessing p[index] without first assigning a value to p. + +Execution stopped here in main() in tests/run_time/dereference_uninitialized_with_index.c at line 4: + +int main(void) { + int **a = malloc(sizeof *a); +--> return a[0][0]; +} + + diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/double_int_literal_conversion.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/double_int_literal_conversion.txt index e929558..a8a10d8 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/double_int_literal_conversion.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/double_int_literal_conversion.txt @@ -1,5 +1,5 @@ -tests/extracted_compile_time_tests/double_int_literal_conversion.c:3:10: warning: implicit conversion from 'double' to 'int' changes value from 6.7 to 6 [-Wliteral-conversion] +tests/extracted_compile_time_tests/double_int_literal_conversion.c:3:10: warning: implicit conversion from 'double' to 'int' changes value from 6.7 to 6 [-Wliteral-conversion] int i = 6.7; - ~ ^~~ + ~ ^~~ dcc explanation: you are assigning the floating point number 6.7 to the int variable i , if this is what you want, change 6.7 to 6 diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/expression_not_assignable.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/expression_not_assignable.txt index 65b55bf..c2cc0aa 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/expression_not_assignable.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/expression_not_assignable.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/expression_not_assignable.c:3:23: error: expression is not assignable +tests/extracted_compile_time_tests/expression_not_assignable.c:3:23: error: expression is not assignable if (argc = 1 || argc = 2) { - ~~~~~~~~~ ^ + ~~~~~~~~~ ^ dcc explanation: You are using = Reminder: you use = to assign to a variable. You use == to compare values. diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/format_type_mismatch.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/format_type_mismatch.txt index bb2ca87..0a7cc95 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/format_type_mismatch.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/format_type_mismatch.txt @@ -1,14 +1,14 @@ -tests/extracted_compile_time_tests/format_type_mismatch.c:5:9: warning: missing terminating '"' character [-Winvalid-pp-token] +tests/extracted_compile_time_tests/format_type_mismatch.c:5:9: warning: missing terminating '"' character [-Winvalid-pp-token] printf("%d - ^ -tests/extracted_compile_time_tests/format_type_mismatch.c:5:9: error: expected expression -tests/extracted_compile_time_tests/format_type_mismatch.c:6:11: warning: missing terminating '"' character [-Winvalid-pp-token] + ^ +tests/extracted_compile_time_tests/format_type_mismatch.c:5:9: error: expected expression +tests/extracted_compile_time_tests/format_type_mismatch.c:6:11: warning: missing terminating '"' character [-Winvalid-pp-token] ", "hello!"); - ^ -tests/extracted_compile_time_tests/format_type_mismatch.c:7:2: error: expected '}' + ^ +tests/extracted_compile_time_tests/format_type_mismatch.c:7:2: error: expected '}' } - ^ -tests/extracted_compile_time_tests/format_type_mismatch.c:4:16: note: to match this '{' + ^ +tests/extracted_compile_time_tests/format_type_mismatch.c:4:16: note: to match this '{' int main(void) { - ^ + ^ dcc explanation: Make sure that all opening brace symbols `{` are matched with a closing brace `}`. diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/hash_define.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/hash_define.txt index 2ce23ac..5370747 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/hash_define.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/hash_define.txt @@ -1,12 +1,19 @@ -tests/run_time/hash_define.c:10:3: runtime error: index 1000 out of bounds for type 'int [1000]' -Execution stopped here in main() in tests/run_time/hash_define.c at line 10: +tests/run_time/hash_define.c:10:3: runtime error - index 1000 out of bounds for type 'int [1000]' + +dcc explanation: You are using an illegal array index: 1000 + Valid indices for an array of size 1000 are 0..999 + Make sure the size of your array is correct. + Make sure your array indices are correct. +Execution stopped here in main() in tests/run_time/hash_define.c at line 10: + for (i = 0; i < ARRAY_SIZE; i++) { --> a[i+argc] = i+argc; } -} + return a[0]; + Values when execution stopped: argc = diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/illegal_nested_array_assignment.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/illegal_nested_array_assignment.txt index 376cacd..3676c35 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/illegal_nested_array_assignment.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/illegal_nested_array_assignment.txt @@ -1,8 +1,14 @@ -tests/run_time/illegal_nested_array_assignment.c:3:2: runtime error: index 4 out of bounds for type 'int [4]' + +tests/run_time/illegal_nested_array_assignment.c:3:2: runtime error - index 4 out of bounds for type 'int [4]' + +dcc explanation: You are using an illegal array index: 4 + Valid indices for an array of size 4 are 0..3 + Make sure the size of your array is correct. + Make sure your array indices are correct. Execution stopped here in main() in tests/run_time/illegal_nested_array_assignment.c at line 3: -int main(int argc, char **argv) { +int main(int argc, char **argv) { int a[] = {1,2,3,4}; --> a[a[a[a[a[0]]]]] = 1; } diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/illegal_vla_index.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/illegal_vla_index.txt index 71349cc..de58e60 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/illegal_vla_index.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/illegal_vla_index.txt @@ -1,10 +1,16 @@ -tests/run_time/illegal_vla_index.c:3:2: runtime error: index 1000 out of bounds for type 'int [600 + argc]' + +tests/run_time/illegal_vla_index.c:3:2: runtime error - index 1000 out of bounds for type 'int [600 + argc]' + +dcc explanation: You are using an illegal array index: 1000 + Make sure the size of your array is correct. + Make sure your array indices are correct. Execution stopped here in main() in tests/run_time/illegal_vla_index.c at line 3: -int main(int argc, char **argv) { +int main(int argc, char **argv) { int a[600+argc]; --> a[1000] = argc; + return a[1000]; } Values when execution stopped: diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/implicit_function_declaration.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/implicit_function_declaration.txt index dc96660..4c3f690 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/implicit_function_declaration.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/implicit_function_declaration.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/implicit_function_declaration.c:3:2: warning: implicit declaration of function 'f' is invalid in C99 [-Wimplicit-function-declaration] +tests/extracted_compile_time_tests/implicit_function_declaration.c:3:2: warning: implicit declaration of function 'f' is invalid in C99 [-Wimplicit-function-declaration] f(); - ^ + ^ dcc explanation: you are calling a function named f line 3 of tests/extracted_compile_time_tests/implicit_function_declaration.c but dcc does not recognize f as a function. There are several possible causes: a) You might have misspelt the function name. @@ -9,4 +9,4 @@ There are several possible causes: undefined reference to `f' -clang: error: linker command failed with exit code 1 (use -v to see invocation) +clang: error: linker command failed with exit code 1 (use -v to see invocation) diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/incremental_compilation.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/incremental_compilation.txt new file mode 100644 index 0000000..d44a7eb --- /dev/null +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/incremental_compilation.txt @@ -0,0 +1,2 @@ +incremental compilation works +incremental compilation works diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/int_overflow.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/int_overflow.txt index d153076..1157416 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/int_overflow.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/int_overflow.txt @@ -1,8 +1,12 @@ -tests/run_time/int_overflow.c:5:6: runtime error: signed integer overflow: + 1 cannot be represented in type 'int' + +tests/run_time/int_overflow.c:5:6: runtime error - signed integer overflow: + 1 cannot be represented in type 'int' + +dcc explanation: There are limits in the range of values that can be represented in all types. + Your program has produced a value outside that range. Execution stopped here in main() in tests/run_time/int_overflow.c at line 5: -int main(int argc, char **argv) { +int main(int argc, char **argv) { int k = INT_MAX; --> k += argc; } diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/leak_valgrind--valgrind#--leak-check.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/leak_valgrind--valgrind#--leak-check.txt deleted file mode 100644 index 8e6a2aa..0000000 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/leak_valgrind--valgrind#--leak-check.txt +++ /dev/null @@ -1,2 +0,0 @@ -clang: error: unsupported option '--valgrind#--leak-check' - diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/leak_valgrind--valgrind_--leak-check.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/leak_valgrind--valgrind_--leak-check.txt new file mode 100644 index 0000000..3805d19 --- /dev/null +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/leak_valgrind--valgrind_--leak-check.txt @@ -0,0 +1 @@ +Error: free not called for memory allocated with malloc in function main in leak_valgrind.c at line 6. diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/main_wrong_type.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/main_wrong_type.txt index 6b09fce..c12a4a7 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/main_wrong_type.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/main_wrong_type.txt @@ -1,5 +1,5 @@ -tests/compile_time/main_wrong_type.c:1:5: error: second parameter of 'main' (argument array) must be of type 'char **' +tests/compile_time/main_wrong_type.c:1:5: error: second parameter of 'main' (argument array) must be of type 'char **' int main(int argc, int argv[]) { - ^ + ^ dcc explanation: Looks like your declaration of `main` isn't quite right. Be sure its second parameter is `char *argv[]` or some equivalent! diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/missing_library_include.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/missing_library_include.txt index b178b83..0a460ac 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/missing_library_include.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/missing_library_include.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/missing_library_include.c:3:2: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)' [-Wimplicit-function-declaration] +tests/extracted_compile_time_tests/missing_library_include.c:3:2: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)' [-Wimplicit-function-declaration] printf("hello"); - ^ + ^ dcc explanation: You are calling the function printf on line 3 of tests/extracted_compile_time_tests/missing_library_include.c but dcc does not recognize printf as a function because you have forgotten to #include diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/missing_semicolon_line_before_assert.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/missing_semicolon_line_before_assert.txt index 7143dd9..7fa5017 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/missing_semicolon_line_before_assert.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/missing_semicolon_line_before_assert.txt @@ -1,7 +1,7 @@ -tests/extracted_compile_time_tests/missing_semicolon_line_before_assert.c:6:2: error: called object type 'int' is not a function or function pointer +tests/extracted_compile_time_tests/missing_semicolon_line_before_assert.c:6:2: error: called object type 'int' is not a function or function pointer assert(i == 10); - ^ -/usr/include/assert.h:108:3: note: expanded from macro 'assert' + ^ + expanded from macro 'assert' ((void) sizeof ((expr) ? 1 : 0), __extension__ ({ \ - ^ + ^ dcc explanation: there is probably a syntax error such as missing semi-colon on line 5 of tests/extracted_compile_time_tests/missing_semicolon_line_before_assert.c or an earlier line diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/misspelt_printf.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/misspelt_printf.txt index be0ded3..0ec6788 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/misspelt_printf.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/misspelt_printf.txt @@ -1,9 +1,9 @@ -tests/extracted_compile_time_tests/misspelt_printf.c:4:2: warning: implicit declaration of function 'print' is invalid in C99 [-Wimplicit-function-declaration] +tests/extracted_compile_time_tests/misspelt_printf.c:4:2: warning: implicit declaration of function 'print' is invalid in C99 [-Wimplicit-function-declaration] print("hello"); - ^ + ^ dcc explanation: you are calling a function named print on line 4 of tests/extracted_compile_time_tests/misspelt_printf.c but dcc does not recognize print as a function. Maybe you meant printf? undefined reference to `print' -clang: error: linker command failed with exit code 1 (use -v to see invocation) +clang: error: linker command failed with exit code 1 (use -v to see invocation) diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/mod_zero--valgrind.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/mod_zero--valgrind.txt index deeef77..fceacb4 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/mod_zero--valgrind.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/mod_zero--valgrind.txt @@ -1,2 +1,5 @@ -tests/run_time/mod_zero.c:7:20: runtime error: division by zero + +tests/run_time/mod_zero.c:7:20: runtime error - division by zero + +dcc explanation: A common error is to evaluate x % y when y == 0 which is undefined. diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/mod_zero.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/mod_zero.txt index fe97cd9..87222da 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/mod_zero.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/mod_zero.txt @@ -1,4 +1,7 @@ -tests/run_time/mod_zero.c:7:20: runtime error: division by zero + +tests/run_time/mod_zero.c:7:20: runtime error - division by zero + +dcc explanation: A common error is to evaluate x % y when y == 0 which is undefined. Execution stopped here in main() in tests/run_time/mod_zero.c at line 7: diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/no_main_function.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/no_main_function.txt index 6d5fa91..1c0b7ca 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/no_main_function.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/no_main_function.txt @@ -1,5 +1,5 @@ undefined reference to `main' -clang: error: linker command failed with exit code 1 (use -v to see invocation) +clang: error: linker command failed with exit code 1 (use -v to see invocation) dcc explanation: Your program does not contain a main function - a C program must contain a main function. diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/printf_int_string_mismatch.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/printf_int_string_mismatch.txt index 380307f..5742fbb 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/printf_int_string_mismatch.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/printf_int_string_mismatch.txt @@ -1,6 +1,6 @@ -tests/compile_time/printf_int_string_mismatch.c:4:17: warning: format specifies type 'int' but the argument has type 'char *' [-Wformat] +tests/compile_time/printf_int_string_mismatch.c:4:17: warning: format specifies type 'int' but the argument has type 'char *' [-Wformat] printf("%d\n", "hello!"); - ~~ ^~~~~~~~ - %s + ~~ ^~~~~~~~ + %s dcc explanation: make sure you are using the correct format code (e.g., `%d` for integers, `%lf` for floating-point values) in your format string on line 4 diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/relational_expression_with_comma.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/relational_expression_with_comma.txt index bb6fdad..902a595 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/relational_expression_with_comma.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/relational_expression_with_comma.txt @@ -1,5 +1,5 @@ -tests/compile_time/relational_expression_with_comma.c:2:11: warning: relational comparison result unused [-Wunused-comparison] +tests/compile_time/relational_expression_with_comma.c:2:11: warning: relational comparison result unused [-Wunused-comparison] if (argc < 1, argc < 2) - ~~~~~^~~ + ~~~~~^~~ dcc explanation: Looks like you're comparing two values on line 2 of `tests/compile_time/relational_expression_with_comma.c` but not using the result? diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/scanf_missing_ampersand.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/scanf_missing_ampersand.txt index a8e8112..303d69a 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/scanf_missing_ampersand.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/scanf_missing_ampersand.txt @@ -1,5 +1,5 @@ -tests/extracted_compile_time_tests/scanf_missing_ampersand.c:6:14: warning: format specifies type 'int *' but the argument has type 'int' [-Wformat] +tests/extracted_compile_time_tests/scanf_missing_ampersand.c:6:14: warning: format specifies type 'int *' but the argument has type 'int' [-Wformat] scanf("%d", i); - ~~ ^ + ~~ ^ dcc explanation: Perhaps you have forgotten an '&' before 'i' on line 6. diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/stack_use_after_return.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/stack_use_after_return.txt index 55953c3..0490831 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/stack_use_after_return.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/stack_use_after_return.txt @@ -1,6 +1,6 @@ -tests/extracted_compile_time_tests/stack_use_after_return.c:4:15: warning: address of stack memory associated with local variable 'i' returned [-Wreturn-stack-address] +tests/extracted_compile_time_tests/stack_use_after_return.c:4:15: warning: address of stack memory associated with local variable 'i' returned [-Wreturn-stack-address] return (int)&i; - ^ + ^ dcc explanation: you are trying to return a pointer to the local variable 'i'. You can not do this because i will not exist after the function returns. See more information here: https://comp1511unsw.github.io/dcc/stack_use_after_return.html diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/two_main_functions.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/two_main_functions.txt index 07ac542..0b103fc 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/two_main_functions.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/two_main_functions.txt @@ -1,5 +1,5 @@ first defined here -clang: error: linker command failed with exit code 1 (use -v to see invocation) +clang: error: linker command failed with exit code 1 (use -v to see invocation) dcc explanation: Your program contains more than one main function - a C program can only contain one main function. diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/uninitialized-array-element-if--valgrind.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/uninitialized-array-element-if--valgrind.txt index 33381ad..69d2b9b 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/uninitialized-array-element-if--valgrind.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/uninitialized-array-element-if--valgrind.txt @@ -11,6 +11,7 @@ Execution stopped here in main() in tests/run_time/uninitialized-array-element-i Values when execution stopped: +a = argc = a[42] = a[43] = diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/uninitialized-array-element-printf--valgrind.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/uninitialized-array-element-printf--valgrind.txt index 9949ece..05084e9 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/uninitialized-array-element-printf--valgrind.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/uninitialized-array-element-printf--valgrind.txt @@ -10,6 +10,7 @@ Execution stopped here in main() in tests/run_time/uninitialized-array-element-p Values when execution stopped: +a = argc = a[42] = a[argc] = diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/uninitialized-array-element-sum--memory.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/uninitialized-array-element-sum--memory.txt index c7dfae2..5d2b248 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/uninitialized-array-element-sum--memory.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/uninitialized-array-element-sum--memory.txt @@ -3,7 +3,7 @@ tests/run_time/uninitialized-array-element-sum.c:9 runtime error uninitialized v Execution stopped here in main() in tests/run_time/uninitialized-array-element-sum.c at line 9: for (i = 0; i < 1000; i++) - sum += a[i]; + sum += a[i] % 2; --> if (sum < 1000) { return sum; } diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/uninitialized-array-element-sum--valgrind.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/uninitialized-array-element-sum--valgrind.txt index bcdfd2f..b7ac68a 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/uninitialized-array-element-sum--valgrind.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/uninitialized-array-element-sum--valgrind.txt @@ -5,12 +5,13 @@ Execution stopped here in main() in tests/run_time/uninitialized-array-element-s a[42] = 42; for (i = 0; i < 1000; i++) ---> sum += a[i]; +--> sum += a[i] % 2; if (sum < 1000) { return sum; Values when execution stopped: +a = i = sum = a[42] = diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/uninitialized_local_variable.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/uninitialized_local_variable.txt index b01a8a3..be95379 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/uninitialized_local_variable.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/uninitialized_local_variable.txt @@ -1,14 +1,14 @@ -tests/compile_time/uninitialized_local_variable.c:5:13: warning: variable 's' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] +tests/compile_time/uninitialized_local_variable.c:5:13: warning: variable 's' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] else if (argc < 2) - ^~~~~~~~ -tests/compile_time/uninitialized_local_variable.c:8:9: note: uninitialized use occurs here + ^~~~~~~~ +tests/compile_time/uninitialized_local_variable.c:8:9: note: uninitialized use occurs here return s; - ^ -tests/compile_time/uninitialized_local_variable.c:5:9: note: remove the 'if' if its condition is always true + ^ +tests/compile_time/uninitialized_local_variable.c:5:9: note: remove the 'if' if its condition is always true else if (argc < 2) - ^~~~~~~~~~~~~ -tests/compile_time/uninitialized_local_variable.c:2:7: note: initialize the variable 's' to silence this warning + ^~~~~~~~~~~~~ +tests/compile_time/uninitialized_local_variable.c:2:7: note: initialize the variable 's' to silence this warning int s; - ^ - = 0 + ^ + = 0 diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/variable_used_in_own_initialization.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/variable_used_in_own_initialization.txt index 7a1e50a..0d03238 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/variable_used_in_own_initialization.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/variable_used_in_own_initialization.txt @@ -1,6 +1,6 @@ -tests/compile_time/variable_used_in_own_initialization.c:2:10: warning: variable 'x' is uninitialized when used within its own initialization [-Wuninitialized] +tests/compile_time/variable_used_in_own_initialization.c:2:10: warning: variable 'x' is uninitialized when used within its own initialization [-Wuninitialized] int x = x + 1; - ~ ^ + ~ ^ dcc explanation: Looks like you have `x` on both the left- and right-hand side of the `=` on line 2 of `tests/compile_time/variable_used_in_own_initialization.c`, but `x` doesn't yet have a value. Be sure not to initialize `x` with itself. diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/write_null_stream.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/write_null_stream.txt index 3f39588..e4a51a9 100644 --- a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/write_null_stream.txt +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/write_null_stream.txt @@ -1,5 +1,5 @@ -tests/run_time/write_null_stream.c: In function ‘main’: -tests/run_time/write_null_stream.c:4:2: warning: null argument where non-null required (argument 1) [-Wnonnull] - fprintf(NULL, "Hello world\n"); - ^~~~~~~ +tests/run_time/write_null_stream.c: In function ‘main’: +tests/run_time/write_null_stream.c:4:2: warning: null argument where non-null required (argument 1) [-Wnonnull] + fprintf(NULL, "Hello world\n"); + ^~~~~~~ diff --git a/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/zero_size_array.txt b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/zero_size_array.txt new file mode 100644 index 0000000..33fd63b --- /dev/null +++ b/tests/expected_output/clang-8.0-x86_64-pc-linux-gnu/zero_size_array.txt @@ -0,0 +1,15 @@ + +tests/run_time/zero_size_array.c:3:8: runtime error - index 0 out of bounds for type 'int [0]' + +dcc explanation: You have created a array of size 0 which is illegal. + Make sure the size of your array is correct. + Make sure your array indices are correct. + +Execution stopped here in main() in tests/run_time/zero_size_array.c at line 3: + +int main(void) { + int a[0]; +-->return a[0]; +} + +