diff --git a/project/CMakeLists.txt b/project/CMakeLists.txt index 9820f750..668ba595 100755 --- a/project/CMakeLists.txt +++ b/project/CMakeLists.txt @@ -7,4 +7,4 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BUILD_DIR}/../bin") include_directories(${CMAKE_SOURCE_DIR}) add_subdirectory(src/transpiler) -add_subdirectory(tests/unit_tests) \ No newline at end of file +add_subdirectory(tests/unit_tests) diff --git a/project/scripts/build_c2eo.py b/project/scripts/build_c2eo.py index 42b5a42b..2c799efb 100755 --- a/project/scripts/build_c2eo.py +++ b/project/scripts/build_c2eo.py @@ -24,37 +24,37 @@ SOFTWARE. """ -import os import sys import argparse import subprocess +from os import chdir +from pathlib import Path # Our scripts import tools import settings -def main(path_to_c2eo_build, cmake_cmd='cmake ..'): +def main(path_to_c2eo_build: Path, cmake_cmd: str = 'cmake ..') -> None: tools.pprint() - original_path = os.getcwd() - if not os.path.exists(path_to_c2eo_build): - os.mkdir(path_to_c2eo_build) - os.chdir(path_to_c2eo_build) + original_path = Path.cwd() + path_to_c2eo_build.mkdir(exist_ok=True) + chdir(path_to_c2eo_build) result = subprocess.run(cmake_cmd, shell=True, capture_output=True, text=True) - if result.returncode != 0: + if result.returncode: tools.pprint_status_result(cmake_cmd, tools.EXCEPTION, result.stderr) - os.chdir(original_path) + chdir(original_path) exit('Failed during cmake execution') tools.pprint(result.stdout, slowly=True) result = subprocess.run(f'make -j {tools.cpu_count()}', shell=True) - os.chdir(original_path) - if result.returncode != 0: + chdir(original_path) + if result.returncode: exit('Failed during make execution') tools.pprint() -def create_parser(): +def create_parser() -> argparse.ArgumentParser: _parser = argparse.ArgumentParser(description='the script for building c2eo in the specified directory') _parser.add_argument('-p', '--path_to_c2eo_build', default=settings.get_setting('path_to_c2eo_build'), @@ -63,7 +63,7 @@ def create_parser(): if __name__ == '__main__': - tools.move_to_script_dir(sys.argv[0]) + tools.move_to_script_dir(Path(sys.argv[0])) parser = create_parser() namespace = parser.parse_args() - main(namespace.path_to_c2eo_build) + main(Path(namespace.path_to_c2eo_build)) diff --git a/project/scripts/build_eo.py b/project/scripts/build_eo.py index 2596f0de..1f269d82 100755 --- a/project/scripts/build_eo.py +++ b/project/scripts/build_eo.py @@ -24,9 +24,13 @@ SOFTWARE. """ -import os import sys +import csv +import json import subprocess +from os import chdir +from os import sep as os_sep +from pathlib import Path # Our scripts import tools @@ -35,7 +39,7 @@ class EOBuilder(object): - def __init__(self, transpilation_units): + def __init__(self, transpilation_units: list[dict]): self.path_to_eo_project = settings.get_setting('path_to_eo_project') self.current_version = settings.get_setting('current_eo_version') self.path_to_foreign_objects = settings.get_setting('path_to_foreign_objects') @@ -45,14 +49,16 @@ def __init__(self, transpilation_units): self.errors = set() self.error_result = {} - def build(self): + def build(self) -> (set[dict], dict): tools.pprint('Compilation start\n') - original_path = os.getcwd() - os.chdir(self.path_to_eo_project) - result = self.is_recompilation() - tools.pprint(f'\n{"Recompilation eo project starts" if result else "Full eo project compilation starts"}\n') - cmd = ['mvn'] if result else ['mvn', 'clean'] - cmd.extend(['compile', '-Djansi.force=true', '-Dstyle.color=always']) + original_path = Path.cwd() + chdir(self.path_to_eo_project) + can_recompile = self.is_recompilation() + if can_recompile: + cmd, _ = ['mvn'], tools.pprint('\nRecompilation eo project starts') + else: + cmd, _ = ['mvn', 'clean'], tools.pprint('Full eo project compilation starts\n') + cmd.extend(['compile', '-D', 'jansi.force=true', '-D' 'style.color=always']) process = subprocess.Popen(cmd, stdout=subprocess.PIPE, text=True) for line in process.stdout: if line: @@ -61,13 +67,13 @@ def build(self): self.handle_eo_error(line) elif process.poll() is not None: break - os.chdir(original_path) + chdir(original_path) if process.poll(): exit('compilation failed') return self.errors, self.error_result - def is_recompilation(self): - if not os.path.exists(self.path_to_foreign_objects): + def is_recompilation(self) -> bool: + if not self.path_to_foreign_objects.exists(): tools.pprint('Compile dir not found', status=tools.WARNING) return False @@ -77,12 +83,12 @@ def is_recompilation(self): return False tools.pprint('Latest version detected', status=tools.PASS) - eo_src_files = tools.search_files_by_patterns(self.path_to_eo, ['*.eo'], recursive=True) - eo_src_files = set(map(lambda x: x.replace(self.path_to_eo, '', 1).replace('.eo', '', 1), eo_src_files)) - project_eo_files = tools.search_files_by_patterns(self.path_to_eo_parse, ['*.xmir'], - recursive=True, filters=['!org/eolang']) - project_eo_files = set(map(lambda x: x.replace(self.path_to_eo_parse, '', 1).replace('.xmir', '', 1), - project_eo_files)) + eo_src_files = tools.search_files_by_patterns(self.path_to_eo, {'*.eo'}, recursive=True) + eo_src_files = {Path(str(x).replace(self.path_to_eo, '', 1).replace('.eo', '', 1)) for x in eo_src_files} + project_eo_files = tools.search_files_by_patterns(self.path_to_eo_parse, {'*.xmir'}, + recursive=True, filters={'!org/eolang'}) + project_eo_files = {Path(str(x).replace(self.path_to_eo_parse, '', 1).replace('.xmir', '', 1)) for x in + project_eo_files} difference = project_eo_files - eo_src_files tools.pprint() if difference: @@ -93,9 +99,16 @@ def is_recompilation(self): tools.pprint('EO project files are compatible', status=tools.PASS) return True - def is_actual_object_version(self): + def is_actual_object_version(self) -> bool: tools.pprint('\nCheck version of compiled eo objects\n') - data = tools.read_file_as_dictionary(self.path_to_foreign_objects) + data = [] + if not self.path_to_foreign_objects.exists(): + return False + + with open(self.path_to_foreign_objects) as f: + reader = csv.DictReader(f) + for row in reader: + data.append(row) for package in data: if package['version'] not in ['*.*.*', '0.0.0']: compare = tools.version_compare(self.current_version, package['version']) @@ -103,8 +116,8 @@ def is_actual_object_version(self): return True return False - def handle_eo_error(self, message): - file, error = message.split('/', maxsplit=1)[1].split('with error:', maxsplit=1) + def handle_eo_error(self, message) -> None: + file, error = message.split(os_sep, maxsplit=1)[1].split('with error:', maxsplit=1) file, error = file.strip(), error.strip() for unit in self.transpilation_units: if unit['unique_name'] in file: @@ -116,5 +129,5 @@ def handle_eo_error(self, message): if __name__ == '__main__': - tools.move_to_script_dir(sys.argv[0]) + tools.move_to_script_dir(Path(sys.argv[0])) EOBuilder([]).build() diff --git a/project/scripts/c2eo-all.py b/project/scripts/c2eo-all.py index 8611af45..26ee1cc5 100755 --- a/project/scripts/c2eo-all.py +++ b/project/scripts/c2eo-all.py @@ -33,7 +33,6 @@ if __name__ == '__main__': path_to_c_files = os.path.abspath(sys.argv[1]) if not os.path.exists(path_to_c_files): - print('This path does not exist') exit('This path does not exist') clean_before_transpilation.main(path_to_c_files) diff --git a/project/scripts/clang_tidy.py b/project/scripts/clang_tidy.py index 33a12ae7..a8a6c0ee 100755 --- a/project/scripts/clang_tidy.py +++ b/project/scripts/clang_tidy.py @@ -24,11 +24,12 @@ SOFTWARE. """ -import os import sys import time import argparse import subprocess +from os import chdir +from pathlib import Path # Our scripts import settings @@ -37,28 +38,25 @@ class ClangTidy(object): - def __init__(self, path_to_code_files): + def __init__(self, path_to_code_files: Path): self.filters = None - if os.path.isfile(path_to_code_files): - self.filters = [os.path.split(path_to_code_files)[1]] - path_to_code_files = os.path.dirname(path_to_code_files) + if path_to_code_files.is_file(): + self.filters = {path_to_code_files.name} + path_to_code_files = path_to_code_files.parent self.path_to_code_files = path_to_code_files self.files_handled_count = 0 self.files_count = 0 self.path_to_c2eo_build = settings.get_setting('path_to_c2eo_build') - if not os.path.exists(self.path_to_c2eo_build): - os.mkdir(self.path_to_c2eo_build) - self.ignored_inspection_warnings = settings.get_setting('ignored_inspection_warnings') - if not self.ignored_inspection_warnings: - self.ignored_inspection_warnings = [] + self.path_to_c2eo_build.mkdir(exist_ok=True) + self.ignored_inspection_warnings = settings.get_setting('ignored_inspection_warnings') or [] self.clang_tidy_checks = ','.join(settings.get_setting('clang_tidy_checks')) - self.results = [] + self.results: list[dict[str, str | Path | subprocess.CompletedProcess]] = [] - def inspect(self): + def inspect(self) -> bool: start_time = time.time() tools.pprint('\nInspection start\n') self.generate_compile_commands() - patterns = settings.get_setting('code_file_patterns') + patterns = set(settings.get_setting('code_file_patterns')) code_files = tools.search_files_by_patterns(self.path_to_code_files, patterns, filters=self.filters, recursive=True, print_files=True) self.files_count = len(code_files) @@ -67,30 +65,30 @@ def inspect(self): with tools.thread_pool() as threads: self.results = [result for result in threads.map(self.inspect_file, code_files)] result = self.group_inspection_results() - _is_failed = len(result[tools.WARNING]) + len(result[tools.EXCEPTION]) + _is_failed = len(result[tools.WARNING]) + len(result[tools.EXCEPTION]) > 0 tools.pprint_result('INSPECTION', self.files_count, int(time.time() - start_time), result, _is_failed) return _is_failed - def generate_compile_commands(self): - original_path = os.getcwd() - os.chdir(self.path_to_c2eo_build) + def generate_compile_commands(self) -> None: + original_path = Path.cwd() + chdir(self.path_to_c2eo_build) cmd = f'cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON' result = subprocess.run(cmd, shell=True, capture_output=True, text=True) - os.chdir(original_path) + chdir(original_path) if result.returncode != 0: tools.pprint_status_result(cmd, tools.EXCEPTION, result.stderr) exit('Failed during cmake execution') tools.pprint(result.stdout, slowly=True) - def inspect_file(self, file): + def inspect_file(self, file: Path) -> dict[str, str | Path | subprocess.CompletedProcess]: transpile_cmd = f'clang-tidy -p {self.path_to_c2eo_build} --checks=\'{self.clang_tidy_checks}\' {file}' result = subprocess.run(transpile_cmd, shell=True, capture_output=True, text=True) self.files_handled_count += 1 tools.print_progress_bar(self.files_handled_count, self.files_count) - return {'name': tools.get_file_name(file), 'file': os.path.basename(file), 'inspection_result': result} + return {'name': file.stem, 'file': file.name, 'inspection_result': result} - def group_inspection_results(self): - result = {tools.PASS: set([unit['file'] for unit in self.results]), tools.NOTE: {}, tools.WARNING: {}, + def group_inspection_results(self) -> dict[str, set[str] | dict[str, [dict[str, set[str]]]]]: + result = {tools.PASS: {unit['file'] for unit in self.results}, tools.NOTE: {}, tools.WARNING: {}, tools.ERROR: {}, tools.EXCEPTION: {}} tools.pprint('\nGetting results\n', slowly=True, on_the_next_line=True) for unit in self.results: @@ -116,11 +114,11 @@ def group_inspection_results(self): if unit['file'] in place: result[status][message][unit['file']].add(place.split(':', 1)[1][:-2]) for status in [tools.WARNING, tools.ERROR, tools.EXCEPTION]: - result[tools.PASS] -= set(file for value in result[status].values() for file in value.keys()) + result[tools.PASS] -= {file for value in result[status].values() for file in value.keys()} return result -def create_parser(): +def create_parser() -> argparse.ArgumentParser: _parser = argparse.ArgumentParser(description='script for checking code files using Clang-Tidy') _parser.add_argument('-p', '--path_to_code_files', default=settings.get_setting('path_to_code_files'), @@ -129,9 +127,9 @@ def create_parser(): if __name__ == '__main__': - tools.move_to_script_dir(sys.argv[0]) + tools.move_to_script_dir(Path(sys.argv[0])) parser = create_parser() namespace = parser.parse_args() - is_failed = ClangTidy(namespace.path_to_code_files).inspect() + is_failed = ClangTidy(Path(namespace.path_to_code_files)).inspect() if is_failed: exit(f'clang-tidy checks failed') diff --git a/project/scripts/clean_before_transpilation.py b/project/scripts/clean_before_transpilation.py index 4741255e..c2f29287 100755 --- a/project/scripts/clean_before_transpilation.py +++ b/project/scripts/clean_before_transpilation.py @@ -24,25 +24,26 @@ SOFTWARE. """ -import os + import sys import argparse +from pathlib import Path # Our scripts import tools import settings -def main(path_to_files): - patterns = settings.get_setting('patterns_for_cleaning') - if os.path.isfile(path_to_files): - path_to_files = os.path.dirname(path_to_files) +def main(path_to_files: Path) -> None: + patterns = set(settings.get_setting('patterns_for_cleaning')) + if path_to_files.is_file(): + path_to_files = path_to_files.parent tools.clear_dir_by_patterns(path_to_files, patterns, recursive=True) tools.remove_empty_dirs(path_to_files) - tools.clear_dir_by_patterns(settings.get_setting('path_to_c2eo_transpiler'), ['*.eo']) + tools.clear_dir_by_patterns(settings.get_setting('path_to_c2eo_transpiler'), {'*.eo'}) -def create_parser(): +def create_parser() -> argparse.ArgumentParser: _parser = argparse.ArgumentParser(description='the script for cleaning the folder from temporary files') _parser.add_argument('-p', '--path_to_files', metavar='PATH', default=settings.get_setting('path_to_tests'), @@ -51,7 +52,7 @@ def create_parser(): if __name__ == '__main__': - tools.move_to_script_dir(sys.argv[0]) + tools.move_to_script_dir(Path(sys.argv[0])) parser = create_parser() namespace = parser.parse_args() - main(namespace.path_to_files) + main(Path(namespace.path_to_files)) diff --git a/project/scripts/code_lines.py b/project/scripts/code_lines.py index a7d57a35..22ce6392 100755 --- a/project/scripts/code_lines.py +++ b/project/scripts/code_lines.py @@ -24,28 +24,26 @@ SOFTWARE. """ -import os import sys -import glob import subprocess +from pathlib import Path if __name__ == '__main__': - path_to_files = os.path.abspath(sys.argv[1]) - if not os.path.exists(path_to_files): - print('This path does not exist') + path_to_files = Path(sys.argv[1]).resolve() + if not path_to_files.exists(): exit('This path does not exist') - path_to_files = os.path.join(path_to_files, '**') code_lines = {'c': 0, 'i': 0, 'eo': 0, 'h': 0} if len(sys.argv) == 3 and sys.argv[2] in code_lines.keys(): code_lines = {sys.argv[2]: 0} for extension in code_lines.keys(): - files = glob.glob(os.path.join(path_to_files, f'*.{extension}'), recursive=True) + files = path_to_files.rglob(f'*.{extension}') if extension == 'c': - files = list(filter(lambda f: '-eo.c' not in f, files)) + files = {f for f in files if not f.match('-eo.c')} lines_count = 0 + files_count = 0 for file in files: - result = subprocess.run(f'wc -l {file}', shell=True, text=True, capture_output=True) - lines_count += int(result.stdout.split()[0]) - lines_count = '{0:7,}'.format(lines_count).replace(',', ' ') - print(f'*.{extension:2} | files: {len(files):3} | lines: {lines_count}') + if result := subprocess.run(f'wc -l {file}', shell=True, text=True, capture_output=True).stdout.split(): + lines_count += int(result[0]) + files_count += 1 + print(f'*.{extension:2} | files: {files_count:5,} | lines: {lines_count:7,}') diff --git a/project/scripts/codecov.py b/project/scripts/codecov.py index 26f3aff4..391391e2 100755 --- a/project/scripts/codecov.py +++ b/project/scripts/codecov.py @@ -24,33 +24,34 @@ SOFTWARE. """ -import os import sys import argparse import subprocess +from os import chdir +from pathlib import Path # Our scripts import tools import settings -def generate_codecov(): - os.chdir(settings.get_setting('path_to_c2eo_transpiler')) +def generate_codecov() -> None: + chdir(settings.get_setting('path_to_c2eo_transpiler')) tools.pprint('Merging profdata\n') subprocess.run(f'llvm-profdata-14 merge -sparse *.profraw -o res.profdata', shell=True) tools.pprint('Convert res.profdata to report.txt') subprocess.run('llvm-cov-14 show ./c2eo ../src/transpiler/*.cpp -instr-profile=res.profdata > report.txt', shell=True) - tools.clear_dir_by_patterns('.', ['*.profraw', '*.profdata']) + tools.clear_dir_by_patterns(Path.cwd(), {'*.profraw', '*.profdata'}) -def create_parser(): +def create_parser() -> argparse.ArgumentParser: _parser = argparse.ArgumentParser(description='the script for generating codecov for c2eo transpiler') return _parser if __name__ == '__main__': - tools.move_to_script_dir(sys.argv[0]) + tools.move_to_script_dir(Path(sys.argv[0])) parser = create_parser() namespace = parser.parse_args() generate_codecov() diff --git a/project/scripts/compile.py b/project/scripts/compile.py index 08c80de2..d9fdb0f3 100755 --- a/project/scripts/compile.py +++ b/project/scripts/compile.py @@ -27,6 +27,8 @@ import sys import time import argparse +from pathlib import Path +from subprocess import CompletedProcess # Our scripts import tools @@ -37,27 +39,30 @@ class Compiler(object): - def __init__(self, path_to_files, skips_file_name, need_to_prepare_c_code=True): + def __init__(self, path_to_files: Path, skips_file_name: str, need_to_prepare_c_code: bool = True, + need_to_generate_codecov: bool = False): + self.need_to_generate_codecov = need_to_generate_codecov self.need_to_prepare_c_code = need_to_prepare_c_code self.skips_file_name = skips_file_name self.path_to_tests = path_to_files self.path_to_c2eo_build = settings.get_setting('path_to_c2eo_build') - self.transpilation_units = [] + self.transpilation_units: list[dict[str, str | Path | CompletedProcess]] = [] - def compile(self): + def compile(self) -> Transpiler.transpile: start_time = time.time() self.transpilation_units, skip_result = Transpiler(self.path_to_tests, self.skips_file_name, - self.need_to_prepare_c_code).transpile() + self.need_to_prepare_c_code, + self.need_to_generate_codecov).transpile() if self.transpilation_units: errors, error_result = EOBuilder(self.transpilation_units).build() - passes = set(unit['unique_name'] for unit in self.transpilation_units) - errors + passes = {unit['unique_name'] for unit in self.transpilation_units} - errors result = {tools.PASS: passes, tools.ERROR: error_result, tools.SKIP: skip_result} tests_count = len(self.transpilation_units) + sum(map(len, skip_result.values())) - tools.pprint_result('COMPILE', tests_count, int(time.time() - start_time), result, 0) + tools.pprint_result('COMPILE', tests_count, int(time.time() - start_time), result, False) return self.transpilation_units, skip_result -def create_parser(): +def create_parser() -> argparse.ArgumentParser: _parser = argparse.ArgumentParser(description='the script for compiling translated files from C to EO') _parser.add_argument('-p', '--path_to_files', metavar='PATH', @@ -68,11 +73,15 @@ def create_parser(): _parser.add_argument('-n', '--not_prepare_c_code', action='store_const', const=True, default=False, help='the script will not change the c code in the input files') + + _parser.add_argument('-c', '--codecov', action='store_const', const=True, default=False, + help='the script will generate codecov files') return _parser if __name__ == '__main__': - tools.move_to_script_dir(sys.argv[0]) + tools.move_to_script_dir(Path(sys.argv[0])) parser = create_parser() namespace = parser.parse_args() - Compiler(namespace.path_to_files, namespace.skips_file_name, not namespace.not_prepare_c_code).compile() + Compiler(Path(namespace.path_to_files), namespace.skips_file_name, not namespace.not_prepare_c_code, + namespace.codecov).compile() diff --git a/project/scripts/csmith.py b/project/scripts/csmith.py index de3bbc82..5a42e151 100755 --- a/project/scripts/csmith.py +++ b/project/scripts/csmith.py @@ -24,11 +24,12 @@ SOFTWARE. """ -import os import sys import shutil import argparse import subprocess +from os import chdir +from pathlib import Path # Our scripts import tools @@ -37,45 +38,42 @@ class Csmith(object): - def __init__(self, path_to_generate, files_count): + def __init__(self, path_to_generate: Path, files_count: int): self.csmith_args = ' '.join([f'--{arg}' for arg in settings.get_setting('csmith_args')]) - self.path_to_csmith = os.path.abspath(os.path.join(settings.get_setting('path_to_csmith'), 'csmith')) - self.path_to_csmith_runtime = os.path.join(settings.get_setting('path_to_csmith_runtime')) + self.path_to_csmith = (settings.get_setting('path_to_csmith') / 'csmith').resolve() + self.path_to_csmith_runtime = settings.get_setting('path_to_csmith_runtime') self.path_to_generate = path_to_generate self.files_count = files_count self.generated_files_count = 0 - def generate(self): + def generate(self) -> None: tools.pprint('\nMaking the dir:', slowly=True) - if os.path.exists(self.path_to_generate): - tools.clear_dir_by_patterns(self.path_to_generate, ['*.c', '*.h']) + if self.path_to_generate.exists(): + tools.clear_dir_by_patterns(self.path_to_generate, {'*.c', '*.h'}) else: - os.makedirs(self.path_to_generate, exist_ok=True) + self.path_to_generate.mkdir(exist_ok=True) tools.pprint('\nCopying runtime files into the dir:', slowly=True) - for file in tools.search_files_by_patterns(self.path_to_csmith_runtime, ['*.h'], print_files=True): + for file in tools.search_files_by_patterns(self.path_to_csmith_runtime, {'*.h'}, print_files=True): shutil.copy(file, self.path_to_generate) - os.chdir(self.path_to_generate) + chdir(self.path_to_generate) tools.pprint('\nRunning generating files:\n', slowly=True) tools.print_progress_bar(0, self.files_count) with tools.thread_pool() as threads: results = threads.map(self.generate_file, range(self.files_count)) - print() - tools.pprint('\nGenerated files: ') + tools.pprint('\nGenerated files: ', on_the_next_line=True) for file_name, code in sorted(results, key=lambda x: x[0]): - print(f'{file_name}:\n') - print(code) + print(f'{file_name}:\n\n', code) - def generate_file(self, number): + def generate_file(self, number: int) -> (str, list[str]): result = subprocess.run(f'{self.path_to_csmith} {self.csmith_args}', shell=True, text=True, capture_output=True) - file_name = f'{number + 1:0{len(str(self.files_count))}}.c' - with open(file_name, 'w') as f: - f.write(result.stdout) + file_name = Path(f'{number + 1:0{len(str(self.files_count))}}.c') + file_name.write_text(result.stdout) self.generated_files_count += 1 tools.print_progress_bar(self.generated_files_count, self.files_count) return file_name, result.stderr if result.returncode else result.stdout -def create_parser(): +def create_parser() -> argparse.ArgumentParser: _parser = argparse.ArgumentParser(description='the script for generating csmith testsuite for c2eo transpiler') _parser.add_argument('path_to_generate', metavar='PATH', @@ -83,12 +81,11 @@ def create_parser(): _parser.add_argument('-c', '--count_of_files', metavar='COUNT', default=1, type=int, help='the count of generating files') - return _parser if __name__ == '__main__': - tools.move_to_script_dir(sys.argv[0]) + tools.move_to_script_dir(Path(sys.argv[0])) parser = create_parser() namespace = parser.parse_args() - Csmith(namespace.path_to_generate, namespace.count_of_files).generate() + Csmith(Path(namespace.path_to_generate), namespace.count_of_files).generate() diff --git a/project/scripts/data/settings.yml b/project/scripts/data/settings.yml index cfbff6d7..895a5f59 100644 --- a/project/scripts/data/settings.yml +++ b/project/scripts/data/settings.yml @@ -44,7 +44,7 @@ csmith_args: skips_for_test: test skips_for_compile: compile skips_for_transpile: transpile -current_eo_version: 0.27.0 +current_eo_version: 0.27.2 ignored_inspection_warnings: null ignored_transpilation_warnings: - Wunused-command-line-argument diff --git a/project/scripts/settings.py b/project/scripts/settings.py index 13924334..9a1827ff 100755 --- a/project/scripts/settings.py +++ b/project/scripts/settings.py @@ -23,8 +23,8 @@ """ import yaml -import os.path import requests +from pathlib import Path from yaml.loader import SafeLoader # Our scripts @@ -33,19 +33,19 @@ settings_file = 'data/settings.yml' -def get_setting(setting_name): +def get_setting(setting_name: str) -> str | list[str] | Path: if setting_name == 'latest_eo_version': return get_latest_eo_version() with open(settings_file) as f: data = yaml.load(f, Loader=SafeLoader) setting = data[setting_name] - if 'path' in setting_name and '.' not in setting: - setting = os.path.join(setting, '') + if 'path' in setting_name: + setting = Path(setting) return setting -def set_setting(setting_name, value): +def set_setting(setting_name: str, value) -> None: with open(settings_file) as f: data = yaml.load(f, Loader=SafeLoader) data[setting_name] = value @@ -53,33 +53,33 @@ def set_setting(setting_name, value): f.write(yaml.dump(data)) -def get_latest_eo_version(): +def get_latest_eo_version() -> str: tools.pprint('Check latest EO version') url = 'https://search.maven.org/solrsearch/select?q=g:"org.eolang"a:"eo-parent"&rows=1&wt=json' data = requests.get(url).json() - latest_version = data['response']['docs'][0]['latestVersion'] + latest_version = str(data['response']['docs'][0]['latestVersion']) tools.pprint(f'Latest EO version: "{latest_version}"') return latest_version -def get_meta_code(name, read_as_lines=False): +def get_meta_code(name: str, read_as_lines: bool = False) -> str | list[str]: path = get_setting('path_to_meta') - file = os.path.join(path, f'{name}.txt') + file = path / f'{name}.txt' with open(file, 'r') as f: return f.readlines() if read_as_lines else f.read() -def get_skips(name): +def get_skips(name: str) -> dict: path = get_setting('path_to_skips') - file = os.path.join(path, f'{name}.txt') - with open(file, 'r') as f: - data = f.readlines() + file = path / f'{name}.txt' skips = {} - for row in data: - row = row.rstrip() - if row and not row.startswith('#'): - _filters, comment = row.split(':', maxsplit=1) - _filters = _filters.split(',') - for _filter in _filters: - skips[_filter.strip()] = comment.strip() + with open(file, 'r') as f: + for line in f: + if line.startswith('#'): + continue + + if line := line.rstrip(): + filters, comment = line.split(':', maxsplit=1) + for _filter in filters.split(','): + skips[_filter.strip()] = comment.strip() return skips diff --git a/project/scripts/test.py b/project/scripts/test.py index bfbc4d03..3d385015 100755 --- a/project/scripts/test.py +++ b/project/scripts/test.py @@ -24,12 +24,14 @@ SOFTWARE. """ -import os import sys import time import argparse import subprocess import re as regex +from os import chdir +from pathlib import Path +from subprocess import CompletedProcess # Our scripts import tools @@ -39,8 +41,10 @@ class Tests(object): - def __init__(self, path_to_tests, skips_file_name, need_to_prepare_c_code=True): + def __init__(self, path_to_tests: Path, skips_file_name: str, need_to_prepare_c_code: bool = True, + need_to_generate_codecov: bool = False): self.need_to_prepare_c_code = need_to_prepare_c_code + self.need_to_generate_codecov = need_to_generate_codecov self.skips_file_name = skips_file_name self.path_to_tests = path_to_tests self.path_to_c2eo_build = settings.get_setting('path_to_c2eo_build') @@ -48,13 +52,14 @@ def __init__(self, path_to_tests, skips_file_name, need_to_prepare_c_code=True): self.path_to_eo_project = settings.get_setting('path_to_eo_project') self.run_sh_cmd = settings.get_meta_code('run.sh', read_as_lines=True)[2].rstrip() self.run_sh_replace = settings.get_setting('run_sh_replace') - self.transpilation_units = [] + self.transpilation_units: list[dict[str, str | Path | CompletedProcess]] = [] self.test_handled_count = 0 - def test(self): + def test(self) -> bool: start_time = time.time() self.transpilation_units, skip_result = Compiler(self.path_to_tests, self.skips_file_name, - self.need_to_prepare_c_code).compile() + self.need_to_prepare_c_code, + self.need_to_generate_codecov).compile() if self.transpilation_units: self.get_result_for_tests() with tools.thread_pool() as threads: @@ -62,11 +67,11 @@ def test(self): result = group_comparison_results(results) result[tools.SKIP] = skip_result tests_count = len(self.transpilation_units) + sum(map(len, skip_result.values())) - _is_failed = len(result[tools.ERROR]) + len(result[tools.EXCEPTION]) + _is_failed = len(result[tools.ERROR]) + len(result[tools.EXCEPTION]) > 0 tools.pprint_result('TEST', tests_count, int(time.time() - start_time), result, _is_failed) return _is_failed - def get_result_for_tests(self): + def get_result_for_tests(self) -> None: tools.pprint('\nRunning C tests:\n', slowly=True) tools.print_progress_bar(0, len(self.transpilation_units)) with tools.thread_pool() as threads: @@ -74,57 +79,52 @@ def get_result_for_tests(self): tools.pprint(on_the_next_line=True) tools.pprint('\nRunning EO tests:\n', slowly=True) self.test_handled_count = 0 - original_path = os.getcwd() - os.chdir(self.path_to_eo_project) + original_path = Path.cwd() + chdir(self.path_to_eo_project) tools.print_progress_bar(0, len(self.transpilation_units)) with tools.thread_pool() as threads: threads.map(self.get_result_for_eo_file, self.transpilation_units) - os.chdir(original_path) + chdir(original_path) tools.pprint(on_the_next_line=True) - def get_result_for_c_file(self, unit): - compiled_file = os.path.join(unit['result_path'], f'{unit["name"]}.out') - unit['result_c_file'] = os.path.join(unit['result_path'], f'{unit["name"]}-c.txt') + def get_result_for_c_file(self, unit: dict[str, str | Path | CompletedProcess]) -> None: + compiled_file = unit['result_path'] / f'{unit["name"]}.out' + unit['result_c_file'] = unit['result_path'] / f'{unit["name"]}-c.txt' compile_cmd = ['clang', unit['c_file'], '-o', compiled_file, '-Wno-everything'] try: subprocess.run(compile_cmd, check=True, capture_output=True, text=True) except subprocess.CalledProcessError as exc: - with open(unit['result_c_file'], 'w') as f: - f.write(exc.stderr) + unit['result_c_file'].write_text(exc.stderr) else: process = subprocess.Popen([compiled_file], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) timeout = 10 try: outs, errs = process.communicate(timeout=timeout) - with open(unit['result_c_file'], 'w') as f: - f.write(outs + errs + str(process.returncode)) + unit['result_c_file'].write_text(outs + errs + str(process.returncode)) except subprocess.TimeoutExpired: process.kill() - with open(unit['result_c_file'], 'w') as f: - f.write(f'exception: execution time of C file exceeded {timeout} seconds\n') + unit['result_c_file'].write_text(f'exception: execution time of C file exceeded {timeout} seconds\n') finally: self.test_handled_count += 1 tools.print_progress_bar(self.test_handled_count, len(self.transpilation_units)) - def get_result_for_eo_file(self, unit): + def get_result_for_eo_file(self, unit: dict[str, str | Path | CompletedProcess]) -> None: command = regex.sub(self.run_sh_replace, unit['full_name'].replace('-', '_'), self.run_sh_cmd).split() - unit['result_eo_file'] = os.path.join(unit['result_path'], f'{unit["name"]}-eo.txt') + unit['result_eo_file'] = unit['result_path'] / f'{unit["name"]}-eo.txt' process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) timeout = 60 try: outs, errs = process.communicate(timeout=timeout) - with open(unit['result_eo_file'], 'w') as f: - f.write(outs + errs) + unit['result_eo_file'].write_text(outs + errs) except subprocess.TimeoutExpired: process.kill() - with open(unit['result_eo_file'], 'w') as f: - f.write(f'exception: execution time EO file exceeded {timeout} seconds\n') + unit['result_eo_file'].write_text(f'exception: execution time EO file exceeded {timeout} seconds\n') finally: self.test_handled_count += 1 tools.print_progress_bar(self.test_handled_count, len(self.transpilation_units)) -def compare_files(c_data, eo_data): +def compare_files(c_data: list[str], eo_data: list[str]) -> (bool, bool, list[str]): if is_exception(c_data): return True, False, c_data @@ -142,26 +142,36 @@ def compare_files(c_data, eo_data): return False, is_equal, log_data -def is_exception(lines): +def is_exception(lines: list[str]) -> bool: return len(lines) > 0 and ('exception' in lines[0].casefold() or 'error' in lines[0].casefold()) -def compare_lines(c_data, eo_data): +def compare_lines(c_data: list[str], eo_data: list[str]) -> (bool, list[str]): is_equal = True log_data = [] - for i, (c_line, eo_line) in enumerate(zip(c_data, eo_data)): + for i, (c_line, eo_line) in enumerate(zip(c_data, eo_data), start=1): c_line, eo_line = c_line.rstrip(), eo_line.rstrip() - if c_line == eo_line or tools.is_equal_float_strs(c_line, eo_line) or tools.is_equal_hex_strs(c_line, eo_line): + c_args, eo_args = c_line.split(), eo_line.split() + is_line_equal = len(c_args) == len(eo_args) + if is_line_equal: + for c_arg, eo_arg in zip(c_args, eo_args): + if c_arg == eo_arg or tools.is_equal_float_strs(c_arg, eo_arg) or tools.is_equal_hex_strs(c_arg, + eo_arg): + continue + is_line_equal = False + break + + if is_line_equal: log_data.append(f'\t{tools.BGreen}Line {i}: {c_line} == {eo_line}{tools.IWhite}\n') - continue - - is_equal = False - log_data.append(f'\t{tools.BRed}Line {i}: {c_line} != {eo_line}{tools.IWhite}\n') + else: + is_equal = False + log_data.append(f'\t{tools.BRed}Line {i}: {c_line} != {eo_line}{tools.IWhite}\n') return is_equal, log_data -def group_comparison_results(results): - result = {tools.PASS: [], tools.ERROR: [], tools.EXCEPTION: {}} +def group_comparison_results(results: list[dict[str, str | Path | CompletedProcess], bool, bool, list[str]]) -> \ + dict[str, set[str | str, str] | dict[str, dict[str, set[str]]]]: + result = {tools.PASS: set(), tools.ERROR: set(), tools.EXCEPTION: {}} tools.pprint('Getting results\n', slowly=True) for unit, is_except, is_equal, log_data in results: if is_except: @@ -170,24 +180,25 @@ def group_comparison_results(results): result[tools.EXCEPTION][log_data] = {} result[tools.EXCEPTION][log_data][unit['unique_name']] = set() elif is_equal: - result[tools.PASS].append(unit['unique_name']) + result[tools.PASS].add(unit['unique_name']) else: - result[tools.ERROR].append((unit['unique_name'], log_data)) + result[tools.ERROR].add((unit['unique_name'], ''.join(log_data))) return result -def compare_test_results(unit): +def compare_test_results(unit: dict[str, str | Path | CompletedProcess]) -> ( + dict[str, str | CompletedProcess], bool, bool, list[str]): with open(unit['result_c_file'], 'r') as f: c_data = f.readlines() with open(unit['result_eo_file'], 'r') as f: eo_data = f.readlines() is_except, is_equal, log_data = compare_files(c_data, eo_data) - with open(os.path.join(unit['result_path'], f'{unit["name"]}.log'), 'w') as f: + with open(unit['result_path'] / f'{unit["name"]}.log', 'w') as f: f.writelines(log_data) return unit, is_except, is_equal, log_data -def create_parser(): +def create_parser() -> argparse.ArgumentParser: _parser = argparse.ArgumentParser(description='the script for testing the correctness of the execution of ' 'translated files from C to EO') @@ -199,13 +210,17 @@ def create_parser(): _parser.add_argument('-n', '--not_prepare_c_code', action='store_const', const=True, default=False, help='the script will not change the c code in the input files') + + _parser.add_argument('-c', '--codecov', action='store_const', const=True, default=False, + help='the script will generate codecov files') return _parser if __name__ == '__main__': - tools.move_to_script_dir(sys.argv[0]) + tools.move_to_script_dir(Path(sys.argv[0])) parser = create_parser() namespace = parser.parse_args() - is_failed = Tests(namespace.path_to_tests, namespace.skips_file_name, not namespace.not_prepare_c_code).test() + is_failed = Tests(Path(namespace.path_to_tests), namespace.skips_file_name, not namespace.not_prepare_c_code, + namespace.codecov).test() if is_failed: exit(f'Testing failed') diff --git a/project/scripts/tools.py b/project/scripts/tools.py index 6095d8d7..4702dd84 100755 --- a/project/scripts/tools.py +++ b/project/scripts/tools.py @@ -21,15 +21,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ - -import os -import csv -import json -import glob +import copy import time import math +from os import chdir +from pathlib import Path +from os import sep as os_sep +from os import cpu_count as os_cpu_count from multiprocessing.dummy import Pool as ThreadPool +ISO_8859_1 = 'ISO-8859-1' + # Reset Color_Off = '\033[0m' @@ -71,64 +73,48 @@ separation_line = f'{BIWhite}{"-" * 108}{IWhite}' -def apply_filters_to_files(files, filters=None, print_files=False): +def apply_filters_to_files(files: set[Path], filters: set[str] = None, print_files: bool = False) -> set[Path]: if filters is None: return files pprint(f'Apply filters: {filters} to found files') - inclusion_filters = set(filter(lambda f: f[0] != '!', filters)) - result = set() if inclusion_filters else set(files) - for inclusion_filter in inclusion_filters: - result |= set(filter(lambda file: inclusion_filter in file, files)) - exclusion_filters = set(filter(lambda f: f[0] == '!', filters)) - for exclusion_filter in exclusion_filters: - result = set(filter(lambda file: exclusion_filter[1:] not in file, result)) - result = list(result) + if inclusion_filters := [f for f in filters if f[0] != '!']: + result = set() + for _filter in inclusion_filters: + result |= set(x for x in files if x.match(_filter)) + else: + result = copy.copy(files) + for exclusion_filter in [x[1:] for x in filters if x[0] == '!']: + result = {file for file in result if not file.match(exclusion_filter)} pprint(f'{len(result)} files left') if print_files: pprint_only_file_names(result) return result -def clear_dir_by_patterns(path, file_patterns, recursive=False, print_files=False): +def clear_dir_by_patterns(path: Path, file_patterns: set[str], recursive: bool = False, + print_files: bool = False) -> None: found_files = search_files_by_patterns(path, file_patterns, recursive=recursive, print_files=print_files) for file in found_files: - os.remove(file) + file.unlink() pprint('Files removed') -def compare_files(file1, file2): - if not (os.path.isfile(file1) and os.path.isfile(file2)): - return False - with open(file1, 'r', encoding='ISO-8859-1') as f1: - data1 = f1.read() - with open(file2, 'r', encoding='ISO-8859-1') as f2: - data2 = f2.read() - return data1 == data2 +def compare_files(file1: Path, file2: Path) -> bool: + if file1.exists() and file2.exists(): + return file1.read_text(encoding=ISO_8859_1) == file2.read_text(encoding=ISO_8859_1) + return False -def cpu_count(): - count = os.cpu_count() - if count is None: - return 1 - return count +def cpu_count() -> int: + return os_cpu_count() or 1 -def get_or_none(array, index): - return array[index] if index < len(array) else None - - -def get_status(status): +def get_status(status: str) -> str: return statuses[status] -def get_file_name(path): - file = os.path.basename(path) - name = os.path.splitext(file)[0] - return name - - -def is_equal_float_strs(str_num1, str_num2): +def is_equal_float_strs(str_num1: str, str_num2: str) -> bool: str_num1, str_num2 = str_num1.replace(',', '.'), str_num2.replace(',', '.') try: return math.isclose(float(str_num1), float(str_num2), abs_tol=0.0001) @@ -136,7 +122,7 @@ def is_equal_float_strs(str_num1, str_num2): return False -def is_equal_hex_strs(str_num1, str_num2): +def is_equal_hex_strs(str_num1: str, str_num2: str) -> bool: try: if len(str_num1) == len(str_num2): return int(str_num1, 16) == int(str_num2, 16) @@ -149,26 +135,23 @@ def is_equal_hex_strs(str_num1, str_num2): return False -def make_name_from_path(path): - path = path.replace(os.sep, ' ').replace('.', '') - names = path.split() - return '.'.join(names) +def make_name_from_path(path: Path) -> str: + name = str(path).lstrip(os_sep).replace(os_sep, ' ').replace('.', '') + return '.'.join(name.split()) -def move_to_script_dir(path_to_script): - path_to_script = os.path.dirname(path_to_script) - if os.path.exists(path_to_script): - os.chdir(path_to_script) +def move_to_script_dir(path_to_script: Path) -> None: + if path_to_script.parent.exists(): + chdir(path_to_script.parent) -def pprint(*data, slowly=False, status=INFO, end='\n', on_the_next_line=False): +def pprint(*data: str | list, slowly: bool = False, status: str = INFO, end: str = '\n', + on_the_next_line: bool = False) -> None: if on_the_next_line: print() - if not data: - data = [''] - for token in data: + for token in data or ['']: if type(token) == list: - token = ''.join(list(map(str, token))) + token = ''.join(map(str, token)) for line in str(token).split('\n'): status_str = f'[{get_status(status)}] ' if status else '' print(f'{IWhite}{status_str}{line}', end=end) @@ -176,13 +159,13 @@ def pprint(*data, slowly=False, status=INFO, end='\n', on_the_next_line=False): time.sleep(0.01) -def pprint_header(header): +def pprint_header(header: str) -> None: pprint_separation_line() pprint(header, slowly=True) pprint_separation_line() -def pprint_status_result(name, status, log_data, max_lines=None): +def pprint_status_result(name: str, status: str, log_data: list[str] | str, max_lines: int = None) -> None: pprint(name, slowly=True, status=status) if max_lines: pprint_truncated_data(log_data, max_lines) @@ -190,30 +173,30 @@ def pprint_status_result(name, status, log_data, max_lines=None): pprint(log_data, slowly=True, status='') -def pprint_only_file_names(files): - names = list(map(lambda x: get_file_name(x), files)) - pprint(', '.join(sorted(names, key=str.casefold))) +def pprint_only_file_names(files: set[Path]) -> None: + pprint(', '.join(sorted({x.name for x in files}, key=str.casefold))) pprint() -def pprint_result(header, total_tests, total_time, result, is_failed): +def pprint_result(header: str, total_tests: int, total_seconds: int, + result: dict[str, set[str | str, str] | dict[str, dict[str, set[str]]]], is_failed: bool) -> None: pprint_header(f'{header} RESULTS') summary = [f'Total tests: {total_tests}'] for status in result: if status == PASS: if result[status]: - pprint_status_result(', '.join(sorted(result[status], key=str.casefold)), status, '') + pprint_status_result(', '.join(sorted(result[status], key=str.casefold)), status=status, log_data='') summary.append(f'Passed: {len(result[status])}') elif status in [NOTE, WARNING, EXCEPTION, SKIP] or (status == ERROR and type(result[status]) == dict): count = 0 for message, files in sorted(result[status].items(), key=lambda x: x[0].casefold()): - file_places = [] + file_places = set() for file, places in sorted(files.items(), key=lambda x: x[0].casefold()): if len(places): count += len(places) - file_places.append(f'{file}: [{", ".join(sorted(places))}]') + file_places.add(f'{file}: [{", ".join(sorted(places))}]') else: - file_places.append(f'{file}') + file_places.add(f'{file}') count += 1 file_places = ', '.join(file_places) if status == EXCEPTION and message.count('\n') > 2: @@ -229,17 +212,16 @@ def pprint_result(header, total_tests, total_time, result, is_failed): summary.append(f'{str(status).capitalize()}s: {len(result[status])}') pprint() pprint_separation_line() - pprint(f'{BRed}{header} FAILED{IWhite}') if is_failed else pprint(f'{BGreen}{header} SUCCESS{IWhite}') - summary = ', '.join(summary) - time_header = f'Total time: {total_time // 60:02}:{total_time % 60:02} min' - pprint_header(f'{summary}\n{time_header}') + pprint(f'{BRed}{header} FAILED{IWhite}' if is_failed else f'{BGreen}{header} SUCCESS{IWhite}') + time_header = f'Total time: {total_seconds // 60:02}:{total_seconds % 60:02} min' + pprint_header(f'{", ".join(summary)}\n{time_header}') -def pprint_separation_line(): +def pprint_separation_line() -> None: pprint(separation_line, slowly=True) -def pprint_truncated_data(data, max_lines): +def pprint_truncated_data(data: list[str] | str, max_lines: int) -> None: if type(data) == str: data = '\n'.join(data.split('\n')[:max_lines]) else: @@ -247,7 +229,7 @@ def pprint_truncated_data(data, max_lines): pprint(data, slowly=True, status='') -def print_progress_bar(i, n): +def print_progress_bar(i: int, n: int) -> None: cell_count = 20 cell_size = n / cell_count filled_cell_count = int(i / (float(n) / cell_count)) if n > 0 else cell_count @@ -261,40 +243,18 @@ def print_progress_bar(i, n): print(f'\r[{get_status(INFO)}] {percentage}|{bar}| {i}/{n}', end='') -def read_file_as_dictionary(path): - _, _, extension = split_path(path) - data = [] - if '.csv' == extension: - with open(path, newline='') as csvfile: - reader = csv.DictReader(csvfile) - for row in reader: - data.append(row) - elif '.json' == extension: - with open(path) as f: - data = json.load(f) - else: - pprint('unsupported file extension', status=EXCEPTION) - return data - - -def remove_empty_dirs(path): - is_removed = True - while is_removed: - is_removed = False - folders = list(os.walk(path))[1:] - for folder in folders: - if not folder[1] and not folder[2]: - os.rmdir(folder[0]) - is_removed = True +def remove_empty_dirs(path: Path) -> None: + [remove_empty_dirs(x) for x in path.iterdir() if x.is_dir()] + if not any(path.iterdir()): + path.rmdir() -def search_files_by_patterns(path, file_patterns, filters=None, recursive=False, print_files=False): - if recursive: - path = os.path.join(path, '**') +def search_files_by_patterns(path: Path, file_patterns: set[str], filters: set[str] = None, recursive: bool = False, + print_files: bool = False) -> set[Path]: pprint(f'\nLooking for "{file_patterns}" files in "{path}"') - found_files = [] + found_files = set() for pattern in file_patterns: - found_files.extend(glob.glob(os.path.join(path, pattern), recursive=recursive)) + found_files |= set(path.rglob(pattern) if recursive else path.glob(pattern)) pprint(f'Found {len(found_files)} files') if print_files: pprint_only_file_names(found_files) @@ -302,22 +262,12 @@ def search_files_by_patterns(path, file_patterns, filters=None, recursive=False, return found_files -def split_path(path_to_file, with_end_sep=False): - path, file = os.path.split(path_to_file) - if with_end_sep: - path += os.sep - file_name, extension = os.path.splitext(file) - return path, file_name, extension - - def thread_pool(): return ThreadPool(cpu_count()) -def version_compare(ver1, ver2): +def version_compare(ver1: str, ver2: str) -> int: for v1, v2 in zip(ver1.split('.'), ver2.split('.')): - if int(v1) > int(v2): - return 1 - elif int(v1) < int(v2): - return -1 + if diff := int(v1) - int(v2): + return diff return 0 diff --git a/project/scripts/transpile.py b/project/scripts/transpile.py index 75017ef8..702be56f 100755 --- a/project/scripts/transpile.py +++ b/project/scripts/transpile.py @@ -24,13 +24,16 @@ SOFTWARE. """ -import os import sys import time -import shutil import argparse import subprocess import re as regex +from os import chdir +from pathlib import Path +from shutil import copyfile +from os import sep as os_sep +from subprocess import CompletedProcess # Our scripts import tools @@ -41,45 +44,44 @@ class Transpiler(object): - def __init__(self, path_to_c_files, skips_file_name, need_to_prepare_c_code=True, need_to_generate_codecov=False): + def __init__(self, path_to_c_files: Path, skips_file_name: str, need_to_prepare_c_code: bool = True, + need_to_generate_codecov: bool = False): self.filters = None - if os.path.isfile(path_to_c_files): - self.filters = [os.path.split(path_to_c_files)[1]] - path_to_c_files = os.path.dirname(path_to_c_files) + if path_to_c_files.is_file(): + self.filters = {path_to_c_files.name} + path_to_c_files = path_to_c_files.parent self.skips = settings.get_skips(skips_file_name) if skips_file_name else {} - self.codecov_arg = 'LLVM_PROFILE_FILE="C%p.profraw"' if need_to_generate_codecov else '' self.need_to_generate_codecov = need_to_generate_codecov + self.codecov_arg = 'LLVM_PROFILE_FILE="C%p.profraw"' if self.need_to_generate_codecov else '' self.need_to_prepare_c_code = need_to_prepare_c_code self.path_to_c2eo_build = settings.get_setting('path_to_c2eo_build') self.path_to_c2eo_transpiler = settings.get_setting('path_to_c2eo_transpiler') - self.path_to_c_files = os.path.join(os.path.abspath(path_to_c_files), '') + self.path_to_c_files = path_to_c_files.resolve() self.path_to_eo_project = settings.get_setting('path_to_eo_project') - self.path_to_eo_src = os.path.join(os.path.abspath(settings.get_setting('path_to_eo_src')), '') - self.path_to_eo_external = os.path.join(os.path.abspath(settings.get_setting('path_to_eo_external')), '') + self.path_to_eo_src = settings.get_setting('path_to_eo_src').resolve() + self.path_to_eo_external = settings.get_setting('path_to_eo_external').resolve() self.plug_code = settings.get_meta_code('plug') self.result_dir_name = settings.get_setting('result_dir_name') self.run_sh_code = settings.get_meta_code('run.sh') self.run_sh_replace = settings.get_setting('run_sh_replace') - self.transpilation_units = [] - self.replaced_path = f'{os.path.split(self.path_to_c_files[:-1])[0]}{os.sep}' + self.transpilation_units: list[dict[str, str | Path | CompletedProcess]] = [] + self.replaced_path = self.path_to_c_files.parent self.files_handled_count = 0 - self.ignored_transpilation_warnings = settings.get_setting('ignored_transpilation_warnings') - if not self.ignored_transpilation_warnings: - self.ignored_transpilation_warnings = [] + self.ignored_transpilation_warnings = settings.get_setting('ignored_transpilation_warnings') or [] - def transpile(self): + def transpile(self) -> (list[dict[str, str | Path | CompletedProcess]], dict[str, dict[str, set[str]]]): start_time = time.time() self.build_c2eo() tools.pprint('\nTranspilation start\n') clean_before_transpilation.main(self.path_to_c_files) - c_files = tools.search_files_by_patterns(self.path_to_c_files, ['*.c'], filters=self.filters, recursive=True, + c_files = tools.search_files_by_patterns(self.path_to_c_files, {'*.c'}, filters=self.filters, recursive=True, print_files=True) with tools.thread_pool() as threads: self.transpilation_units = list(threads.map(self.make_unit, c_files)) generate_unique_names_for_units(self.transpilation_units) skip_result = self.check_skips() - original_path = os.getcwd() - os.chdir(self.path_to_c2eo_transpiler) + original_path = Path.cwd() + chdir(self.path_to_c2eo_transpiler) tools.pprint('\nTranspile files:\n', slowly=True) tools.print_progress_bar(0, len(self.transpilation_units)) with tools.thread_pool() as threads: @@ -87,7 +89,7 @@ def transpile(self): result = self.group_transpilation_results() result[tools.SKIP] = skip_result tests_count = len(self.transpilation_units) + sum(map(len, skip_result.values())) - is_failed = sum(map(len, result[tools.EXCEPTION].values())) + is_failed = sum(map(len, result[tools.EXCEPTION].values())) > 0 tools.pprint_result('TRANSPILE', tests_count, int(time.time() - start_time), result, is_failed) if is_failed: exit(f'transpilation failed') @@ -98,26 +100,27 @@ def transpile(self): if len(c_files) == 1: self.generate_run_sh(self.transpilation_units[0]['full_name']) tools.pprint('\nTranspilation done\n') - os.chdir(original_path) + chdir(original_path) return self.transpilation_units, skip_result - def build_c2eo(self): + def build_c2eo(self) -> None: if self.need_to_generate_codecov: build_c2eo.main(self.path_to_c2eo_build, 'cmake -D CMAKE_CXX_COMPILER="/bin/clang++" -D CMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS ' '-fprofile-instr-generate -fcoverage-mapping" .. ') else: - build_c2eo.main(self.path_to_c2eo_build) + build_c2eo.main(self.path_to_c2eo_build, + 'cmake -D CMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS -fsanitize=address" .. ') - def make_unit(self, c_file): - path, name, _ = tools.split_path(c_file, with_end_sep=True) - rel_c_path = path.replace(self.replaced_path, '') - full_name = f'{tools.make_name_from_path(rel_c_path)}.{name}' - prepared_c_file, result_path = self.prepare_c_file(path, name, c_file) + def make_unit(self, c_file: Path) -> dict[str, str | Path]: + rel_c_path = Path(str(c_file.parent).replace(str(self.replaced_path), '').lstrip(os_sep)) + full_name = f'{tools.make_name_from_path(rel_c_path)}.{c_file.stem}' + prepared_c_file, result_path = self.prepare_c_file(c_file) return {'c_file': c_file, 'rel_c_path': rel_c_path, 'full_name': full_name, 'prepared_c_file': prepared_c_file, - 'result_path': result_path, 'name': name, 'unique_name': name} + 'result_path': result_path, 'name': c_file.stem, 'unique_name': c_file.stem, + 'prepared_c_i_file': prepared_c_file.with_suffix('.c.i')} - def check_skips(self): + def check_skips(self) -> dict[str, dict[str, set[str]]]: skip_units = [] skips = {} for unit in self.transpilation_units: @@ -130,49 +133,47 @@ def check_skips(self): self.transpilation_units = list(filter(lambda x: x not in skip_units, self.transpilation_units)) return skips - def start_transpilation(self, unit): - eo_file = f'{unit["full_name"]}.eo' + def start_transpilation(self, unit: dict[str, str | Path | CompletedProcess]) -> None: + eo_file = Path(f'{unit["full_name"]}.eo') transpile_cmd = f'{self.codecov_arg} ./c2eo {unit["prepared_c_file"]} {eo_file}' result = subprocess.run(transpile_cmd, shell=True, capture_output=True, text=True) self.files_handled_count += 1 unit['transpilation_result'] = result - unit['eo_file'] = os.path.abspath(eo_file) - unit['rel_eo_file'] = os.path.join(unit["rel_c_path"], f'{unit["name"]}.eo') + unit['eo_file'] = eo_file.resolve() + unit['rel_eo_file'] = unit['rel_c_path'] / f'{unit["name"]}.eo' if not result.returncode: add_return_code_to_eo_file(eo_file) tools.print_progress_bar(self.files_handled_count, len(self.transpilation_units)) - def prepare_c_file(self, path, file_name, c_file): - with open(f'{c_file}', 'r', encoding='ISO-8859-1') as f: + def prepare_c_file(self, c_file: Path) -> (Path, Path): + with open(c_file, 'r', encoding=tools.ISO_8859_1) as f: data = f.readlines() if self.need_to_prepare_c_code: prepare_c_code(data) - result_path = os.path.join(path, self.result_dir_name) - prepared_c_file = os.path.join(path, f'{file_name}-eo.c') - if not os.path.exists(result_path): - os.makedirs(result_path, exist_ok=True) + result_path = c_file.parent / self.result_dir_name + prepared_c_file = c_file.parent / f'{c_file.stem}-eo.c' + result_path.mkdir(exist_ok=True, parents=True) with open(prepared_c_file, 'w') as f: f.writelines(data) return prepared_c_file, result_path - def remove_unused_eo_files(self): - transpiled_eo_names = set(map(lambda x: x['rel_eo_file'], self.transpilation_units)) - src_eo_names = tools.search_files_by_patterns(self.path_to_eo_src, ['*.eo'], recursive=True) - src_eo_names = set(map(lambda x: x.replace(self.path_to_eo_src, ''), src_eo_names)) + def remove_unused_eo_files(self) -> None: + src_eo_names = tools.search_files_by_patterns(self.path_to_eo_src, {'*.eo'}, recursive=True) + src_eo_names = {Path(str(x).replace(str(self.path_to_eo_src), '').lstrip(os_sep)) for x in src_eo_names} + transpiled_eo_names = {x['rel_eo_file'] for x in self.transpilation_units} for name in src_eo_names - transpiled_eo_names: - os.remove(f'{self.path_to_eo_src}{name}') + (self.path_to_eo_src / name).unlink() for unit in self.transpilation_units: - unit['src_eo_path'] = os.path.join(self.path_to_eo_src, unit['rel_c_path']) - unit['src_eo_file'] = os.path.join(unit['src_eo_path'], f'{unit["name"]}.eo') + unit['src_eo_path'] = self.path_to_eo_src / unit['rel_c_path'] + unit['src_eo_file'] = unit['src_eo_path'] / f'{unit["name"]}.eo' tools.remove_empty_dirs(self.path_to_eo_src) - def create_plug_file(self, unit, message): + def create_plug_file(self, unit: dict[str, str | Path | CompletedProcess], message: str) -> None: plug = regex.sub('', unit['full_name'], self.plug_code) plug = regex.sub('', message, plug) - with open(unit['eo_file'], 'w') as f: - f.write(plug) + unit['eo_file'].write_text(plug) - def group_transpilation_results(self): + def group_transpilation_results(self) -> dict[str, set[str] | dict[str, dict[str, set[str]]]]: result = {tools.PASS: set([unit['unique_name'] for unit in self.transpilation_units]), tools.NOTE: {}, tools.WARNING: {}, tools.ERROR: {}, tools.EXCEPTION: {}} tools.pprint('\nGetting results\n', slowly=True, on_the_next_line=True) @@ -204,20 +205,18 @@ def group_transpilation_results(self): result[tools.PASS] -= set(file for value in result[status].values() for file in value.keys()) return result - def move_transpiled_files(self): + def move_transpiled_files(self) -> None: difference = [] for unit in self.transpilation_units: - shutil.copy(unit['eo_file'], os.path.join(unit['result_path'], f'{unit["name"]}.eo')) - shutil.move(unit['prepared_c_file'], unit['result_path']) - shutil.move(f'{unit["prepared_c_file"]}.i', unit['result_path']) + copyfile(unit['eo_file'], unit['result_path'] / f'{unit["name"]}.eo') + unit['prepared_c_file'].replace(unit['result_path'] / unit['prepared_c_file'].name) + unit['prepared_c_i_file'].replace(unit['result_path'] / unit['prepared_c_i_file'].name) if not tools.compare_files(unit['eo_file'], unit['src_eo_file']): - if not os.path.exists(unit['src_eo_path']): - os.makedirs(unit['src_eo_path'], exist_ok=True) - shutil.move(unit['eo_file'], unit['src_eo_file']) + unit['src_eo_path'].mkdir(parents=True, exist_ok=True) + unit['eo_file'].replace(unit['src_eo_file']) difference.append(unit['eo_file']) - if os.path.isfile(unit['eo_file']): - os.remove(unit['eo_file']) - difference = list(filter(lambda x: x, difference)) # Filter None values + unit['eo_file'].unlink(missing_ok=True) + difference = set(filter(lambda x: x, difference)) # Filter None values if difference: tools.pprint(f'\nDetected changes in src files:') tools.pprint_only_file_names(difference) @@ -225,23 +224,20 @@ def move_transpiled_files(self): else: tools.pprint('\nNot found any changes in src files') - def move_aliases(self): - aliases = tools.search_files_by_patterns('.', ['*.alias'], print_files=True) - if not os.path.exists(self.path_to_eo_external): - os.makedirs(self.path_to_eo_external, exist_ok=True) - tools.clear_dir_by_patterns(self.path_to_eo_external, ['*.eo']) + def move_aliases(self) -> None: + aliases = tools.search_files_by_patterns(Path(), {'*.alias'}, print_files=True) + self.path_to_eo_external.mkdir(exist_ok=True, parents=True) + tools.clear_dir_by_patterns(self.path_to_eo_external, {'*.eo'}) for alias in aliases: - file_name = tools.get_file_name(alias) - destination_file = os.path.join(self.path_to_eo_external, file_name) - shutil.move(alias, destination_file) + alias.replace(self.path_to_eo_external / alias.stem) - def generate_run_sh(self, full_name): + def generate_run_sh(self, full_name: str) -> None: code = regex.sub(self.run_sh_replace, full_name, self.run_sh_code) with open(f'{self.path_to_eo_project}run.sh', 'w') as f: f.write(code) -def generate_unique_names_for_units(units, words_in_name=2): +def generate_unique_names_for_units(units: list[dict[str, str | CompletedProcess]], words_in_name: int = 2) -> None: names = {} collision_names = {} for unit in units: @@ -255,16 +251,17 @@ def generate_unique_names_for_units(units, words_in_name=2): for name, _units in collision_names.items(): units.extend(_units) for unit in _units: - unit['unique_name'] = f'{os.sep.join(unit["rel_c_path"].split(os.sep)[-words_in_name:])}{unit["name"]}' + unit['unique_name'] = str(Path(*unit['rel_c_path'].parts[-words_in_name:]) / unit['name']) if len(collision_names) > 0: generate_unique_names_for_units(units, words_in_name + 1) -def add_return_code_to_eo_file(eo_file): - with open(f'{eo_file}', 'r', encoding='ISO-8859-1') as f: +def add_return_code_to_eo_file(eo_file: Path) -> None: + with open(f'{eo_file}', 'r', encoding=tools.ISO_8859_1) as f: data = f.readlines() is_main = False - aliases = {'+alias c2eo.coperators.printf\n', '+alias c2eo.coperators.read-as-int32\n'} + aliases = {'+alias c2eo.coperators.printf\n', '+alias c2eo.coperators.read-as-int32\n', + '+alias c2eo.coperators.as-uint8\n'} aliases_count = 0 for i, line in enumerate(data): if line.startswith('+alias'): @@ -276,26 +273,26 @@ def add_return_code_to_eo_file(eo_file): data[i] = ' write-as-int32 return 0\n goto-return-label.forward TRUE\n' aliases.add('+alias c2eo.coperators.write-as-int32\n') break - data[-1] = ' printf "%d" (read-as-int32 return)\n' - with open(f'{eo_file}', 'w', encoding='ISO-8859-1') as f: + data[-1] = ' printf "%d" (as-uint8 (read-as-int32 return))\n' + with open(f'{eo_file}', 'w', encoding=tools.ISO_8859_1) as f: f.writelines(sorted(aliases)) f.writelines(data[aliases_count:]) -def check_unit_exception(unit): +def check_unit_exception(unit: dict[str, str | Path | CompletedProcess]) -> str: exception_message = '' if unit['transpilation_result'].returncode: exception_message = '\n'.join(unit['transpilation_result'].stderr.split('\n')[-3:-1]) - elif not os.path.isfile(unit['eo_file']): + elif not unit['eo_file'].exists(): exception_message = 'was generated empty EO file' - elif os.stat(unit['eo_file']).st_size == 0: + elif unit['eo_file'].stat().st_size == 0: exception_message = 'the EO file was not generated' - if not os.path.isfile(unit['eo_file']): + if not unit['eo_file'].exists(): open(unit['eo_file'], 'a').close() return exception_message -def prepare_c_code(data): +def prepare_c_code(data: list[str]) -> None: for i, line in enumerate(data): if '#include' in line: new_line = line.lstrip() @@ -304,7 +301,7 @@ def prepare_c_code(data): data[i] = f'{indent}// {new_line}' -def create_parser(): +def create_parser() -> argparse.ArgumentParser: _parser = argparse.ArgumentParser(description='the script for translating C files to the EO files') _parser.add_argument('path_to_c_files', metavar='PATH', @@ -322,8 +319,8 @@ def create_parser(): if __name__ == '__main__': - tools.move_to_script_dir(sys.argv[0]) + tools.move_to_script_dir(Path(sys.argv[0])) parser = create_parser() namespace = parser.parse_args() - Transpiler(os.path.abspath(namespace.path_to_c_files), namespace.skips_file_name, + Transpiler(Path(namespace.path_to_c_files).resolve(), namespace.skips_file_name, not namespace.not_prepare_c_code, namespace.codecov).transpile() diff --git a/project/scripts/update_eo_version.py b/project/scripts/update_eo_version.py deleted file mode 100755 index 473172ea..00000000 --- a/project/scripts/update_eo_version.py +++ /dev/null @@ -1,92 +0,0 @@ -#! /usr/bin/python3 - -""" -The MIT License (MIT) - -Copyright (c) 2021-2022 c2eo team - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -""" - -import sys -import re as regex - -# Our scripts -import tools -import settings - - -def main(): - tools.pprint() - current_version = settings.get_setting('current_eo_version') - latest_version = settings.get_setting('latest_eo_version') - - is_latest_version, latest_version = is_update_needed(current_version, latest_version) - if is_latest_version: - return - - path_to_eo_project = settings.get_setting('path_to_eo_project') - found_files = tools.search_files_by_patterns(path_to_eo_project, ['pom.xml'], recursive=True) - update_version_in_files(found_files, latest_version) - settings.set_setting('current_eo_version', latest_version) - tools.pprint('EO version updated\n') - - -def is_update_needed(current_version, latest_version): - compare = tools.version_compare(current_version, latest_version) - is_latest_version = False - if compare == 1: - latest_version = current_version - tools.pprint(f'Manual update latest EO version to {latest_version}', status=tools.WARNING) - elif compare == 0: - is_latest_version = True - tools.pprint('We use latest EO version', status=tools.PASS) - tools.pprint() - else: - tools.pprint(f'We use old EO version: "{current_version}"', status=tools.WARNING) - tools.pprint(f'Start updating files') - - return is_latest_version, latest_version - - -def update_version_in_files(files, latest_version): - tools.pprint('Updating version') - count_changed_files = 0 - pattern = r'.*<\/eolang\.version>' - latest_version_declaration = f'{latest_version}' - for file in files: - with open(file, 'r') as f: - data = f.read() - - result = regex.search(pattern, data) - if (not result) or (latest_version_declaration in result.group()): - continue - - new_data = regex.sub(pattern, latest_version_declaration, data) - with open(file, 'w') as f: - f.write(new_data) - count_changed_files += 1 - - tools.pprint(f'{count_changed_files} files updated') - return count_changed_files - - -if __name__ == '__main__': - tools.move_to_script_dir(sys.argv[0]) - main() diff --git a/project/src/transpiler/main.cpp b/project/src/transpiler/main.cpp index c78651fc..fec3950a 100644 --- a/project/src/transpiler/main.cpp +++ b/project/src/transpiler/main.cpp @@ -129,6 +129,8 @@ int main(int argc, const char **argv) { auto expected_parser = CommonOptionsParser::create( parser_argc, parser_argv, MyToolCategory, llvm::cl::Optional); + delete[] parser_argv; + if (!expected_parser) { // Fail gracefully for unsupported options. llvm::errs() << expected_parser.takeError(); diff --git a/project/src/transpiler/memory_manager.cpp b/project/src/transpiler/memory_manager.cpp index 76bbadae..0f8e77d7 100644 --- a/project/src/transpiler/memory_manager.cpp +++ b/project/src/transpiler/memory_manager.cpp @@ -33,11 +33,19 @@ #include "src/transpiler/transpile_helper.h" Variable MemoryManager::Add(const clang::VarDecl *id, size_t size, - const std::string &type, std::string alias, + const std::string &type, const std::string &alias, EOObject value, std::string local_name, size_t shift, bool is_initialized) { + auto res = find_if(variables_.begin(), variables_.end(), + [id](const Variable &x) { return x.id == id; }); + if (res != variables_.end()) { + return *res; + } + std::string unique_alias; if (duplicates[alias] > 0) { - alias += "-" + std::to_string(duplicates[alias]); + unique_alias = alias + "-" + std::to_string(duplicates[alias]); + } else { + unique_alias = alias; } duplicates[alias]++; std::string type_postfix = type.substr(2); @@ -53,7 +61,7 @@ Variable MemoryManager::Add(const clang::VarDecl *id, size_t size, pointer_, size, type, - std::move(alias), + std::move(unique_alias), std::move(value), std::move(local_name), shift, @@ -148,8 +156,9 @@ EOObject MemoryManager::GetEOObject() const { void MemoryManager::RemoveAllUsed(const std::vector &all_local) { for (const auto &var : all_local) { - pointer_ -= var.size; - variables_.erase(find(variables_.begin(), variables_.end(), var)); + auto var_in_memory = find(variables_.begin(), variables_.end(), var); + pointer_ -= var_in_memory->size; + variables_.erase(var_in_memory); } } diff --git a/project/src/transpiler/memory_manager.h b/project/src/transpiler/memory_manager.h index 1fd1a06a..a094c091 100644 --- a/project/src/transpiler/memory_manager.h +++ b/project/src/transpiler/memory_manager.h @@ -27,6 +27,7 @@ static const int some_non_zero_position = 999999; static const int eight_kilobytes = 8192; +static const int eight_bytes = 8; #include #include #include @@ -72,11 +73,12 @@ class MemoryManager { public: [[maybe_unused]] explicit MemoryManager(std::string name, size_t start_pointer = 8) - : pointer_(start_pointer), name_(std::move(name)) {} + : name_(std::move(name)), pointer_(start_pointer) {} Variable Add(const clang::VarDecl *id, size_t size, const std::string &type, - std::string alias, EOObject value, std::string local_name = "", - size_t shift = 0, bool is_initialized = true); + const std::string &alias, EOObject value, + std::string local_name = "", size_t shift = 0, + bool is_initialized = true); Variable AddExternal(const clang::VarDecl *id, size_t size, const std::string &type, std::string alias, @@ -104,7 +106,7 @@ class MemoryManager { private: // index of first free byte in memory - size_t pointer_; + size_t pointer_ = eight_bytes; int mem_size_ = eight_kilobytes; std::vector variables_; std::map duplicates; diff --git a/project/src/transpiler/process_variables.cpp b/project/src/transpiler/process_variables.cpp index 9abf96e0..cf9a19ad 100644 --- a/project/src/transpiler/process_variables.cpp +++ b/project/src/transpiler/process_variables.cpp @@ -46,141 +46,163 @@ using std::vector; extern UnitTranspiler transpiler; void ProcessDeclStmt(size_t shift, vector &all_local, - DeclStmt *decl_stmt); + DeclStmt *decl_stmt, bool process_only_static); void ProcessForStmtLocalVariables(vector &all_local, size_t shift, - ForStmt *for_stmt); + ForStmt *for_stmt, bool process_only_static); void ProcessWhileStmtLocalVariables(vector &all_local, size_t shift, - WhileStmt *while_stmt); + WhileStmt *while_stmt, + bool process_only_static); void ProcessCaseStmtLocalVariables(vector &all_local, size_t shift, - CaseStmt *case_stmt); + CaseStmt *case_stmt, + bool process_only_static); void ProcessIfStmtLocalVariables(vector &all_local, size_t shift, - IfStmt *if_stmt); + IfStmt *if_stmt, bool process_only_static); void ProcessDefaultStmtLocalVariables(vector &all_local, size_t shift, - DefaultStmt *default_stmt); + DefaultStmt *default_stmt, + bool process_only_static); void ProcessSwitchStmtLocalVariables(vector &all_local, size_t shift, - SwitchStmt *switch_stmt); + SwitchStmt *switch_stmt, + bool process_only_static); void ProcessDoStmtLocalVariables(vector &all_local, size_t shift, - DoStmt *do_stmt); + DoStmt *do_stmt, bool process_only_static); void ProcessStmtLocalVariables(vector &all_local, size_t shift, - Stmt *stmt) { + Stmt *stmt, bool process_only_static) { Stmt::StmtClass stmt_class = stmt->getStmtClass(); if (stmt_class == Stmt::DeclStmtClass) { auto *decl_stmt = dyn_cast(stmt); - ProcessDeclStmt(shift, all_local, decl_stmt); + ProcessDeclStmt(shift, all_local, decl_stmt, process_only_static); } else if (stmt_class == Stmt::ForStmtClass) { auto *for_stmt = dyn_cast(stmt); - ProcessForStmtLocalVariables(all_local, shift, for_stmt); + ProcessForStmtLocalVariables(all_local, shift, for_stmt, + process_only_static); } else if (stmt_class == Stmt::CompoundStmtClass) { auto *compound_stmt = dyn_cast(stmt); - ProcessFunctionLocalVariables(compound_stmt, all_local, shift); + ProcessFunctionLocalVariables(compound_stmt, all_local, shift, + process_only_static); } else if (stmt_class == Stmt::WhileStmtClass) { auto *while_stmt = dyn_cast(stmt); - ProcessWhileStmtLocalVariables(all_local, shift, while_stmt); + ProcessWhileStmtLocalVariables(all_local, shift, while_stmt, + process_only_static); } else if (stmt_class == Stmt::SwitchStmtClass) { auto *switch_stmt = dyn_cast(stmt); - ProcessSwitchStmtLocalVariables(all_local, shift, switch_stmt); + ProcessSwitchStmtLocalVariables(all_local, shift, switch_stmt, + process_only_static); } else if (stmt_class == Stmt::DoStmtClass) { auto *do_stmt = dyn_cast(stmt); - ProcessDoStmtLocalVariables(all_local, shift, do_stmt); + ProcessDoStmtLocalVariables(all_local, shift, do_stmt, process_only_static); } else if (stmt_class == Stmt::CaseStmtClass) { auto *case_stmt = dyn_cast(stmt); - ProcessCaseStmtLocalVariables(all_local, shift, case_stmt); + ProcessCaseStmtLocalVariables(all_local, shift, case_stmt, + process_only_static); } else if (stmt_class == Stmt::DefaultStmtClass) { auto *default_stmt = dyn_cast(stmt); - ProcessDefaultStmtLocalVariables(all_local, shift, default_stmt); + ProcessDefaultStmtLocalVariables(all_local, shift, default_stmt, + process_only_static); } else if (stmt_class == Stmt::IfStmtClass) { auto *if_stmt = dyn_cast(stmt); - ProcessIfStmtLocalVariables(all_local, shift, if_stmt); + ProcessIfStmtLocalVariables(all_local, shift, if_stmt, process_only_static); } } void ProcessFunctionLocalVariables(const clang::CompoundStmt *CS, std::vector &all_local, - size_t shift) { + size_t shift, bool process_only_static) { if (CS == nullptr) { return; } for (auto *stmt : CS->body()) { - ProcessStmtLocalVariables(all_local, shift, stmt); + ProcessStmtLocalVariables(all_local, shift, stmt, process_only_static); } } void ProcessDoStmtLocalVariables(vector &all_local, size_t shift, - DoStmt *do_stmt) { + DoStmt *do_stmt, bool process_only_static) { if (do_stmt == nullptr) { return; } if (do_stmt->getBody() != nullptr && do_stmt->getBody()->getStmtClass() == Stmt::CompoundStmtClass) { auto *compound_stmt = dyn_cast(do_stmt->getBody()); - ProcessFunctionLocalVariables(compound_stmt, all_local, shift); + ProcessFunctionLocalVariables(compound_stmt, all_local, shift, + process_only_static); } } void ProcessSwitchStmtLocalVariables(vector &all_local, size_t shift, - SwitchStmt *switch_stmt) { + SwitchStmt *switch_stmt, + bool process_only_static) { if (switch_stmt == nullptr) { return; } if (switch_stmt->getBody() != nullptr && switch_stmt->getBody()->getStmtClass() == Stmt::CompoundStmtClass) { auto *compound_stmt = dyn_cast(switch_stmt->getBody()); - ProcessFunctionLocalVariables(compound_stmt, all_local, shift); + ProcessFunctionLocalVariables(compound_stmt, all_local, shift, + process_only_static); } } void ProcessDefaultStmtLocalVariables(vector &all_local, size_t shift, - DefaultStmt *default_stmt) { + DefaultStmt *default_stmt, + bool process_only_static) { if (default_stmt == nullptr) { return; } if (default_stmt->getSubStmt() != nullptr && default_stmt->getSubStmt()->getStmtClass() == Stmt::CompoundStmtClass) { auto *compound_stmt = dyn_cast(default_stmt->getSubStmt()); - ProcessFunctionLocalVariables(compound_stmt, all_local, shift); + ProcessFunctionLocalVariables(compound_stmt, all_local, shift, + process_only_static); } else if (default_stmt->getSubStmt() != nullptr && default_stmt->getSubStmt()->getStmtClass() == Stmt::DeclStmtClass) { auto *decl_stmt = dyn_cast(default_stmt->getSubStmt()); - ProcessDeclStmt(shift, all_local, decl_stmt); + ProcessDeclStmt(shift, all_local, decl_stmt, process_only_static); } } void ProcessIfStmtLocalVariables(vector &all_local, size_t shift, - IfStmt *if_stmt) { + IfStmt *if_stmt, bool process_only_static) { if (if_stmt == nullptr) { return; } if (if_stmt->getThen() != nullptr) { - ProcessStmtLocalVariables(all_local, shift, if_stmt->getThen()); + ProcessStmtLocalVariables(all_local, shift, if_stmt->getThen(), + process_only_static); } if (if_stmt->getElse() != nullptr) { - ProcessStmtLocalVariables(all_local, shift, if_stmt->getElse()); + ProcessStmtLocalVariables(all_local, shift, if_stmt->getElse(), + process_only_static); } } void ProcessCaseStmtLocalVariables(vector &all_local, size_t shift, - CaseStmt *case_stmt) { + CaseStmt *case_stmt, + bool process_only_static) { if (case_stmt == nullptr || case_stmt->getSubStmt() == nullptr) { return; } - ProcessStmtLocalVariables(all_local, shift, case_stmt->getSubStmt()); + ProcessStmtLocalVariables(all_local, shift, case_stmt->getSubStmt(), + process_only_static); } void ProcessWhileStmtLocalVariables(vector &all_local, size_t shift, - WhileStmt *while_stmt) { + WhileStmt *while_stmt, + bool process_only_static) { if (while_stmt == nullptr || while_stmt->getBody() == nullptr) { return; } - ProcessStmtLocalVariables(all_local, shift, while_stmt->getBody()); + ProcessStmtLocalVariables(all_local, shift, while_stmt->getBody(), + process_only_static); } void ProcessForStmtLocalVariables(vector &all_local, size_t shift, - ForStmt *for_stmt) { + ForStmt *for_stmt, bool process_only_static) { if (for_stmt == nullptr) { return; } if (for_stmt->getInit() != nullptr && for_stmt->getInit()->getStmtClass() == Stmt::DeclStmtClass) { auto *decl_stmt = dyn_cast(for_stmt->getInit()); - ProcessDeclStmt(shift, all_local, decl_stmt); + ProcessDeclStmt(shift, all_local, decl_stmt, process_only_static); } if (for_stmt->getBody() != nullptr) { - ProcessStmtLocalVariables(all_local, shift, for_stmt->getBody()); + ProcessStmtLocalVariables(all_local, shift, for_stmt->getBody(), + process_only_static); } } @@ -231,7 +253,7 @@ void ProcessCompoundStatementLocalVariables(const clang::CompoundStmt *CS, } void ProcessDeclStmt(size_t shift, vector &all_local, - DeclStmt *decl_stmt) { + DeclStmt *decl_stmt, bool process_only_static) { if (decl_stmt == nullptr) { return; } @@ -239,8 +261,10 @@ void ProcessDeclStmt(size_t shift, vector &all_local, Decl::Kind decl_kind = decl->getKind(); if (decl_kind == Decl::Var) { auto *var_decl = dyn_cast(decl); - if (var_decl != nullptr && !var_decl->isStaticLocal()) { - all_local.push_back(ProcessVariable(var_decl, "local-start", shift)); + if (var_decl != nullptr) { + if (var_decl->isStaticLocal() == process_only_static) { + all_local.push_back(ProcessVariable(var_decl, "local-start", shift)); + } } } } diff --git a/project/src/transpiler/process_variables.h b/project/src/transpiler/process_variables.h index b59e654b..faa7ae6a 100644 --- a/project/src/transpiler/process_variables.h +++ b/project/src/transpiler/process_variables.h @@ -31,7 +31,7 @@ void ProcessFunctionLocalVariables(const clang::CompoundStmt* CS, std::vector& all_local, - size_t shift); + size_t shift, bool process_only_static); void ProcessCompoundStatementLocalVariables(const clang::CompoundStmt* CS, std::vector& all_local); diff --git a/project/src/transpiler/transpile_helper.cpp b/project/src/transpiler/transpile_helper.cpp index acf89bf7..1f03bb20 100644 --- a/project/src/transpiler/transpile_helper.cpp +++ b/project/src/transpiler/transpile_helper.cpp @@ -133,6 +133,8 @@ EOObject GetSeqForBodyEOObject(const Stmt *p_stmt); uint64_t GetTypeSize(QualType qual_type); +uint64_t GetSizeOfType(QualType qual_type); + EOObject GetCastEOObject(const CastExpr *op); EOObject GetSwitchEOObject(const SwitchStmt *p_stmt); @@ -204,18 +206,29 @@ EOObject GetFunctionBody(const clang::FunctionDecl *FD) { return EOObject(EOObjectType::EO_EMPTY); } size_t shift = transpiler.glob_.GetFreeSpacePointer(); + vector all_static_local; + ProcessFunctionLocalVariables(func_body, all_static_local, shift, true); + shift = transpiler.glob_.GetFreeSpacePointer(); size_t param_memory_size = GetParamMemorySize(FD->parameters()); vector all_param = ProcessFunctionParams(FD->parameters(), shift); vector all_types = PrecessRecordTypes(func_body); + vector all_local; - ProcessFunctionLocalVariables(func_body, all_local, - shift + param_memory_size); + ProcessFunctionLocalVariables(func_body, all_local, shift + param_memory_size, + false); EOObject func_body_eo = EOObject(EOObjectType::EO_EMPTY); EOObject local_start("plus", "local-start"); local_start.nested.emplace_back("param-start"); local_start.nested.emplace_back("param-size"); func_body_eo.nested.push_back(local_start); - size_t free_pointer = transpiler.glob_.GetFreeSpacePointer(); + size_t local_static_size = 0; + for (const auto &var : all_local) { + if (var.id->isStaticLocal()) { + local_static_size += var.size; + } + } + size_t free_pointer = + transpiler.glob_.GetFreeSpacePointer() - local_static_size; EOObject local_empty_position("plus", "empty-local-position"); local_empty_position.nested.emplace_back("local-start"); local_empty_position.nested.emplace_back( @@ -229,6 +242,9 @@ EOObject GetFunctionBody(const clang::FunctionDecl *FD) { func_body_eo.nested.push_back(var); } for (const auto &var : all_local) { + if (var.id->isStaticLocal()) { + continue; + } func_body_eo.nested.push_back(var.GetAddress(transpiler.glob_.name_)); } EOObject goto_object{"goto", "@"}; @@ -435,11 +451,7 @@ EOObject GetStmtEOObject(const Stmt *stmt) { } if (stmt_class == Stmt::UnaryExprOrTypeTraitExprClass) { const auto *op = dyn_cast(stmt); - // Need to release instead this code return GetUnaryExprOrTypeTraitExprEOObject(op); - // llvm::errs() << "Warning: Noreleased statement " - // << stmt->getStmtClassName() << "\n"; - // return EOObject(EOObjectType::EO_PLUG); } if (stmt_class == Stmt::StringLiteralClass) { const auto *op = dyn_cast(stmt); @@ -590,9 +602,20 @@ EOObject GetSwitchEOObject(const SwitchStmt *p_stmt) { eq_obj.nested.push_back(GetStmtEOObject(case_stmt->getLHS())); cond_obj.nested.push_back( GetCaseCondEOObject(all_cases, switch_expr_object, 0)); - if_obj.nested.push_back(cond_obj); + if (nested != nullptr && + nested->getStmtClass() == Stmt::DefaultStmtClass) { + EOObject always_true_obj{"or"}; + always_true_obj.nested.push_back(cond_obj); + always_true_obj.nested.emplace_back("TRUE", EOObjectType::EO_LITERAL); + if_obj.nested.push_back(always_true_obj); + const auto *def_stmt = dyn_cast(nested); + nested = def_stmt->getSubStmt(); + } else { + if_obj.nested.push_back(cond_obj); + } EOObject buffer_obj{"seq"}; - if (nested != nullptr) { + if (nested != nullptr && + nested->getStmtClass() != Stmt::DefaultStmtClass) { buffer_obj.nested.push_back(GetStmtEOObject(nested)); } auto tmp = stmt; @@ -606,6 +629,27 @@ EOObject GetSwitchEOObject(const SwitchStmt *p_stmt) { buffer_obj.nested.emplace_back("TRUE", EOObjectType::EO_LITERAL); if_obj.nested.push_back(buffer_obj); seq_object.nested.push_back(if_obj); + + if (nested != nullptr && + nested->getStmtClass() == Stmt::DefaultStmtClass) { + const auto *default_stmt = dyn_cast(nested); + EOObject buffer_obj_def{"seq"}; + if (default_stmt->getSubStmt() != nullptr) { + buffer_obj_def.nested.push_back( + GetStmtEOObject(default_stmt->getSubStmt())); + } + auto tmp_def = stmt; + tmp_def++; + while (tmp_def != end && + (*tmp_def)->getStmtClass() != Stmt::CaseStmtClass && + (*tmp_def)->getStmtClass() != Stmt::DefaultStmtClass) { + buffer_obj_def.nested.push_back(GetStmtEOObject(*tmp_def)); + tmp_def++; + } + buffer_obj_def.nested.push_back(set_flag_object); + buffer_obj_def.nested.emplace_back("TRUE", EOObjectType::EO_LITERAL); + seq_object.nested.push_back(buffer_obj_def); + } } else if ((*stmt)->getStmtClass() == Stmt::DefaultStmtClass) { const auto *default_stmt = dyn_cast(*stmt); EOObject buffer_obj{"seq"}; @@ -751,7 +795,9 @@ EOObject GetArraySubscriptExprEOObject(const ArraySubscriptExpr *op, if (tmp_dims.size() > dims->size()) { dims = &tmp_dims; } + uint64_t dim_size = decl_info.first; // current dimension size. + for (int i = 0; i < depth && i < dims->size(); ++i) { dim_size *= dims->at(i); } @@ -778,20 +824,49 @@ EOObject GetArraySubscriptExprEOObject(const ArraySubscriptExpr *op, add_shift.nested.emplace_back(next_shift); if (depth == 0) { + // TEST + // std::cout << "depth == 0\n"; EOObject final_write{"plus"}; final_write.nested.emplace_back(decl_info.second); final_write.nested.emplace_back(add_shift); - return final_write; + // return final_write; + EOObject addr{"address"}; + EOObject glob_ram{"global-ram"}; + addr.nested.emplace_back(glob_ram); + addr.nested.emplace_back(final_write); + return addr; } return add_shift; } - if (stmt_class == Stmt::DeclRefExprClass || - stmt_class == Stmt::MemberExprClass) { + if (stmt_class == Stmt::DeclRefExprClass) { + if (depth == 0) { + // TEST + // std::cout << "(Stmt::DeclRefExprClass || Stmt::MemberExprClass) && + // depth == 0\n"; + EOObject final_write{"plus"}; + final_write.nested.emplace_back(decl_info.second); + final_write.nested.emplace_back(curr_shift); + // return final_write; + EOObject addr{"address"}; + EOObject glob_ram{"global-ram"}; + addr.nested.emplace_back(glob_ram); + addr.nested.emplace_back(final_write); + return addr; + } + } else if (stmt_class == Stmt::MemberExprClass) { if (depth == 0) { + // TEST + // std::cout << "(Stmt::DeclRefExprClass || Stmt::MemberExprClass) && + // depth == 0\n"; EOObject final_write{"plus"}; final_write.nested.emplace_back(decl_info.second); final_write.nested.emplace_back(curr_shift); return final_write; + // EOObject addr{"address"}; + // EOObject glob_ram{"global-ram"}; + // addr.nested.emplace_back(glob_ram); + // addr.nested.emplace_back(final_write); + // return addr; } } return curr_shift; @@ -980,8 +1055,15 @@ EOObject GetPrintfCallEOObject(const CallExpr *op) { printf.nested.push_back(param); } else if (idx <= formats.size() && !formats[idx - 1].empty() && param.type != EOObjectType::EO_LITERAL) { + // TEST out + // std::cout << "formats[" << (idx - 1) << "] = " << formats[idx - 1] << + // "\n"; EOObject cast{formats[idx - 1]}; - cast.nested.push_back(param); + EOObject addr{"address"}; + EOObject ram{"global-ram"}; + addr.nested.push_back(ram); + addr.nested.push_back(param); + cast.nested.push_back(addr); printf.nested.push_back(cast); } else { printf.nested.push_back(param); @@ -1020,10 +1102,54 @@ EOObject GetCompoundAssignEOObject(const CompoundAssignOperator *p_operator) { auto op_code = p_operator->getOpcode(); std::string operation; + auto *opd1 = p_operator->getLHS(); + auto *opd2 = p_operator->getRHS(); + auto eo_opd1 = GetStmtEOObject(opd1); + auto eo_opd2 = GetStmtEOObject(opd2); + auto qual_type1 = opd1->getType(); + if (op_code == BinaryOperatorKind::BO_AddAssign) { operation = "plus"; + // is 1st pointer or array? + const clang::Type *type1 = qual_type1.getTypePtrOrNull(); + if (type1->isArrayType() || type1->isPointerType()) { + // set size of pointer shift + uint64_t type_size = GetTypeSize(qual_type1); + // TEST type size output + // std::cout << "Size of type = " << type_size << "\n"; + EOObject value{std::to_string(type_size), EOObjectType::EO_LITERAL}; + // second Operand must be integer expression else C-error + EOObject mult{"times"}; + mult.nested.push_back(eo_opd2); + mult.nested.push_back(value); + EOObject read_op{"read-as-ptr"}; + read_op.nested.push_back(eo_opd1); + EOObject binary_op{operation}; + binary_op.nested.push_back(read_op); + binary_op.nested.push_back(mult); + return binary_op; + } } else if (op_code == BinaryOperatorKind::BO_SubAssign) { operation = "minus"; + // is 1st pointer or array? + const clang::Type *type1 = qual_type1.getTypePtrOrNull(); + if (type1->isArrayType() || type1->isPointerType()) { + // set size of pointer shift + uint64_t type_size = GetTypeSize(qual_type1); + // TEST type size output + // std::cout << "Size of type = " << type_size << "\n"; + EOObject value{std::to_string(type_size), EOObjectType::EO_LITERAL}; + // second Operand must be integer expression else C-error + EOObject mult{"times"}; + mult.nested.push_back(eo_opd2); + mult.nested.push_back(value); + EOObject read_op{"read-as-ptr"}; + read_op.nested.push_back(eo_opd1); + EOObject binary_op{operation}; + binary_op.nested.push_back(read_op); + binary_op.nested.push_back(mult); + return binary_op; + } } else if (op_code == BinaryOperatorKind::BO_MulAssign) { operation = "times"; } else if (op_code == BinaryOperatorKind::BO_DivAssign) { @@ -1044,23 +1170,27 @@ EOObject GetCompoundAssignEOObject(const CompoundAssignOperator *p_operator) { EOObject binary_op{operation}; EOObject eo_object{"read"}; - Expr *left = dyn_cast(p_operator->getLHS()); - if (left != nullptr) { - QualType qual_type = left->getType(); - eo_object.nested.push_back(GetStmtEOObject(left)); - if (!qual_type->isRecordType()) { - eo_object.name += "-as-" + GetTypeName(qual_type); + // Expr *left = dyn_cast(p_operator->getLHS()); + // if (left != nullptr) { + if (opd1 != nullptr) { + // QualType qual_type = left->getType(); + // eo_object.nested.push_back(GetStmtEOObject(left)); + eo_object.nested.push_back(eo_opd1); + // if (!qual_type->isRecordType()) { + // eo_object.name += "-as-" + GetTypeName(qual_type); + if (!qual_type1->isRecordType()) { + eo_object.name += "-as-" + GetTypeName(qual_type1); } else { eo_object.nested.emplace_back( to_string(transpiler.record_manager_ - .GetById(qual_type->getAsRecordDecl()->getID()) + .GetById(qual_type1->getAsRecordDecl()->getID()) ->size), EOObjectType::EO_LITERAL); } } binary_op.nested.emplace_back(eo_object); - - binary_op.nested.push_back(GetStmtEOObject(p_operator->getRHS())); + binary_op.nested.push_back(eo_opd2); + // binary_op.nested.push_back(GetStmtEOObject(p_operator->getRHS())); return binary_op; } @@ -1073,10 +1203,62 @@ EOObject GetBinaryStmtEOObject(const BinaryOperator *p_operator) { if (op_code == BinaryOperatorKind::BO_Assign) { return GetAssignmentOperatorEOObject(p_operator); } + auto *opd1 = p_operator->getLHS(); + auto *opd2 = p_operator->getRHS(); + auto eo_opd1 = GetStmtEOObject(opd1); + auto eo_opd2 = GetStmtEOObject(opd2); + auto qual_type1 = opd1->getType(); + auto qual_type2 = opd2->getType(); if (op_code == BinaryOperatorKind::BO_Add) { operation = "plus"; + // is 1st pointer or array? + const clang::Type *type1 = qual_type1.getTypePtrOrNull(); + if (type1->isArrayType() || type1->isPointerType()) { + // set size of pointer shift + uint64_t type_size = GetTypeSize(qual_type1); + // TEST type size output + // std::cout << "Size of type = " << type_size << "\n"; + EOObject value{std::to_string(type_size), EOObjectType::EO_LITERAL}; + // second Operand must be integer expression else C-error + EOObject mult{"times"}; + mult.nested.push_back(eo_opd2); + mult.nested.push_back(value); + EOObject binary_op{operation}; + binary_op.nested.push_back(eo_opd1); + binary_op.nested.push_back(mult); + return binary_op; + } } else if (op_code == BinaryOperatorKind::BO_Sub) { operation = "minus"; + // is 1st pointer or array? + const clang::Type *type1 = qual_type1.getTypePtrOrNull(); + const clang::Type *type2 = qual_type2.getTypePtrOrNull(); + if (type1->isArrayType() || type1->isPointerType()) { + // set size of pointer shift + uint64_t type_size = GetTypeSize(qual_type1); + // TEST type size output + // std::cout << "Size of type = " << type_size << "\n"; + EOObject value{std::to_string(type_size), EOObjectType::EO_LITERAL}; + // Second operand maybe pointer too + if (type2->isArrayType() || type2->isPointerType()) { + // uint64_t type_size2 = GetTypeSize(qual_type2); + EOObject substr{"minus"}; + substr.nested.push_back(eo_opd1); + substr.nested.push_back(eo_opd2); + EOObject div{"div"}; + div.nested.push_back(substr); + div.nested.push_back(value); + return div; + } + // Or second Operand must be integer expression else C-error + EOObject mult{"times"}; + mult.nested.push_back(eo_opd2); + mult.nested.push_back(value); + EOObject binary_op{operation}; + binary_op.nested.push_back(eo_opd1); + binary_op.nested.push_back(mult); + return binary_op; + } } else if (op_code == BinaryOperatorKind::BO_Mul) { operation = "times"; } else if (op_code == BinaryOperatorKind::BO_Div) { @@ -1116,10 +1298,11 @@ EOObject GetBinaryStmtEOObject(const BinaryOperator *p_operator) { llvm::errs() << "Warning: Unknown operator " << p_operator->getOpcodeStr() << "\n"; } - EOObject binary_op{operation}; - binary_op.nested.push_back(GetStmtEOObject(p_operator->getLHS())); - binary_op.nested.push_back(GetStmtEOObject(p_operator->getRHS())); + binary_op.nested.push_back(eo_opd1); + binary_op.nested.push_back(eo_opd2); + // binary_op.nested.push_back(GetStmtEOObject(p_operator->getLHS())); + // binary_op.nested.push_back(GetStmtEOObject(p_operator->getRHS())); return binary_op; } @@ -1256,14 +1439,15 @@ EOObject GetUnaryExprOrTypeTraitExprEOObject( if (p_expr->isArgumentType()) { // Argument isTtype QualType qual_type = p_expr->getTypeOfArgument(); - auto type_size = GetTypeSize(qual_type); + auto type_size = GetSizeOfType(qual_type); std::string str_val{std::to_string(type_size)}; return EOObject{str_val, EOObjectType::EO_LITERAL}; } // Argument is Expr const auto *p_size_expr = p_expr->getArgumentExpr(); QualType expr_type = p_size_expr->getType(); - auto expr_type_size = GetTypeSize(expr_type); + // auto expr_type_size = GetTypeSize(expr_type); + auto expr_type_size = GetSizeOfType(expr_type); std::string str_val{std::to_string(expr_type_size)}; return EOObject{str_val, EOObjectType::EO_LITERAL}; } @@ -1295,10 +1479,25 @@ EOObject GetEODeclRefExpr(const DeclRefExpr *op) { return EOObject{std::to_string(var->value), EOObjectType::EO_LITERAL}; } const auto *id = dyn_cast(val); - if (id->isStaticLocal()) { - return EOObject{"s-" + id->getName().str()}; - } + /* if (id->isStaticLocal()) { + auto var = ProcessVariable(id, "s-" + id->getName().str(), 8); + return EOObject{var.alias}; + }*/ const auto &var = transpiler.glob_.GetVarById(id); + // TEST output + // std::cout << "It is var " << id->getName().str() << "\n"; + clang::QualType qual_type = id->getType(); + // TEST output + // std::cout << "Size of variable = " << var.size << "\n"; + // std::cout << "QualType as string = " << qual_type.getAsString() << "\n"; + const clang::Type *type = qual_type.getTypePtrOrNull(); + if (type->isArrayType()) { + // TEST output + // std::cout << "It is array type which used as pointer\n"; + EOObject array_as_ptr{"addr-of"}; + array_as_ptr.nested.emplace_back(var.alias); + return array_as_ptr; + } return EOObject{var.alias}; } catch (std::invalid_argument &) { return EOObject{EOObjectType::EO_PLUG}; @@ -1452,6 +1651,18 @@ uint64_t GetTypeSize(QualType qual_type) { return type_size / byte_size; } +uint64_t GetSizeOfType(QualType qual_type) { + const clang::Type *type_ptr = qual_type.getTypePtr(); + TypeInfo type_info = context->getTypeInfo(type_ptr); + uint64_t type_size = type_info.Width; + + if (type_ptr->isPointerType()) { + return 8; // Size of any pointer == 8 byte + } + + return type_size / byte_size; +} + std::string GetPostfix(QualType qual_type) { const clang::Type *type_ptr = qual_type.getTypePtr(); TypeInfo type_info = context->getTypeInfo(type_ptr); diff --git a/project/tests/in_progress/for_main/bad/operations/sizeof/00077/00077.c b/project/tests/in_progress/for_main/bad/operations/sizeof/00077/00077.c deleted file mode 100644 index e28483d5..00000000 --- a/project/tests/in_progress/for_main/bad/operations/sizeof/00077/00077.c +++ /dev/null @@ -1,56 +0,0 @@ -int -foo(int x[100]) -{ - int y[100]; - int *p; - - y[0] = 2000; - - if(x[0] != 1000) - { - return 1; - } - - p = x; - - if(p[0] != 1000) - { - return 2; - } - - p = y; - - if(p[0] != 2000) - { - return 3; - } - - if(sizeof(x) != sizeof(void*)) - { - return 4; - } - - if(sizeof(y) <= sizeof(x)) - { - return 5; - } - - return 0; -} - -int -test() -{ - int x[100]; - x[0] = 1000; - - return foo(x); -} - -#include -int main() -{ - int x = test(); - printf("%d\n", x); - return x; -} diff --git a/project/tests/in_progress/for_main/bad/types/composite_types/array/array2scalar.c b/project/tests/in_progress/for_main/bad/types/composite_types/array/other/array2scalar.c similarity index 59% rename from project/tests/in_progress/for_main/bad/types/composite_types/array/array2scalar.c rename to project/tests/in_progress/for_main/bad/types/composite_types/array/other/array2scalar.c index c611f0ec..6333e0a9 100644 --- a/project/tests/in_progress/for_main/bad/types/composite_types/array/array2scalar.c +++ b/project/tests/in_progress/for_main/bad/types/composite_types/array/other/array2scalar.c @@ -18,6 +18,21 @@ int main() { printf("x = %lld\n", x); printf("y = %lld\n", y); + x = a[1]; + y = a[0]; + printf("x = %lld\n", x); + printf("y = %lld\n", y); + + i64 v = *a; + i64 w = *(a+1); + printf("v = %lld\n", v); + printf("w = %lld\n", w); + + v = *(a+1); + w = *a; + printf("v = %lld\n", v); + printf("w = %lld\n", w); + return 0; } diff --git a/project/tests/in_progress/for_main/bad/operations/ptr_bin_op/ptr_plus_val/ptr_plus_long.c b/project/tests/in_progress/for_main/good/operations/ptr_bin_op/ptr_plus_val/ptr_plus_long.c similarity index 100% rename from project/tests/in_progress/for_main/bad/operations/ptr_bin_op/ptr_plus_val/ptr_plus_long.c rename to project/tests/in_progress/for_main/good/operations/ptr_bin_op/ptr_plus_val/ptr_plus_long.c diff --git a/project/tests/in_progress/for_main/bad/types/composite_types/array/array07.c b/project/tests/in_progress/for_main/good/types/complex_types/array/simple/array07.c similarity index 100% rename from project/tests/in_progress/for_main/bad/types/composite_types/array/array07.c rename to project/tests/in_progress/for_main/good/types/complex_types/array/simple/array07.c diff --git a/project/tests/in_progress/for_main/bad/types/composite_types/array/array08.c b/project/tests/in_progress/for_main/good/types/complex_types/array/simple/array08.c similarity index 100% rename from project/tests/in_progress/for_main/bad/types/composite_types/array/array08.c rename to project/tests/in_progress/for_main/good/types/complex_types/array/simple/array08.c diff --git a/project/tests/in_progress/for_main/tests_suite/test000/testsuite_000.c b/project/tests/in_progress/for_main/tests_suite/test000/testsuite_000.c deleted file mode 100644 index 23938660..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test000/testsuite_000.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -int x = 5; -long y = 6; -int *p = &x; - -int -test() -{ - if (x != 5) - return 1; - if (y != 6) - return 2; - if (*p != 5) - return 3; - return 0; -} - -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test002/testsuite_002.c b/project/tests/in_progress/for_main/tests_suite/test002/testsuite_002.c deleted file mode 100644 index 4cbe1773..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test002/testsuite_002.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -int -test() { - int n; - int t; - int c; - int p; - - c = 0; - n = 2; - while (n < 5000) { - t = 2; - p = 1; - while (t*t <= n) { - if (n % t == 0) - p = 0; - t++; - } - n++; - if (p) - c++; - } - if (c != 669) - return 1; - return 0; -} - -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test007/testsuite_007.c b/project/tests/in_progress/for_main/tests_suite/test007/testsuite_007.c deleted file mode 100644 index 1fb2e582..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test007/testsuite_007.c +++ /dev/null @@ -1,40 +0,0 @@ -#include -struct S1 { - int a; - int b; -}; - -struct S2 { - int a; - int b; - union { - int c; - int d; - }; - struct S1 s; -}; - -struct S2 v = {1, 2, 3, {4, 5}}; - -int -test() -{ - if(v.a != 1) - return 1; - if(v.b != 2) - return 2; - if(v.c != 3 || v.d != 3) - return 3; - if(v.s.a != 4) - return 4; - if(v.s.b != 5) - return 5; - - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test011/testsuite_011.c b/project/tests/in_progress/for_main/tests_suite/test011/testsuite_011.c deleted file mode 100644 index a61c228b..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test011/testsuite_011.c +++ /dev/null @@ -1,39 +0,0 @@ -#include - -int test() -{ - int x = 'a'; - char y = x; - - char *a = "hello"; - - printf("%s\n", a); - - int c; - c = *a; - - char *b; - for (b = a; *b != 0; b++) - printf("%c: %d\n", *b, *b); - - char destarray[10]; - char *dest = &destarray[0]; - char *src = a; - - while (*src != 0) - *dest++ = *src++; - - *dest = 0; - - printf("copied string is %s\n", destarray); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test012/testsuite_012.c b/project/tests/in_progress/for_main/tests_suite/test012/testsuite_012.c deleted file mode 100644 index 8253b8db..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test012/testsuite_012.c +++ /dev/null @@ -1,51 +0,0 @@ -#include - -/* This test segfaults as of April 27, 2015. */ -void f1(int argc) -{ - char test[argc]; - if(0) - label: - printf("boom!\n"); - if(argc-- == 0) - return; - goto label; -} - -/* This segfaulted on 2015-11-19. */ -void f2(void) -{ - goto start; - { - int a[1 && 1]; /* not a variable-length array */ - int b[1 || 1]; /* not a variable-length array */ - int c[1 ? 1 : 1]; /* not a variable-length array */ - start: - a[0] = 0; - b[0] = 0; - c[0] = 0; - } -} - -void f3(void) -{ - printf("%d\n", 0 ? printf("x1\n") : 11); - printf("%d\n", 1 ? 12 : printf("x2\n")); - printf("%d\n", 0 && printf("x3\n")); - printf("%d\n", 1 || printf("x4\n")); -} - -int test() -{ - f1(2); - f2(); - f3(); - - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test013/testsuite_013.c b/project/tests/in_progress/for_main/tests_suite/test013/testsuite_013.c deleted file mode 100644 index 26a7b8c2..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test013/testsuite_013.c +++ /dev/null @@ -1,37 +0,0 @@ -#include -typedef struct s s; - -struct s { - struct s1 { - int s; - struct s2 { - int s; - } s1; - } s; -} s2; - -#define s s - -int -test(void) -{ -#undef s - goto s; - struct s s; - { - int s; - return s; - } - return s.s.s + s.s.s1.s; - s: - { - return 0; - } - return 1; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test016/testsuite_016.c b/project/tests/in_progress/for_main/tests_suite/test016/testsuite_016.c deleted file mode 100644 index 16ece993..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test016/testsuite_016.c +++ /dev/null @@ -1,27 +0,0 @@ -#include -struct S -{ - int (*fptr)(); -}; - -int -foo() -{ - return 0; -} - -int -test() -{ - struct S v; - - v.fptr = foo; - return v.fptr(); -} - -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test019/testsuite_019.c b/project/tests/in_progress/for_main/tests_suite/test019/testsuite_019.c deleted file mode 100644 index 7637db75..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test019/testsuite_019.c +++ /dev/null @@ -1,14 +0,0 @@ -#include - -int -test(void) -{ - printf("hello world\n"); - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test021/testsuite_021.c b/project/tests/in_progress/for_main/tests_suite/test021/testsuite_021.c deleted file mode 100644 index df1199d1..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test021/testsuite_021.c +++ /dev/null @@ -1,39 +0,0 @@ -#include - -/* This test is a snippet from the J interpreter */ - -typedef long I; -typedef struct{I c[4];I b,e,k;} PT; - -PT cases[] = { - ((I)4194304L +(I)2097152L +(I)67108864L), (I)262144L, (((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L), -1L, 1,2,1, - ((I)+4194304L +(I)2097152L +(I)67108864L)+( (I)524288L +(I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L)), (I)262144L, (I)262144L, (((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L), 2,3,2, - ((I)4194304L +(I)2097152L +(I)67108864L)+( (I)524288L +(I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L)), (((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L), (I)262144L, (((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L), 1,3,2, - ((I)4194304L +(I)2097152L +(I)67108864L)+( (I)524288L +(I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L)), (I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L), (I)524288L, -1L, 1,2,1, - ((I)4194304L +(I)2097152L +(I)67108864L)+( (I)524288L +(I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L)), (I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L), (I)1048576L, (I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L), 1,3,1, - ((I)4194304L +(I)2097152L +(I)67108864L)+( (I)524288L +(I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L)), (I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L), (I)262144L, (I)262144L, 1,3,1, - ((I)4194304L +(I)2097152L +(I)67108864L), ((I)1048576L +(I)524288L +(I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L)), ((I)1048576L +(I)524288L +(I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L)), -1L, 1,2,1, - (I)33554432L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L), (I)2097152L, ((I)1048576L +(I)524288L +(I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L)), -1L, 0,2,1, - (I)67108864L, ((I)1048576L +(I)524288L +(I)262144L +(((I)1L +(I)256L +(I)4L +(I)8L +(I)16L +(I)64L +(I)128L +(I)268435456L +(I)536870912L +(I)1024L +(I)4096L +(I)8192L +(I)16384L)+((I)2L +(I)131072L +(I)2048L)+(I)32L +(I)32768L +(I)65536L)), (I)134217728L, -1L, 0,2,0, -}; - -int test() { - int i, j; - - for(j=0; j < sizeof(cases)/sizeof(cases[0]); j++) { - for(i=0; i < sizeof(cases->c)/sizeof(cases->c[0]); i++) - printf("cases[%d].c[%d]=%ld\n", j, i, cases[j].c[i]); - - printf("cases[%d].b=%ld\n", j, cases[j].b); - printf("cases[%d].e=%ld\n", j, cases[j].e); - printf("cases[%d].k=%ld\n", j, cases[j].k); - printf("\n"); - } - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test025/testsuite_025.c b/project/tests/in_progress/for_main/tests_suite/test025/testsuite_025.c deleted file mode 100644 index 0966f0d9..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test025/testsuite_025.c +++ /dev/null @@ -1,29 +0,0 @@ -#include -int -f2(int c, int b) -{ - return c - b; -} - -int (* -f1(int a, int b))(int c, int b) -{ - if (a != b) - return f2; - return 0; -} - -int -test() -{ - int (* (*p)(int a, int b))(int c, int d) = f1; - - - return (*(*p)(0, 2))(2, 2); -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test030/testsuite_030.c b/project/tests/in_progress/for_main/tests_suite/test030/testsuite_030.c deleted file mode 100644 index 8d673cd8..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test030/testsuite_030.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -int (*fptr)() = 0; - - -int -test() -{ - if (fptr) - return 1; - return 0; -} - -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test031/testsuite_031.c b/project/tests/in_progress/for_main/tests_suite/test031/testsuite_031.c deleted file mode 100644 index 1abd8763..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test031/testsuite_031.c +++ /dev/null @@ -1,47 +0,0 @@ -#include -typedef unsigned short uint16_t; -typedef unsigned char uint8_t; - -typedef union Unaligned16a { - uint16_t u; - uint8_t b[2]; -} __attribute__((packed)) Unaligned16a; - -typedef union __attribute__((packed)) Unaligned16b { - uint16_t u; - uint8_t b[2]; -} Unaligned16b; - -extern void foo (void) __attribute__((stdcall)); -void __attribute__((stdcall)) foo (void) -{ -} - -/* The actual attribute isn't important, must just be - parsable. */ -#define ATTR __attribute__((__noinline__)) -int ATTR actual_function() { - return 42; -} - -extern int printf (const char *, ...); -int test() -{ - void *function_pointer = &actual_function; - - int a = ((ATTR int(*) (void)) function_pointer)(); - printf("%i\n", a); - - /* In the following we once misparsed 'ATTR *' is a btype - and hence the whole type was garbled. */ - int b = ( (int(ATTR *)(void)) function_pointer)(); - printf("%i\n", b); - - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test036/testsuite_036.c b/project/tests/in_progress/for_main/tests_suite/test036/testsuite_036.c deleted file mode 100644 index d4de8e4b..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test036/testsuite_036.c +++ /dev/null @@ -1,56 +0,0 @@ -#include -/* The following are all valid decls, even though some subtypes - are incomplete. */ -enum E *e; -const enum E *e1; -enum E const *e2; -struct S *s; -const struct S *s1; -struct S const *s2; - -/* Various strangely looking declarators, which are all valid - and have to map to the same numbered typedefs. */ -typedef int (*fptr1)(); -int f1 (int (), int); -typedef int (*fptr2)(int x); -int f2 (int (int x), int); -typedef int (*fptr3)(int); -int f3 (int (int), int); -typedef int (*fptr4[4])(int); -int f4 (int (*[4])(int), int); -typedef int (*fptr5)(fptr1); -int f5 (int (int()), fptr1); -int f1 (fptr1 fp, int i) -{ - return (*fp)(i); -} -int f2 (fptr2 fp, int i) -{ - return (*fp)(i); -} -int f3 (fptr3 fp, int i) -{ - return (*fp)(i); -} -int f4 (fptr4 fp, int i) -{ - return (*fp[i])(i); -} -int f5 (fptr5 fp, fptr1 i) -{ - return fp(i); -} -int f8 (int ([4]), int); -// int main () { return 0; } - -int test() { - int x; - x = -} - -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} diff --git a/project/tests/in_progress/for_main/tests_suite/test039/testsuite_039.c b/project/tests/in_progress/for_main/tests_suite/test039/testsuite_039.c deleted file mode 100644 index afa94815..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test039/testsuite_039.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -int -test() -{ - int x; - int *p; - - x = 1; - p = &x; - p[0] = 0; - return x; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test044/testsuite_044.c b/project/tests/in_progress/for_main/tests_suite/test044/testsuite_044.c deleted file mode 100644 index 133b5b39..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test044/testsuite_044.c +++ /dev/null @@ -1,35 +0,0 @@ -#include - -int fred() -{ - printf("fred\n"); - return 0; -} - -int joe() -{ - printf("joe\n"); - return 1; -} - -int test() -{ - printf("%d\n", fred() && joe()); - printf("%d\n", fred() || joe()); - printf("%d\n", joe() && fred()); - printf("%d\n", joe() || fred()); - printf("%d\n", fred() && (1 + joe())); - printf("%d\n", fred() || (0 + joe())); - printf("%d\n", joe() && (0 + fred())); - printf("%d\n", joe() || (1 + fred())); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test045/testsuite_045.c b/project/tests/in_progress/for_main/tests_suite/test045/testsuite_045.c deleted file mode 100644 index 1bdce6e5..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test045/testsuite_045.c +++ /dev/null @@ -1,28 +0,0 @@ -#include - -int fred(int p) -{ - printf("yo %d\n", p); - return 42; -} - -int (*f)(int) = &fred; - -/* To test what this is supposed to test the destination function - (fprint here) must not be called directly anywhere in the test. */ -int (*fprintfptr)(FILE *, const char *, ...) = &fprintf; - -int test() -{ - fprintfptr(stdout, "%d\n", (*f)(24)); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test046/testsuite_046.c b/project/tests/in_progress/for_main/tests_suite/test046/testsuite_046.c deleted file mode 100644 index 69b7098a..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test046/testsuite_046.c +++ /dev/null @@ -1,60 +0,0 @@ -#include - -void charfunc(char a) -{ - printf("char: %c\n", a); -} - -void intfunc(int a) -{ - printf("int: %d\n", a); -} - -void floatfunc(float a) -{ - printf("float: %f\n", a); -} - -int test() -{ - charfunc('a'); - charfunc(98); - charfunc(99.0); - - intfunc('a'); - intfunc(98); - intfunc(99.0); - - floatfunc('a'); - floatfunc(98); - floatfunc(99.0); - - /* printf("%c %d %f\n", 'a', 'b', 'c'); */ - /* printf("%c %d %f\n", 97, 98, 99); */ - /* printf("%c %d %f\n", 97.0, 98.0, 99.0); */ - - char b = 97; - char c = 97.0; - - printf("%d %d\n", b, c); - - int d = 'a'; - int e = 97.0; - - printf("%d %d\n", d, e); - - float f = 'a'; - float g = 97; - - printf("%f %f\n", f, g); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test047/testsuite_047.c b/project/tests/in_progress/for_main/tests_suite/test047/testsuite_047.c deleted file mode 100644 index 1557d5e4..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test047/testsuite_047.c +++ /dev/null @@ -1,27 +0,0 @@ -#include - -int test() -{ - int Count; - - int Array[10] = { 12, 34, 56, 78, 90, 123, 456, 789, 8642, 9753 }; - - for (Count = 0; Count < 10; Count++) - printf("%d: %d\n", Count, Array[Count]); - - int Array2[10] = { 12, 34, 56, 78, 90, 123, 456, 789, 8642, 9753, }; - - for (Count = 0; Count < 10; Count++) - printf("%d: %d\n", Count, Array2[Count]); - - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test048/testsuite_048.c b/project/tests/in_progress/for_main/tests_suite/test048/testsuite_048.c deleted file mode 100644 index b35b7b0c..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test048/testsuite_048.c +++ /dev/null @@ -1,44 +0,0 @@ -#include - -int -test() -{ -#if defined(__LLP64__) - if (sizeof(short) == 2 - && sizeof(int) == 4 - && sizeof(long int) == 4 - && sizeof(long long int) == 8 - && sizeof(void*) == 8) { - (void)printf("Ok\n"); - } else { - (void)printf("KO __LLP64__\n"); - } -#elif defined(__LP64__) - if (sizeof(short) == 2 - && sizeof(int) == 4 - && sizeof(long int) == 8 - && sizeof(long long int) == 8 - && sizeof(void*) == 8) { - (void)printf("Ok\n"); - } else { - (void)printf("KO __LP64__\n"); - } -#elif defined(__ILP32__) - if (sizeof(short) == 2 - && sizeof(int) == 4 - && sizeof(long int) == 4 - && sizeof(void*) == 4) { - (void)printf("Ok\n"); - } else { - (void)printf("KO __ILP32__\n"); - } -#else - (void)printf("KO no __*LP*__ defined.\n"); -#endif -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test050/testsuite_050.c b/project/tests/in_progress/for_main/tests_suite/test050/testsuite_050.c deleted file mode 100644 index 4b576bda..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test050/testsuite_050.c +++ /dev/null @@ -1,22 +0,0 @@ -#include -int printf(const char *, ...); -char t[] = "012345678"; - -int test(void) -{ - char *data = t; - unsigned long long r = 4; - unsigned a = 5; - unsigned long long b = 12; - - *(unsigned*)(data + r) += a - b; - - printf("data = \"%s\"\n", data); - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test052/testsuite_052.c b/project/tests/in_progress/for_main/tests_suite/test052/testsuite_052.c deleted file mode 100644 index bee74fbc..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test052/testsuite_052.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -#define x(y) #y - -int -test(void) -{ - char *p; - p = x(hello) " is better than bye"; - - return (*p == 'h') ? 0 : 1; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test054/testsuite_054.c b/project/tests/in_progress/for_main/tests_suite/test054/testsuite_054.c deleted file mode 100644 index 9b81e661..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test054/testsuite_054.c +++ /dev/null @@ -1,23 +0,0 @@ -#include - -int test() -{ - char Buf[100]; - int Count; - - for (Count = 1; Count <= 20; Count++) - { - sprintf(Buf, "->%02d<-\n", Count); - printf("%s", Buf); - } - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test057/testsuite_057.c b/project/tests/in_progress/for_main/tests_suite/test057/testsuite_057.c deleted file mode 100644 index 43c1249c..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test057/testsuite_057.c +++ /dev/null @@ -1,14 +0,0 @@ -#include -double x = 100.0; - -int -test() -{ - return x < 1; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test058/testsuite_058.c b/project/tests/in_progress/for_main/tests_suite/test058/testsuite_058.c deleted file mode 100644 index 95c235d5..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test058/testsuite_058.c +++ /dev/null @@ -1,46 +0,0 @@ -#include - -struct ziggy -{ - int a; - int b; - int c; -} bolshevic; - -int test() -{ - int a; - int *b; - int c; - - a = 42; - b = &a; - printf("a = %d\n", *b); - - bolshevic.a = 12; - bolshevic.b = 34; - bolshevic.c = 56; - - printf("bolshevic.a = %d\n", bolshevic.a); - printf("bolshevic.b = %d\n", bolshevic.b); - printf("bolshevic.c = %d\n", bolshevic.c); - - struct ziggy *tsar = &bolshevic; - - printf("tsar->a = %d\n", tsar->a); - printf("tsar->b = %d\n", tsar->b); - printf("tsar->c = %d\n", tsar->c); - - b = &(bolshevic.b); - printf("bolshevic.b = %d\n", *b); - - return 0; -} - -// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test060/testsuite_060.c b/project/tests/in_progress/for_main/tests_suite/test060/testsuite_060.c deleted file mode 100644 index a6780409..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test060/testsuite_060.c +++ /dev/null @@ -1,37 +0,0 @@ -#include - -struct fred -{ - int boris; - int natasha; -}; - -int test() -{ - struct fred bloggs; - - bloggs.boris = 12; - bloggs.natasha = 34; - - printf("%d\n", bloggs.boris); - printf("%d\n", bloggs.natasha); - - struct fred jones[2]; - jones[0].boris = 12; - jones[0].natasha = 34; - jones[1].boris = 56; - jones[1].natasha = 78; - - printf("%d\n", jones[0].boris); - printf("%d\n", jones[0].natasha); - printf("%d\n", jones[1].boris); - printf("%d\n", jones[1].natasha); - - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test063/testsuite_063.c b/project/tests/in_progress/for_main/tests_suite/test063/testsuite_063.c deleted file mode 100644 index 2029fc5a..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test063/testsuite_063.c +++ /dev/null @@ -1,29 +0,0 @@ -#include -int -test() -{ - char arr[2][4], (*p)[4], *q; - int v[4]; - - p = arr; - q = &arr[1][3]; - arr[1][3] = 2; - v[0] = 2; - - if (arr[1][3] != 2) - return 1; - if (p[1][3] != 2) - return 1; - if (*q != 2) - return 1; - if (*v != 2) - return 1; - - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test064/testsuite_064.c b/project/tests/in_progress/for_main/tests_suite/test064/testsuite_064.c deleted file mode 100644 index ddfadfc3..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test064/testsuite_064.c +++ /dev/null @@ -1,25 +0,0 @@ -#include - -int test() -{ - long long int res = 0; - - if (res < -2147483648LL) { - printf("Error: 0 < -2147483648\n"); - return 1; - } - else - if (2147483647LL < res) { - printf("Error: 2147483647 < 0\n"); - return 2; - } - else - printf("long long constant test ok.\n"); - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test066/testsuite_066.c b/project/tests/in_progress/for_main/tests_suite/test066/testsuite_066.c deleted file mode 100644 index 72579594..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test066/testsuite_066.c +++ /dev/null @@ -1,62 +0,0 @@ -#include -#include - -int N; -int *t; - -int -chk(int x, int y) -{ - int i; - int r; - - for (r=i=0; i<8; i++) { - r = r + t[x + 8*i]; - r = r + t[i + 8*y]; - if (x+i < 8 & y+i < 8) - r = r + t[x+i + 8*(y+i)]; - if (x+i < 8 & y-i >= 0) - r = r + t[x+i + 8*(y-i)]; - if (x-i >= 0 & y+i < 8) - r = r + t[x-i + 8*(y+i)]; - if (x-i >= 0 & y-i >= 0) - r = r + t[x-i + 8*(y-i)]; - } - return r; -} - -int -go(int n, int x, int y) -{ - if (n == 8) { - N++; - return 0; - } - for (; y<8; y++) { - for (; x<8; x++) - if (chk(x, y) == 0) { - t[x + 8*y]++; - go(n+1, x, y); - t[x + 8*y]--; - } - x = 0; - } - return 0; -} - -int -test() -{ - t = calloc(64, sizeof(int)); - go(0, 0, 0); - if(N != 92) - return 1; - return 0; -} - -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test067/testsuite_067.c b/project/tests/in_progress/for_main/tests_suite/test067/testsuite_067.c deleted file mode 100644 index dc37a4b2..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test067/testsuite_067.c +++ /dev/null @@ -1,32 +0,0 @@ -#include - -int test() -{ - int a; - char b; - - a = 0; - while (a < 2) - { - printf("%d", a++); - break; - - b = 'A'; - while (b < 'C') - { - printf("%c", b++); - } - printf("e"); - } - printf("\n"); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test070/testsuite_070.c b/project/tests/in_progress/for_main/tests_suite/test070/testsuite_070.c deleted file mode 100644 index 7dabbd60..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test070/testsuite_070.c +++ /dev/null @@ -1,24 +0,0 @@ -#include -int -test(void) -{ - int i, *q; - void *p; - - i = i ? 0 : 0l; - p = i ? (void *) 0 : 0; - p = i ? 0 : (void *) 0; - p = i ? 0 : (const void *) 0; - q = i ? 0 : p; - q = i ? p : 0; - q = i ? q : 0; - q = i ? 0 : q; - - return (int) q; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test071/testsuite_071.c b/project/tests/in_progress/for_main/tests_suite/test071/testsuite_071.c deleted file mode 100644 index 81a13d80..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test071/testsuite_071.c +++ /dev/null @@ -1,75 +0,0 @@ -#include -/* Check some way in where code suppression caused various - miscompilations. */ -extern int printf (const char *, ...); -typedef unsigned long size_t; - -size_t _brk_start, _brk_end; -void * extend_brk(size_t size, size_t align) -{ - size_t mask = align - 1; - void *ret = 0; - - do { - if (__builtin_expect(!!(_brk_start == 0), 0)) - do { - printf("wrong1\n"); - } while (0); - } while (0); - _brk_end = (_brk_end + mask) & ~mask; - ret = (void *)_brk_end; - _brk_end += size; - - return ret; -} - -static void get_args (int a, int b) -{ - if (a != 1) - printf("wrong2\n"); - else - printf("okay\n"); -} - -void bla(void) -{ - int __ret = 42; - ({ - if (__builtin_expect(!!(0), 0)) { - if (__builtin_expect(!!__ret, 0)) - printf("wrong3\n"); - int x = !!(__ret); - } - __ret; - }); - get_args(!!__ret, sizeof(__ret)); -} - -_Bool chk(unsigned long addr, unsigned long limit, unsigned long size) -{ - _Bool ret; - /* This just needs to compile, no runtime test. (And it doesn't compile - only with certain internal checking added that's not committed). */ - if (0) - ret = 0 != (!!(addr > limit - size)); -} - -int test() -{ - void *r; - _brk_start = 1024; - _brk_end = 1024; - r = extend_brk (4096, 16); - if (!r) - printf("wrong4\n"); - else - printf("okay\n"); - bla(); - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test074/testsuite_074.c b/project/tests/in_progress/for_main/tests_suite/test074/testsuite_074.c deleted file mode 100644 index 713624dc..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test074/testsuite_074.c +++ /dev/null @@ -1,78 +0,0 @@ -#include - -enum fred -{ - a, - b, - c, - d, - e = 54, - f = 73, - g, - h -}; - -/* All following uses of enum efoo should compile - without warning. While forward enums aren't ISO C, - it's accepted by GCC also in strict mode, and only warned - about with -pedantic. This happens in the real world. */ -/* Strict ISO C doesn't allow this kind of forward declaration of - enums, but GCC accepts it (and gives only pedantic warning), and - it occurs in the wild. */ -enum efoo; -struct Sforward_use { - int (*fmember) (enum efoo x); -}; - -extern enum efoo it_real_fn(void); -enum efoo { - ONE, - TWO, -}; -struct S2 { - enum efoo (*f2) (void); -}; -void should_compile(struct S2 *s) -{ - s->f2 = it_real_fn; -} - -enum efoo it_real_fn(void) -{ - return TWO; -} - -static unsigned int deref_uintptr(unsigned int *p) -{ - return *p; -} - -enum Epositive { - epos_one, epos_two -}; - -int test() -{ - enum fred frod; - enum Epositive epos = epos_two; - - printf("%d %d %d %d %d %d %d %d\n", a, b, c, d, e, f, g, h); - /* printf("%d\n", frod); */ - frod = 12; - printf("%d\n", frod); - frod = e; - printf("%d\n", frod); - - /* Following should compile without warning. */ - printf ("enum to int: %u\n", deref_uintptr(&epos)); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test077/testsuite_077.c b/project/tests/in_progress/for_main/tests_suite/test077/testsuite_077.c deleted file mode 100644 index 19bb17dd..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test077/testsuite_077.c +++ /dev/null @@ -1,40 +0,0 @@ -#include -struct S1 { - int a; - int b; -}; -struct S2 { - struct S1 s1; - struct S1 *ps1; - int arr[2]; -}; -struct S1 gs1 = { .a = 1, 2 }; -struct S2 *s = &(struct S2) { - {.b = 2, .a = 1}, - &gs1, - {[0] = 1, 1+1} -}; - -int -test() -{ - if(s->s1.a != 1) - return 1; - if(s->s1.b != 2) - return 2; - if(s->ps1->a != 1) - return 3; - if(s->ps1->b != 2) - return 4; - if(s->arr[0] != 1) - return 5; - if(s->arr[1] != 2) - return 6; - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test080/testsuite_080.c b/project/tests/in_progress/for_main/tests_suite/test080/testsuite_080.c deleted file mode 100644 index 54898d74..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test080/testsuite_080.c +++ /dev/null @@ -1,41 +0,0 @@ -#include - -int myfunc(int x) -{ - return x * x; -} - -void vfunc(int a) -{ - printf("a=%d\n", a); -} - -void qfunc() -{ - printf("qfunc()\n"); -} - -void zfunc() -{ - ((void (*)(void))0) (); -} - -int test() -{ - printf("%d\n", myfunc(3)); - printf("%d\n", myfunc(4)); - - vfunc(1234); - - qfunc(); - - return 0; -} - -// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test084/testsuite_084.c b/project/tests/in_progress/for_main/tests_suite/test084/testsuite_084.c deleted file mode 100644 index b621432b..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test084/testsuite_084.c +++ /dev/null @@ -1,26 +0,0 @@ -#include -typedef struct { - int v; - int sub[2]; -} S; - -S a[1] = {{1, {2, 3}}}; - -int -test() -{ - if (a[0].v != 1) - return 1; - if (a[0].sub[0] != 2) - return 2; - if (a[0].sub[1] != 3) - return 3; - - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test089/testsuite_089.c b/project/tests/in_progress/for_main/tests_suite/test089/testsuite_089.c deleted file mode 100644 index 609ca0b8..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test089/testsuite_089.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -int a[] = {1, 2, 3, 4}; - -int -test() -{ - if (sizeof(a) != 4*sizeof(int)) - return 1; - - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test092/testsuite_092.c b/project/tests/in_progress/for_main/tests_suite/test092/testsuite_092.c deleted file mode 100644 index d4c74d97..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test092/testsuite_092.c +++ /dev/null @@ -1,24 +0,0 @@ -#include -int -test() -{ - int x, *p; - - if (sizeof(0) < 2) - return 1; - if (sizeof 0 < 2) - return 1; - if (sizeof(char) < 1) - return 1; - if (sizeof(int) - 2 < 0) - return 1; - if (sizeof(&x) != sizeof p) - return 1; - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test095/testsuite_095.c b/project/tests/in_progress/for_main/tests_suite/test095/testsuite_095.c deleted file mode 100644 index be32e589..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test095/testsuite_095.c +++ /dev/null @@ -1,146 +0,0 @@ -#include - -int a; -unsigned b; -char c; -signed char d; -unsigned char e; -long f; -unsigned long g; -long long h; -unsigned long long i; -short j; -unsigned short k; - -int -test(void) -{ - a = b; - a = c; - a = d; - a = e; - a = f; - a = g; - a = h; - a = i; - a = j; - a = k; - - b = a; - b = c; - b = d; - b = e; - b = f; - b = g; - b = h; - b = i; - b = j; - b = k; - - c = a; - c = b; - c = d; - c = e; - c = f; - c = g; - c = h; - c = i; - c = j; - c = k; - - d = a; - d = b; - d = c; - d = e; - d = f; - d = g; - d = h; - d = i; - d = j; - d = k; - - e = a; - e = b; - e = c; - e = d; - e = f; - e = g; - e = h; - e = i; - e = j; - e = k; - - f = a; - f = b; - f = c; - f = d; - f = e; - f = g; - f = h; - f = i; - f = j; - f = k; - - g = a; - g = b; - g = c; - g = d; - g = e; - g = f; - g = h; - g = i; - g = j; - g = k; - - h = a; - h = b; - h = c; - h = d; - h = e; - h = f; - h = g; - h = i; - h = j; - h = k; - - i = a; - i = b; - i = c; - i = d; - i = e; - i = f; - i = g; - i = h; - i = j; - i = k; - - j = a; - j = b; - j = c; - j = d; - j = e; - j = f; - j = g; - j = h; - j = i; - j = k; - - k = a; - k = b; - k = c; - k = d; - k = e; - k = f; - k = g; - k = h; - k = j; - k = i; - - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test100/testsuite_100.c b/project/tests/in_progress/for_main/tests_suite/test100/testsuite_100.c deleted file mode 100644 index b5429cdf..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test100/testsuite_100.c +++ /dev/null @@ -1,128 +0,0 @@ -/* example from http://barnyard.syr.edu/quickies/hanoi.c */ - -/* hanoi.c: solves the tower of hanoi problem. (Programming exercise.) */ -/* By Terry R. McConnell (12/2/97) */ -/* Compile: cc -o hanoi hanoi.c */ - -/* This program does no error checking. But then, if it's right, - it's right ... right ? */ - - -/* The original towers of hanoi problem seems to have been originally posed - by one M. Claus in 1883. There is a popular legend that goes along with - it that has been often repeated and paraphrased. It goes something like this: - In the great temple at Benares there are 3 golden spikes. On one of them, - God placed 64 disks increasing in size from bottom to top, at the beginning - of time. Since then, and to this day, the priest on duty constantly transfers - disks, one at a time, in such a way that no larger disk is ever put on top - of a smaller one. When the disks have been transferred entirely to another - spike the Universe will come to an end in a large thunderclap. - - This paraphrases the original legend due to DeParville, La Nature, Paris 1884, - Part I, 285-286. For this and further information see: Mathematical - Recreations & Essays, W.W. Rouse Ball, MacMillan, NewYork, 11th Ed. 1967, - 303-305. - * - * - */ - -#include -#include - -#define TRUE 1 -#define FALSE 0 - -/* This is the number of "disks" on tower A initially. Taken to be 64 in the - * legend. The number of moves required, in general, is 2^N - 1. For N = 64, - * this is 18,446,744,073,709,551,615 */ -#define N 4 - -/* These are the three towers. For example if the state of A is 0,1,3,4, that - * means that there are three discs on A of sizes 1, 3, and 4. (Think of right - * as being the "down" direction.) */ -int A[N], B[N], C[N]; - -void Hanoi(int,int*,int*,int*); - -/* Print the current configuration of A, B, and C to the screen */ -void PrintAll() -{ - int i; - - printf("A: "); - for(i=0;i -/* This checks various ways of dead code inside if statements - where there are non-obvious ways of how the code is actually - not dead due to reachable by labels. */ -extern int printf (const char *, ...); -static void kb_wait_1(void) -{ - unsigned long timeout = 2; - do { - /* Here the else arm is a statement expression that's supposed - to be suppressed. The label inside the while would unsuppress - code generation again if not handled correctly. And that - would wreak havoc to the cond-expression because there's no - jump-around emitted, the whole statement expression really - needs to not generate code (perhaps except useless forward jumps). */ - (1 ? - printf("timeout=%ld\n", timeout) : - ({ - int i = 1; - while (1) - while (i--) - some_label: - printf("error\n"); - goto some_label; - }) - ); - timeout--; - } while (timeout); -} - -static int global; - -static void foo(int i) -{ - global+=i; - printf ("g=%d\n", global); -} - -static int check(void) -{ - printf ("check %d\n", global); - return 1; -} - -static void dowhile(void) -{ - do { - foo(1); - if (global == 1) { - continue; - } else if (global == 2) { - continue; - } - /* The following break shouldn't disable the check() call, - as it's reachable by the continues above. */ - break; - } while (check()); -} - -int main (void) -{ - int i = 1; - kb_wait_1(); - - /* Simple test of dead code at first sight which isn't actually dead. */ - if (0) { -yeah: - printf ("yeah\n"); - } else { - printf ("boo\n"); - } - if (i--) - goto yeah; - - /* Some more non-obvious uses where the problems are loops, so that even - the first loop statements aren't actually dead. */ - i = 1; - if (0) { - while (i--) { - printf ("once\n"); -enterloop: - printf ("twice\n"); - } - } - if (i >= 0) - goto enterloop; - - /* The same with statement expressions. One might be tempted to - handle them specially by counting if inside statement exprs and - not unsuppressing code at loops at all then. - See kb_wait_1 for the other side of the medal where that wouldn't work. */ - i = ({ - int j = 1; - if (0) { - while (j--) { - printf ("SEonce\n"); - enterexprloop: - printf ("SEtwice\n"); - } - } - if (j >= 0) - goto enterexprloop; - j; }); - - /* The other two loop forms: */ - i = 1; - if (0) { - for (i = 1; i--;) { - printf ("once2\n"); -enterloop2: - printf ("twice2\n"); - } - } - if (i > 0) - goto enterloop2; - - i = 1; - if (0) { - do { - printf ("once3\n"); -enterloop3: - printf ("twice3\n"); - } while (i--); - } - if (i > 0) - goto enterloop3; - - /* And check that case and default labels have the same effect - of disabling code suppression. */ - i = 41; - switch (i) { - if (0) { - printf ("error\n"); - case 42: - printf ("error2\n"); - case 41: - printf ("caseok\n"); - } - } - - i = 41; - switch (i) { - if (0) { - printf ("error3\n"); - default: - printf ("caseok2\n"); - break; - case 42: - printf ("error4\n"); - } - } - - dowhile(); - - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test106/testsuite_106.c b/project/tests/in_progress/for_main/tests_suite/test106/testsuite_106.c deleted file mode 100644 index e635b4c6..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test106/testsuite_106.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -int strlen(char *); - -int -test() -{ - char *p; - - p = "hello"; - return strlen(p) - 5; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test110/testsuite_110.c b/project/tests/in_progress/for_main/tests_suite/test110/testsuite_110.c deleted file mode 100644 index 5a32c150..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test110/testsuite_110.c +++ /dev/null @@ -1,24 +0,0 @@ -#include -int -test() -{ - int x[2]; - int *p; - - x[1] = 7; - p = &x[0]; - p = p + 1; - - if(*p != 7) - return 1; - if(&x[1] - &x[0] != 1) - return 1; - - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test111/testsuite_111.c b/project/tests/in_progress/for_main/tests_suite/test111/testsuite_111.c deleted file mode 100644 index b703ad40..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test111/testsuite_111.c +++ /dev/null @@ -1,24 +0,0 @@ -#include - -int test() -{ - char a; - int b; - double c; - - printf("%d\n", sizeof(a)); - printf("%d\n", sizeof(b)); - printf("%d\n", sizeof(c)); - - printf("%d\n", sizeof(!a)); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test112/testsuite_112.c b/project/tests/in_progress/for_main/tests_suite/test112/testsuite_112.c deleted file mode 100644 index ce5ef76c..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test112/testsuite_112.c +++ /dev/null @@ -1,24 +0,0 @@ -#include - -int test() -{ - printf("Hello world\n"); - - int Count; - for (Count = -5; Count <= 5; Count++) - printf("Count = %d\n", Count); - - printf("String 'hello', 'there' is '%s', '%s'\n", "hello", "there"); - printf("Character 'A' is '%c'\n", 65); - printf("Character 'a' is '%c'\n", 'a'); - - return 0; -} - -// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test113/testsuite_113.c b/project/tests/in_progress/for_main/tests_suite/test113/testsuite_113.c deleted file mode 100644 index 98f1c5a4..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test113/testsuite_113.c +++ /dev/null @@ -1,22 +0,0 @@ -#include -int test() -{ - char * s; - - s = "abc" "def"; - if(s[0] != 'a') return 1; - if(s[1] != 'b') return 2; - if(s[2] != 'c') return 3; - if(s[3] != 'd') return 4; - if(s[4] != 'e') return 5; - if(s[5] != 'f') return 6; - if(s[6] != 0) return 7; - - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test114/testsuite_114.c b/project/tests/in_progress/for_main/tests_suite/test114/testsuite_114.c deleted file mode 100644 index 13571201..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test114/testsuite_114.c +++ /dev/null @@ -1,30 +0,0 @@ -#include -int x; -int x = 3; -int x; - -int test(); - -int -test() -{ - if (x != 3) - return 0; - - x = 0; - return x; -} - -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} - -void * -foo() -{ - return &main; -} - diff --git a/project/tests/in_progress/for_main/tests_suite/test115/testsuite_115.c b/project/tests/in_progress/for_main/tests_suite/test115/testsuite_115.c deleted file mode 100644 index a7cd9aff..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test115/testsuite_115.c +++ /dev/null @@ -1,26 +0,0 @@ -#include -int a[] = {5, [2] = 2, 3}; - -int -test() -{ - if (sizeof(a) != 4*sizeof(int)) - return 1; - - if (a[0] != 5) - return 2; - if (a[1] != 0) - return 3; - if (a[2] != 2) - return 4; - if (a[3] != 3) - return 5; - - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test116/testsuite_116.c b/project/tests/in_progress/for_main/tests_suite/test116/testsuite_116.c deleted file mode 100644 index f6c55650..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test116/testsuite_116.c +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -int test() -{ - char a[10]; - strcpy(a, "abcdef"); - printf("%s\n", &a[1]); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test117/testsuite_117.c b/project/tests/in_progress/for_main/tests_suite/test117/testsuite_117.c deleted file mode 100644 index 962494e3..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test117/testsuite_117.c +++ /dev/null @@ -1,21 +0,0 @@ -#include - -int test() -{ - int Count; - - for (Count = 0; Count < 10; Count++) - { - printf("%d\n", (Count < 5) ? (Count*Count) : (Count * 3)); - } - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test119/testsuite_119.c b/project/tests/in_progress/for_main/tests_suite/test119/testsuite_119.c deleted file mode 100644 index d1e52661..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test119/testsuite_119.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -int -test() -{ - return L'\0'; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test120/testsuite_120.c b/project/tests/in_progress/for_main/tests_suite/test120/testsuite_120.c deleted file mode 100644 index 7e825ec5..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test120/testsuite_120.c +++ /dev/null @@ -1,32 +0,0 @@ -#include -int -test(void) -{ - long i; - unsigned long u; - - i = 1; - i = -1; - i = -1l; - i = -1u; - i = -1ll; - i = (1ll << 32) - 1 & 3; - i = (long) ((1ll << 32) - 1) < 0; - i = -1u < 0; - - u = 1; - u = -1; - u = -1l; - u = -1u; - u = -1ll; - u = (1ll << 32) - 1 & 3; - u = (long) ((1ll << 32) - 1) < 0; - u = -1u < 0; - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test122/testsuite_122.c b/project/tests/in_progress/for_main/tests_suite/test122/testsuite_122.c deleted file mode 100644 index 62a51745..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test122/testsuite_122.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -int -test() -{ - int a = 0; - float f = a + 1; - - return f == a; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test124/testsuite_124.c b/project/tests/in_progress/for_main/tests_suite/test124/testsuite_124.c deleted file mode 100644 index 0caa8b7c..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test124/testsuite_124.c +++ /dev/null @@ -1,272 +0,0 @@ -/* example from http://barnyard.syr.edu/quickies/led.c */ - -/* led.c: print out number as if on 7 line led display. I.e., write integer - given on command line like this: - _ _ _ - | _| _| |_| |_ - | |_ _| | _| etc. - - We assume the terminal behaves like a classical teletype. So the top - lines of all digits have to be printed first, then the middle lines of - all digits, etc. - - By Terry R. McConnell - -compile: cc -o led led.c - -If you just want to link in the subroutine print_led that does all the -work, compile with -DNO_MAIN, and declare the following in any source file -that uses the call: - -extern void print_led(unsigned long x, char *buf); - -Bug: you cannot call repeatedly to print more than one number to a line. -That would require curses or some other terminal API that allows moving the -cursor to a previous line. - -*/ - - - -#include -#include - -#define MAX_DIGITS 32 -#define NO_MAIN - - -/* Print the top line of the digit d into buffer. - Does not null terminate buffer. */ - -void topline(int d, char *p){ - - *p++ = ' '; - switch(d){ - - /* all these have _ on top line */ - - case 0: - case 2: - case 3: - case 5: - case 7: - case 8: - case 9: - *p++ = '_'; - break; - default: - *p++=' '; - - } - *p++=' '; -} - -/* Print the middle line of the digit d into the buffer. - Does not null terminate. */ - -void midline(int d, char *p){ - - switch(d){ - - /* those that have leading | on middle line */ - - case 0: - case 4: - case 5: - case 6: - case 8: - case 9: - *p++='|'; - break; - default: - *p++=' '; - } - switch(d){ - - /* those that have _ on middle line */ - - case 2: - case 3: - case 4: - case 5: - case 6: - case 8: - case 9: - *p++='_'; - break; - default: - *p++=' '; - - } - switch(d){ - - /* those that have closing | on middle line */ - - case 0: - case 1: - case 2: - case 3: - case 4: - case 7: - case 8: - case 9: - *p++='|'; - break; - default: - *p++=' '; - - } -} - -/* Print the bottom line of the digit d. Does not null terminate. */ - -void botline(int d, char *p){ - - - switch(d){ - - /* those that have leading | on bottom line */ - - case 0: - case 2: - case 6: - case 8: - *p++='|'; - break; - default: - *p++=' '; - } - switch(d){ - - /* those that have _ on bottom line */ - - case 0: - case 2: - case 3: - case 5: - case 6: - case 8: - *p++='_'; - break; - default: - *p++=' '; - - } - switch(d){ - - /* those that have closing | on bottom line */ - - case 0: - case 1: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - *p++='|'; - break; - default: - *p++=' '; - - } -} - -/* Write the led representation of integer to string buffer. */ - -void print_led(unsigned long x, char *buf) -{ - - int i=0,n; - static int d[MAX_DIGITS]; - - - /* extract digits from x */ - - n = ( x == 0L ? 1 : 0 ); /* 0 is a digit, hence a special case */ - - while(x){ - d[n++] = (int)(x%10L); - if(n >= MAX_DIGITS)break; - x = x/10L; - } - - /* print top lines of all digits */ - - for(i=n-1;i>=0;i--){ - topline(d[i],buf); - buf += 3; - *buf++=' '; - } - *buf++='\n'; /* move teletype to next line */ - - /* print middle lines of all digits */ - - for(i=n-1;i>=0;i--){ - midline(d[i],buf); - buf += 3; - *buf++=' '; - } - *buf++='\n'; - - /* print bottom lines of all digits */ - - for(i=n-1;i>=0;i--){ - botline(d[i],buf); - buf += 3; - *buf++=' '; - } - *buf++='\n'; - *buf='\0'; -} - -int test() -{ - char buf[5*MAX_DIGITS]; - print_led(1234567, buf); - printf("%s\n",buf); - - return 0; -} - -#ifndef NO_MAIN -int test(int argc, char **argv) -{ - - int i=0,n; - long x; - static int d[MAX_DIGITS]; - char buf[5*MAX_DIGITS]; - - if(argc != 2){ - fprintf(stderr,"led: usage: led integer\n"); - return 1; - } - - /* fetch argument from command line */ - - x = atol(argv[1]); - - /* sanity check */ - - if(x<0){ - fprintf(stderr,"led: %d must be non-negative\n",x); - return 1; - } - - print_led(x,buf); - printf("%s\n",buf); - - return 0; - -} -#endif - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test126/testsuite_126.c b/project/tests/in_progress/for_main/tests_suite/test126/testsuite_126.c deleted file mode 100644 index 727a8bda..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test126/testsuite_126.c +++ /dev/null @@ -1,20 +0,0 @@ -#include -int -test() -{ - start: - goto next; - return 1; - success: - return 0; - next: - foo: - goto success; - return 1; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test127/testsuite_127.c b/project/tests/in_progress/for_main/tests_suite/test127/testsuite_127.c deleted file mode 100644 index 75b274aa..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test127/testsuite_127.c +++ /dev/null @@ -1,36 +0,0 @@ -#include - -static int fred = 1234; -static int joe; - -void henry() -{ - static int fred = 4567; - - printf("%d\n", fred); - fred++; -} - -int test() -{ - printf("%d\n", fred); - henry(); - henry(); - henry(); - henry(); - printf("%d\n", fred); - fred = 8901; - joe = 2345; - printf("%d\n", fred); - printf("%d\n", joe); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test128/testsuite_128.c b/project/tests/in_progress/for_main/tests_suite/test128/testsuite_128.c deleted file mode 100644 index 4169ea0e..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test128/testsuite_128.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -int -test() -{ - int x; - int *p; - - x = 0; - p = &x; - return p[0]; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test129/testsuite_129.c b/project/tests/in_progress/for_main/tests_suite/test129/testsuite_129.c deleted file mode 100644 index e4cd86b5..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test129/testsuite_129.c +++ /dev/null @@ -1,23 +0,0 @@ -#include - -int test() -{ - int a; - - for (a = 0; a < 2; a++) - { - int b = a; - } - - printf("it's all good\n"); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test133/testsuite_133.c b/project/tests/in_progress/for_main/tests_suite/test133/testsuite_133.c deleted file mode 100644 index de8aa42f..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test133/testsuite_133.c +++ /dev/null @@ -1,113 +0,0 @@ -#include -extern int printf(const char *format, ...); -static void kb_wait_1(void) -{ - unsigned long timeout = 2; - do { - if (1) printf("timeout=%ld\n", timeout); - else - { - while (1) - printf("error\n"); - } - timeout--; - } while (timeout); -} -static void kb_wait_2(void) -{ - unsigned long timeout = 2; - do { - if (1) printf("timeout=%ld\n", timeout); - else - { - for (;;) - printf("error\n"); - } - timeout--; - } while (timeout); -} -static void kb_wait_2_1(void) -{ - unsigned long timeout = 2; - do { - if (1) printf("timeout=%ld\n", timeout); - else - { - do { - printf("error\n"); - } while (1); - } - timeout--; - } while (timeout); -} -static void kb_wait_2_2(void) -{ - unsigned long timeout = 2; - do { - if (1) printf("timeout=%ld\n", timeout); - else - { - label: - printf("error\n"); - goto label; - } - timeout--; - } while (timeout); -} -static void kb_wait_3(void) -{ - unsigned long timeout = 2; - do { - if (1) printf("timeout=%ld\n", timeout); - else - { - int i = 1; - goto label; - i = i + 2; - label: - i = i + 3; - } - timeout--; - } while (timeout); -} -static void kb_wait_4(void) -{ - unsigned long timeout = 2; - do { - if (1) printf("timeout=%ld\n", timeout); - else - { - switch(timeout) { - case 2: - printf("timeout is 2"); - break; - case 1: - printf("timeout is 1"); - break; - default: - printf("timeout is 0?"); - break; - }; - /* return; */ - } - timeout--; - } while (timeout); -} -int test() -{ - printf("begin\n"); - kb_wait_1(); - kb_wait_2(); - kb_wait_2_1(); - kb_wait_2_2(); - kb_wait_3(); - kb_wait_4(); - printf("end\n"); - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test134/testsuite_134.c b/project/tests/in_progress/for_main/tests_suite/test134/testsuite_134.c deleted file mode 100644 index 7a2e87bc..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test134/testsuite_134.c +++ /dev/null @@ -1,56 +0,0 @@ -#include -#include - -int test() -{ - // variables - float a = 12.34 + 56.78; - printf("%f\n", a); - - // infix operators - printf("%f\n", 12.34 + 56.78); - printf("%f\n", 12.34 - 56.78); - printf("%f\n", 12.34 * 56.78); - printf("%f\n", 12.34 / 56.78); - - // comparison operators - printf("%d %d %d %d %d %d\n", 12.34 < 56.78, 12.34 <= 56.78, 12.34 == 56.78, 12.34 >= 56.78, 12.34 > 56.78, 12.34 != 56.78); - printf("%d %d %d %d %d %d\n", 12.34 < 12.34, 12.34 <= 12.34, 12.34 == 12.34, 12.34 >= 12.34, 12.34 > 12.34, 12.34 != 12.34); - printf("%d %d %d %d %d %d\n", 56.78 < 12.34, 56.78 <= 12.34, 56.78 == 12.34, 56.78 >= 12.34, 56.78 > 12.34, 56.78 != 12.34); - - // assignment operators - a = 12.34; - a += 56.78; - printf("%f\n", a); - - a = 12.34; - a -= 56.78; - printf("%f\n", a); - - a = 12.34; - a *= 56.78; - printf("%f\n", a); - - a = 12.34; - a /= 56.78; - printf("%f\n", a); - - // prefix operators - printf("%f\n", +12.34); - printf("%f\n", -12.34); - - // type coercion - a = 2; - printf("%f\n", a); - printf("%f\n", sin(2)); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test137/testsuite_137.c b/project/tests/in_progress/for_main/tests_suite/test137/testsuite_137.c deleted file mode 100644 index 11c149dd..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test137/testsuite_137.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -int -test() -{ - char *p; - - p = "hello"; - return p[0] - 104; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test140/testsuite_140.c b/project/tests/in_progress/for_main/tests_suite/test140/testsuite_140.c deleted file mode 100644 index d5c5bb40..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test140/testsuite_140.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -int -test() -{ - unsigned long long x; - - x = 0; - x = x + 1; - if (x != 1) - return 1; - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test142/testsuite_142.c b/project/tests/in_progress/for_main/tests_suite/test142/testsuite_142.c deleted file mode 100644 index 1930f0aa..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test142/testsuite_142.c +++ /dev/null @@ -1,18 +0,0 @@ -// this file contains BMP chars encoded in UTF-8 -#include -#include - -int test() -{ - wchar_t s[] = L"hello$$你好¢¢世界€€world"; - wchar_t *p; - for (p = s; *p; p++) printf("%04X ", (unsigned) *p); - printf("\n"); - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test149/testsuite_149.c b/project/tests/in_progress/for_main/tests_suite/test149/testsuite_149.c deleted file mode 100644 index 11dfbb06..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test149/testsuite_149.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -int -test() -{ - int x = 0; - int y = 1; - if(x ? 1 : 0) - return 1; - if(y ? 0 : 1) - return 2; - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test150/testsuite_150.c b/project/tests/in_progress/for_main/tests_suite/test150/testsuite_150.c deleted file mode 100644 index 9eecf1e7..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test150/testsuite_150.c +++ /dev/null @@ -1,14 +0,0 @@ -#include -double x = 100; - -int -test() -{ - return x < 1; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test151/testsuite_151.c b/project/tests/in_progress/for_main/tests_suite/test151/testsuite_151.c deleted file mode 100644 index 4f18033f..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test151/testsuite_151.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -int test() -{ - int x[] = { 1, 0 }; - return x[1]; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test152/testsuite_152.c b/project/tests/in_progress/for_main/tests_suite/test152/testsuite_152.c deleted file mode 100644 index 5f32fbcb..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test152/testsuite_152.c +++ /dev/null @@ -1,30 +0,0 @@ -#include -int -test(void) -{ - long long i; - unsigned long long u; - - i = 1; - i = -1; - i = -1l; - i = -1u; - i = -1ll; - i = -1ll & 3; - i = -1ll < 0; - - u = 1; - u = -1; - u = -1l; - u = -1u; - u = -1ll; - u = -1llu & 3; - u = -1llu < 0; - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test153/testsuite_153.c b/project/tests/in_progress/for_main/tests_suite/test153/testsuite_153.c deleted file mode 100644 index d3e2d56d..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test153/testsuite_153.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -int arr[][3][5] = { - { - { 0, 0, 3, 5 }, - { 1, [3] = 6, 7 }, - }, - { - { 1, 2 }, - { [4] = 7, }, - }, -}; - -int -test(void) -{ - return !(arr[0][1][4] == arr[1][1][4]); -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test162/testsuite_162.c b/project/tests/in_progress/for_main/tests_suite/test162/testsuite_162.c deleted file mode 100644 index 87003663..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test162/testsuite_162.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -int -test() -{ - int arr[2]; - int *p; - - p = &arr[0]; - p += 1; - *p = 123; - - if(arr[1] != 123) - return 1; - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test163/testsuite_163.c b/project/tests/in_progress/for_main/tests_suite/test163/testsuite_163.c deleted file mode 100644 index 700af540..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test163/testsuite_163.c +++ /dev/null @@ -1,37 +0,0 @@ -#include -int -zero() -{ - return 0; -} - -struct S -{ - int (*zerofunc)(); -} s = { &zero }; - -struct S * -anon() -{ - return &s; -} - -typedef struct S * (*fty)(); - -fty -go() -{ - return &anon; -} - -int -test() -{ - return go()()->zerofunc(); -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test164/testsuite_164.c b/project/tests/in_progress/for_main/tests_suite/test164/testsuite_164.c deleted file mode 100644 index 1622ef99..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test164/testsuite_164.c +++ /dev/null @@ -1,20 +0,0 @@ -#include - -int test() -{ - char a; - short b; - - printf("%d %d\n", sizeof(char), sizeof(a)); - printf("%d %d\n", sizeof(short), sizeof(b)); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test165/testsuite_165.c b/project/tests/in_progress/for_main/tests_suite/test165/testsuite_165.c deleted file mode 100644 index bda8c17c..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test165/testsuite_165.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $Id: lshift-type.c 53089 2012-07-06 11:18:26Z vinc17/ypig $ - -Tests on left-shift type, written by Vincent Lefevre . - -ISO C99 TC3 says: [6.5.7#3] "The integer promotions are performed on -each of the operands. The type of the result is that of the promoted -left operand." -*/ - -#include - -#define PTYPE(M) ((M) < 0 || -(M) < 0 ? -1 : 1) * (int) sizeof((M)+0) -#define CHECK(X,T) check(#X, PTYPE(X), PTYPE((X) << (T) 1)) -#define TEST1(X,T) do { CHECK(X,T); CHECK(X,unsigned T); } while (0) -#define TEST2(X) \ - do \ - { \ - TEST1((X),short); \ - TEST1((X),int); \ - TEST1((X),long); \ - TEST1((X),long long); \ - } \ - while (0) -#define TEST3(X,T) do { TEST2((T)(X)); TEST2((unsigned T)(X)); } while (0) -#define TEST4(X) \ - do \ - { \ - TEST3((X),short); \ - TEST3((X),int); \ - TEST3((X),long); \ - TEST3((X),long long); \ - } \ - while (0) - -static int debug, nfailed = 0; - -static void check (const char *s, int arg1, int shift) -{ - int failed = arg1 != shift; - if (debug || failed) - printf ("%s %d %d\n", s, arg1, shift); - nfailed += failed; -} - -int main (int argc, char **argv) -{ - debug = argc > 1; - TEST4(1); - TEST4(-1); - printf ("%d test(s) failed\n", nfailed); - return nfailed != 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test166/testsuite_166.c b/project/tests/in_progress/for_main/tests_suite/test166/testsuite_166.c deleted file mode 100644 index 4af82fbb..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test166/testsuite_166.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -int -test() -{ - int arr[2]; - int *p; - - p = &arr[1]; - p -= 1; - *p = 123; - - if(arr[0] != 123) - return 1; - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test170/testsuite_170.c b/project/tests/in_progress/for_main/tests_suite/test170/testsuite_170.c deleted file mode 100644 index c081ada5..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test170/testsuite_170.c +++ /dev/null @@ -1,37 +0,0 @@ -#include -int -test() -{ - int arr[2]; - int *p; - - arr[0] = 2; - arr[1] = 3; - p = &arr[0]; - if(*(p++) != 2) - return 1; - if(*(p++) != 3) - return 2; - - p = &arr[1]; - if(*(p--) != 3) - return 1; - if(*(p--) != 2) - return 2; - - p = &arr[0]; - if(*(++p) != 3) - return 1; - - p = &arr[1]; - if(*(--p) != 2) - return 1; - - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test171/testsuite_171.c b/project/tests/in_progress/for_main/tests_suite/test171/testsuite_171.c deleted file mode 100644 index 36597cdb..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test171/testsuite_171.c +++ /dev/null @@ -1,20 +0,0 @@ -#include -int -test() -{ - struct T { int x; } s1; - s1.x = 1; - { - struct T { int y; } s2; - s2.y = 1; - if (s1.x - s2.y != 0) - return 1; - } - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test172/testsuite_172.c b/project/tests/in_progress/for_main/tests_suite/test172/testsuite_172.c deleted file mode 100644 index 09b9c995..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test172/testsuite_172.c +++ /dev/null @@ -1,24 +0,0 @@ -#include -int -f1(char *p) -{ - return *p+1; -} - -int -test() -{ - char s = 1; - int v[1000]; - int f1(char *); - - if (f1(&s) != 2) - return 1; - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test173/testsuite_173.c b/project/tests/in_progress/for_main/tests_suite/test173/testsuite_173.c deleted file mode 100644 index 391e3d56..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test173/testsuite_173.c +++ /dev/null @@ -1,30 +0,0 @@ -#include - -void fred(int x) -{ - switch (x) - { - case 1: printf("1\n"); return; - case 2: printf("2\n"); break; - case 3: printf("3\n"); return; - } - - printf("out\n"); -} - -int test() -{ - fred(1); - fred(2); - fred(3); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test175/testsuite_175.c b/project/tests/in_progress/for_main/tests_suite/test175/testsuite_175.c deleted file mode 100644 index c5db0d12..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test175/testsuite_175.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -int -test() -{ - return "abc" == (void *)0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test176/testsuite_176.c b/project/tests/in_progress/for_main/tests_suite/test176/testsuite_176.c deleted file mode 100644 index f2a26336..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test176/testsuite_176.c +++ /dev/null @@ -1,45 +0,0 @@ -#include -int x = 0; - -int -test() -{ - switch(x) - case 0: - ; - switch(x) - case 0: - switch(x) { - case 0: - goto next; - default: - return 1; - } - return 1; - next: - switch(x) - case 1: - return 1; - switch(x) { - { - x = 1 + 1; - foo: - case 1: - return 1; - } - } - switch(x) { - case 0: - return x; - case 1: - return 1; - default: - return 1; - } -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test179/testsuite_179.c b/project/tests/in_progress/for_main/tests_suite/test179/testsuite_179.c deleted file mode 100644 index 57322b29..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test179/testsuite_179.c +++ /dev/null @@ -1,16 +0,0 @@ -#include -int -test() -{ - char a[16], b[16]; - - if(sizeof(a) != sizeof(b)) - return 1; - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test180/testsuite_180.c b/project/tests/in_progress/for_main/tests_suite/test180/testsuite_180.c deleted file mode 100644 index 3d198d09..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test180/testsuite_180.c +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -int -test() -{ - int32_t x; - int64_t l; - - x = 0; - l = 0; - - x = ~x; - if (x != 0xffffffff) - return 1; - - l = ~l; - if (x != 0xffffffffffffffff) - return 2; - - - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test181/testsuite_181.c b/project/tests/in_progress/for_main/tests_suite/test181/testsuite_181.c deleted file mode 100644 index 34d9738d..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test181/testsuite_181.c +++ /dev/null @@ -1,19 +0,0 @@ -#include -struct S { int a; int b; }; -struct S *s = &(struct S) { 1, 2 }; - -int -test() -{ - if(s->a != 1) - return 1; - if(s->b != 2) - return 2; - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test183/testsuite_183.c b/project/tests/in_progress/for_main/tests_suite/test183/testsuite_183.c deleted file mode 100644 index 6efde2c2..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test183/testsuite_183.c +++ /dev/null @@ -1,533 +0,0 @@ -// This program is designed to test some arm64-specific things, such as the -// calling convention, but should give the same results on any architecture. - -#include -#include -#include - -struct s1 { char x[1]; } s1 = { "0" }; -struct s2 { char x[2]; } s2 = { "12" }; -struct s3 { char x[3]; } s3 = { "345" }; -struct s4 { char x[4]; } s4 = { "6789" }; -struct s5 { char x[5]; } s5 = { "abcde" }; -struct s6 { char x[6]; } s6 = { "fghijk" }; -struct s7 { char x[7]; } s7 = { "lmnopqr" }; -struct s8 { char x[8]; } s8 = { "stuvwxyz" }; -struct s9 { char x[9]; } s9 = { "ABCDEFGHI" }; -struct s10 { char x[10]; } s10 = { "JKLMNOPQRS" }; -struct s11 { char x[11]; } s11 = { "TUVWXYZ0123" }; -struct s12 { char x[12]; } s12 = { "456789abcdef" }; -struct s13 { char x[13]; } s13 = { "ghijklmnopqrs" }; -struct s14 { char x[14]; } s14 = { "tuvwxyzABCDEFG" }; -struct s15 { char x[15]; } s15 = { "HIJKLMNOPQRSTUV" }; -struct s16 { char x[16]; } s16 = { "WXYZ0123456789ab" }; -struct s17 { char x[17]; } s17 = { "cdefghijklmnopqrs" }; - -struct hfa11 { float a; } hfa11 = { 11.1 }; -struct hfa12 { float a, b; } hfa12 = { 12.1, 12.2 }; -struct hfa13 { float a, b, c; } hfa13 = { 13.1, 13.2, 13.3 }; -struct hfa14 { float a, b, c, d; } hfa14 = { 14.1, 14.2, 14.3, 14.4 }; - -struct hfa21 { double a; } hfa21 = { 21.1 }; -struct hfa22 { double a, b; } hfa22 = { 22.1, 22.2 }; -struct hfa23 { double a, b, c; } hfa23 = { 23.1, 23.2, 23.3 }; -struct hfa24 { double a, b, c, d; } hfa24 = { 24.1, 24.2, 24.3, 24.4 }; - -struct hfa31 { long double a; } hfa31 = { 31.1 }; -struct hfa32 { long double a, b; } hfa32 = { 32.1, 32.2 }; -struct hfa33 { long double a, b, c; } hfa33 = { 33.1, 33.2, 33.3 }; -struct hfa34 { long double a, b, c, d; } hfa34 = { 34.1, 34.2, 34.3, 34.4 }; - -void fa_s1(struct s1 a) { printf("%.1s\n", a.x); } -void fa_s2(struct s2 a) { printf("%.2s\n", a.x); } -void fa_s3(struct s3 a) { printf("%.3s\n", a.x); } -void fa_s4(struct s4 a) { printf("%.4s\n", a.x); } -void fa_s5(struct s5 a) { printf("%.5s\n", a.x); } -void fa_s6(struct s6 a) { printf("%.6s\n", a.x); } -void fa_s7(struct s7 a) { printf("%.7s\n", a.x); } -void fa_s8(struct s8 a) { printf("%.8s\n", a.x); } -void fa_s9(struct s9 a) { printf("%.9s\n", a.x); } -void fa_s10(struct s10 a) { printf("%.10s\n", a.x); } -void fa_s11(struct s11 a) { printf("%.11s\n", a.x); } -void fa_s12(struct s12 a) { printf("%.12s\n", a.x); } -void fa_s13(struct s13 a) { printf("%.13s\n", a.x); } -void fa_s14(struct s14 a) { printf("%.14s\n", a.x); } -void fa_s15(struct s15 a) { printf("%.15s\n", a.x); } -void fa_s16(struct s16 a) { printf("%.16s\n", a.x); } -void fa_s17(struct s17 a) { printf("%.17s\n", a.x); } - -void fa_hfa11(struct hfa11 a) -{ printf("%.1f\n", a.a); } -void fa_hfa12(struct hfa12 a) -{ printf("%.1f %.1f\n", a.a, a.a); } -void fa_hfa13(struct hfa13 a) -{ printf("%.1f %.1f %.1f\n", a.a, a.b, a.c); } -void fa_hfa14(struct hfa14 a) -{ printf("%.1f %.1f %.1f %.1f\n", a.a, a.b, a.c, a.d); } - -void fa_hfa21(struct hfa21 a) -{ printf("%.1f\n", a.a); } -void fa_hfa22(struct hfa22 a) -{ printf("%.1f %.1f\n", a.a, a.a); } -void fa_hfa23(struct hfa23 a) -{ printf("%.1f %.1f %.1f\n", a.a, a.b, a.c); } -void fa_hfa24(struct hfa24 a) -{ printf("%.1f %.1f %.1f %.1f\n", a.a, a.b, a.c, a.d); } - -void fa_hfa31(struct hfa31 a) -{ printf("%.1Lf\n", a.a); } -void fa_hfa32(struct hfa32 a) -{ printf("%.1Lf %.1Lf\n", a.a, a.a); } -void fa_hfa33(struct hfa33 a) -{ printf("%.1Lf %.1Lf %.1Lf\n", a.a, a.b, a.c); } -void fa_hfa34(struct hfa34 a) -{ printf("%.1Lf %.1Lf %.1Lf %.1Lf\n", a.a, a.b, a.c, a.d); } - -void fa1(struct s8 a, struct s9 b, struct s10 c, struct s11 d, - struct s12 e, struct s13 f) -{ - printf("%.3s %.3s %.3s %.3s %.3s %.3s\n", a.x, b.x, c.x, d.x, e.x, f.x); -} - -void fa2(struct s9 a, struct s10 b, struct s11 c, struct s12 d, - struct s13 e, struct s14 f) -{ - printf("%.3s %.3s %.3s %.3s %.3s %.3s\n", a.x, b.x, c.x, d.x, e.x, f.x); -} - -void fa3(struct hfa14 a, struct hfa23 b, struct hfa32 c) -{ - printf("%.1f %.1f %.1f %.1f %.1Lf %.1Lf\n", - a.a, a.d, b.a, b.c, c.a, c.b); -} - -void fa4(struct s1 a, struct hfa14 b, struct s2 c, struct hfa24 d, - struct s3 e, struct hfa34 f) -{ - printf("%.1s %.1f %.1f %.2s %.1f %.1f %.3s %.1Lf %.1Lf\n", - a.x, b.a, b.d, c.x, d.a, d.d, e.x, f.a, f.d); -} - -void arg(void) -{ - printf("Arguments:\n"); - fa_s1(s1); - fa_s2(s2); - fa_s3(s3); - fa_s4(s4); - fa_s5(s5); - fa_s6(s6); - fa_s7(s7); - fa_s8(s8); - fa_s9(s9); - fa_s10(s10); - fa_s11(s11); - fa_s12(s12); - fa_s13(s13); - fa_s14(s14); - fa_s15(s15); - fa_s16(s16); - fa_s17(s17); - fa_hfa11(hfa11); - fa_hfa12(hfa12); - fa_hfa13(hfa13); - fa_hfa14(hfa14); - fa_hfa21(hfa21); - fa_hfa22(hfa22); - fa_hfa23(hfa23); - fa_hfa24(hfa24); - fa_hfa31(hfa31); - fa_hfa32(hfa32); - fa_hfa33(hfa33); - fa_hfa34(hfa34); - fa1(s8, s9, s10, s11, s12, s13); - fa2(s9, s10, s11, s12, s13, s14); - fa3(hfa14, hfa23, hfa32); - fa4(s1, hfa14, s2, hfa24, s3, hfa34); -} - -struct s1 fr_s1(void) { return s1; } -struct s2 fr_s2(void) { return s2; } -struct s3 fr_s3(void) { return s3; } -struct s4 fr_s4(void) { return s4; } -struct s5 fr_s5(void) { return s5; } -struct s6 fr_s6(void) { return s6; } -struct s7 fr_s7(void) { return s7; } -struct s8 fr_s8(void) { return s8; } -struct s9 fr_s9(void) { return s9; } -struct s10 fr_s10(void) { return s10; } -struct s11 fr_s11(void) { return s11; } -struct s12 fr_s12(void) { return s12; } -struct s13 fr_s13(void) { return s13; } -struct s14 fr_s14(void) { return s14; } -struct s15 fr_s15(void) { return s15; } -struct s16 fr_s16(void) { return s16; } -struct s17 fr_s17(void) { return s17; } - -struct hfa11 fr_hfa11(void) { return hfa11; } -struct hfa12 fr_hfa12(void) { return hfa12; } -struct hfa13 fr_hfa13(void) { return hfa13; } -struct hfa14 fr_hfa14(void) { return hfa14; } - -struct hfa21 fr_hfa21(void) { return hfa21; } -struct hfa22 fr_hfa22(void) { return hfa22; } -struct hfa23 fr_hfa23(void) { return hfa23; } -struct hfa24 fr_hfa24(void) { return hfa24; } - -struct hfa31 fr_hfa31(void) { return hfa31; } -struct hfa32 fr_hfa32(void) { return hfa32; } -struct hfa33 fr_hfa33(void) { return hfa33; } -struct hfa34 fr_hfa34(void) { return hfa34; } - -void ret(void) -{ - struct s1 t1 = fr_s1(); - struct s2 t2 = fr_s2(); - struct s3 t3 = fr_s3(); - struct s4 t4 = fr_s4(); - struct s5 t5 = fr_s5(); - struct s6 t6 = fr_s6(); - struct s7 t7 = fr_s7(); - struct s8 t8 = fr_s8(); - struct s9 t9 = fr_s9(); - struct s10 t10 = fr_s10(); - struct s11 t11 = fr_s11(); - struct s12 t12 = fr_s12(); - struct s13 t13 = fr_s13(); - struct s14 t14 = fr_s14(); - struct s15 t15 = fr_s15(); - struct s16 t16 = fr_s16(); - struct s17 t17 = fr_s17(); - printf("Return values:\n"); - printf("%.1s\n", t1.x); - printf("%.2s\n", t2.x); - printf("%.3s\n", t3.x); - printf("%.4s\n", t4.x); - printf("%.5s\n", t5.x); - printf("%.6s\n", t6.x); - printf("%.7s\n", t7.x); - printf("%.8s\n", t8.x); - printf("%.9s\n", t9.x); - printf("%.10s\n", t10.x); - printf("%.11s\n", t11.x); - printf("%.12s\n", t12.x); - printf("%.13s\n", t13.x); - printf("%.14s\n", t14.x); - printf("%.15s\n", t15.x); - printf("%.16s\n", t16.x); - printf("%.17s\n", t17.x); - printf("%.1f\n", fr_hfa11().a); - printf("%.1f %.1f\n", fr_hfa12().a, fr_hfa12().b); - printf("%.1f %.1f\n", fr_hfa13().a, fr_hfa13().c); - printf("%.1f %.1f\n", fr_hfa14().a, fr_hfa14().d); - printf("%.1f\n", fr_hfa21().a); - printf("%.1f %.1f\n", fr_hfa22().a, fr_hfa22().b); - printf("%.1f %.1f\n", fr_hfa23().a, fr_hfa23().c); - printf("%.1f %.1f\n", fr_hfa24().a, fr_hfa24().d); - printf("%.1Lf\n", fr_hfa31().a); - printf("%.1Lf %.1Lf\n", fr_hfa32().a, fr_hfa32().b); - printf("%.1Lf %.1Lf\n", fr_hfa33().a, fr_hfa33().c); - printf("%.1Lf %.1Lf\n", fr_hfa34().a, fr_hfa34().d); -} - -int match(const char **s, const char *f) -{ - const char *p = *s; - for (p = *s; *f && *f == *p; f++, p++) - ; - if (!*f) { - *s = p - 1; - return 1; - } - return 0; -} - -void myprintf(const char *format, ...) -{ - const char *s; - va_list ap; - va_start(ap, format); - for (s = format; *s; s++) { - if (match(&s, "%7s")) { - struct s7 t7 = va_arg(ap, struct s7); - printf("%.7s", t7.x); - } - else if (match(&s, "%9s")) { - struct s9 t9 = va_arg(ap, struct s9); - printf("%.9s", t9.x); - } - else if (match(&s, "%hfa11")) { - struct hfa11 x = va_arg(ap, struct hfa11); - printf("%.1f,%.1f", x.a, x.a); - } - else if (match(&s, "%hfa12")) { - struct hfa12 x = va_arg(ap, struct hfa12); - printf("%.1f,%.1f", x.a, x.b); - } - else if (match(&s, "%hfa13")) { - struct hfa13 x = va_arg(ap, struct hfa13); - printf("%.1f,%.1f", x.a, x.c); - } - else if (match(&s, "%hfa14")) { - struct hfa14 x = va_arg(ap, struct hfa14); - printf("%.1f,%.1f", x.a, x.d); - } - else if (match(&s, "%hfa21")) { - struct hfa21 x = va_arg(ap, struct hfa21); - printf("%.1f,%.1f", x.a, x.a); - } - else if (match(&s, "%hfa22")) { - struct hfa22 x = va_arg(ap, struct hfa22); - printf("%.1f,%.1f", x.a, x.b); - } - else if (match(&s, "%hfa23")) { - struct hfa23 x = va_arg(ap, struct hfa23); - printf("%.1f,%.1f", x.a, x.c); - } - else if (match(&s, "%hfa24")) { - struct hfa24 x = va_arg(ap, struct hfa24); - printf("%.1f,%.1f", x.a, x.d); - } - else if (match(&s, "%hfa31")) { - struct hfa31 x = va_arg(ap, struct hfa31); - printf("%.1Lf,%.1Lf", x.a, x.a); - } - else if (match(&s, "%hfa32")) { - struct hfa32 x = va_arg(ap, struct hfa32); - printf("%.1Lf,%.1Lf", x.a, x.b); - } - else if (match(&s, "%hfa33")) { - struct hfa33 x = va_arg(ap, struct hfa33); - printf("%.1Lf,%.1Lf", x.a, x.c); - } - else if (match(&s, "%hfa34")) { - struct hfa34 x = va_arg(ap, struct hfa34); - printf("%.1Lf,%.1Lf", x.a, x.d); - } - else - putchar(*s); - } - putchar('\n'); -} - -void stdarg(void) -{ - printf("stdarg:\n"); - myprintf("%9s %9s %9s %9s %9s %9s", s9, s9, s9, s9, s9, s9); - myprintf("%7s %9s %9s %9s %9s %9s", s7, s9, s9, s9, s9, s9); - - myprintf("HFA long double:"); - myprintf("%hfa34 %hfa34 %hfa34 %hfa34", hfa34, hfa34, hfa34, hfa34); - myprintf("%hfa33 %hfa34 %hfa34 %hfa34", hfa33, hfa34, hfa34, hfa34); - myprintf("%hfa32 %hfa34 %hfa34 %hfa34", hfa32, hfa34, hfa34, hfa34); - myprintf("%hfa31 %hfa34 %hfa34 %hfa34", hfa31, hfa34, hfa34, hfa34); - - myprintf("%hfa32 %hfa33 %hfa33 %hfa33 %hfa33", - hfa32, hfa33, hfa33, hfa33, hfa33); - myprintf("%hfa31 %hfa33 %hfa33 %hfa33 %hfa33", - hfa31, hfa33, hfa33, hfa33, hfa33); - myprintf("%hfa33 %hfa33 %hfa33 %hfa33", - hfa33, hfa33, hfa33, hfa33); - - myprintf("%hfa34 %hfa32 %hfa32 %hfa32 %hfa32", - hfa34, hfa32, hfa32, hfa32, hfa32); - myprintf("%hfa33 %hfa32 %hfa32 %hfa32 %hfa32", - hfa33, hfa32, hfa32, hfa32, hfa32); - - myprintf("%hfa34 %hfa32 %hfa31 %hfa31 %hfa31 %hfa31", - hfa34, hfa32, hfa31, hfa31, hfa31, hfa31); - - myprintf("HFA double:"); - myprintf("%hfa24 %hfa24 %hfa24 %hfa24", hfa24, hfa24, hfa24, hfa24); - myprintf("%hfa23 %hfa24 %hfa24 %hfa24", hfa23, hfa24, hfa24, hfa24); - myprintf("%hfa22 %hfa24 %hfa24 %hfa24", hfa22, hfa24, hfa24, hfa24); - myprintf("%hfa21 %hfa24 %hfa24 %hfa24", hfa21, hfa24, hfa24, hfa24); - - myprintf("%hfa22 %hfa23 %hfa23 %hfa23 %hfa23", - hfa22, hfa23, hfa23, hfa23, hfa23); - myprintf("%hfa21 %hfa23 %hfa23 %hfa23 %hfa23", - hfa21, hfa23, hfa23, hfa23, hfa23); - myprintf("%hfa23 %hfa23 %hfa23 %hfa23", - hfa23, hfa23, hfa23, hfa23); - - myprintf("%hfa24 %hfa22 %hfa22 %hfa22 %hfa22", - hfa24, hfa22, hfa22, hfa22, hfa22); - myprintf("%hfa23 %hfa22 %hfa22 %hfa22 %hfa22", - hfa23, hfa22, hfa22, hfa22, hfa22); - - myprintf("%hfa24 %hfa22 %hfa21 %hfa21 %hfa21 %hfa21", - hfa24, hfa22, hfa21, hfa21, hfa21, hfa21); - - myprintf("HFA float:"); - myprintf("%hfa14 %hfa14 %hfa14 %hfa14", hfa14, hfa14, hfa14, hfa14); - myprintf("%hfa13 %hfa14 %hfa14 %hfa14", hfa13, hfa14, hfa14, hfa14); - myprintf("%hfa12 %hfa14 %hfa14 %hfa14", hfa12, hfa14, hfa14, hfa14); - myprintf("%hfa11 %hfa14 %hfa14 %hfa14", hfa11, hfa14, hfa14, hfa14); - - myprintf("%hfa12 %hfa13 %hfa13 %hfa13 %hfa13", - hfa12, hfa13, hfa13, hfa13, hfa13); - myprintf("%hfa11 %hfa13 %hfa13 %hfa13 %hfa13", - hfa11, hfa13, hfa13, hfa13, hfa13); - myprintf("%hfa13 %hfa13 %hfa13 %hfa13", - hfa13, hfa13, hfa13, hfa13); - - myprintf("%hfa14 %hfa12 %hfa12 %hfa12 %hfa12", - hfa14, hfa12, hfa12, hfa12, hfa12); - myprintf("%hfa13 %hfa12 %hfa12 %hfa12 %hfa12", - hfa13, hfa12, hfa12, hfa12, hfa12); - - myprintf("%hfa14 %hfa12 %hfa11 %hfa11 %hfa11 %hfa11", - hfa14, hfa12, hfa11, hfa11, hfa11, hfa11); -} - -void pll(unsigned long long x) -{ - printf("%llx\n", x); -} - -void movi(void) -{ - printf("MOVI:\n"); - pll(0); - pll(0xabcd); - pll(0xabcd0000); - pll(0xabcd00000000); - pll(0xabcd000000000000); - pll(0xffffabcd); - pll(0xabcdffff); - pll(0xffffffffffffabcd); - pll(0xffffffffabcdffff); - pll(0xffffabcdffffffff); - pll(0xabcdffffffffffff); - pll(0xaaaaaaaa); - pll(0x5555555555555555); - pll(0x77777777); - pll(0x3333333333333333); - pll(0xf8f8f8f8); - pll(0x1e1e1e1e1e1e1e1e); - pll(0x3f803f80); - pll(0x01ff01ff01ff01ff); - pll(0x007fffc0); - pll(0x03fff80003fff800); - pll(0x0007fffffffffe00); - - pll(0xabcd1234); - pll(0xabcd00001234); - pll(0xabcd000000001234); - pll(0xabcd12340000); - pll(0xabcd000012340000); - pll(0xabcd123400000000); - pll(0xffffffffabcd1234); - pll(0xffffabcdffff1234); - pll(0xabcdffffffff1234); - pll(0xffffabcd1234ffff); - pll(0xabcdffff1234ffff); - pll(0xabcd1234ffffffff); - - pll(0xffffef0123456789); - pll(0xabcdef012345ffff); - - pll(0xabcdef0123456789); -} - -static uint32_t addip0(uint32_t x) { return x + 0; } -static uint64_t sublp0(uint64_t x) { return x - 0; } -static uint32_t addip123(uint32_t x) { return x + 123; } -static uint64_t addlm123(uint64_t x) { return x + -123; } -static uint64_t sublp4095(uint64_t x) { return x - 4095; } -static uint32_t subim503808(uint32_t x) { return x - -503808; } -static uint64_t addp12345(uint64_t x) { return x + 12345; } -static uint32_t subp12345(uint32_t x) { return x - 12345; } - -static uint32_t mvni(uint32_t x) { return 0xffffffff - x; } -static uint64_t negl(uint64_t x) { return 0 - x; } -static uint32_t rsbi123(uint32_t x) { return 123 - x; } -static uint64_t rsbl123(uint64_t x) { return 123 - x; } - -static uint32_t andi0(uint32_t x) { return x & 0; } -static uint64_t andlm1(uint64_t x) { return x & -1; } -static uint64_t orrl0(uint64_t x) { return x | 0; } -static uint32_t orrim1(uint32_t x) { return x | -1; } -static uint32_t eori0(uint32_t x) { return x ^ 0; } -static uint64_t eorlm1(uint64_t x) { return x ^ -1; } -static uint32_t and0xf0(uint32_t x) { return x & 0xf0; } -static uint64_t orr0xf0(uint64_t x) { return x | 0xf0; } -static uint64_t eor0xf0(uint64_t x) { return x ^ 0xf0; } - -static uint32_t lsli0(uint32_t x) { return x << 0; } -static uint32_t lsri0(uint32_t x) { return x >> 0; } -static int64_t asrl0(int64_t x) { return x >> 0; } -static uint32_t lsli1(uint32_t x) { return x << 1; } -static uint32_t lsli31(uint32_t x) { return x << 31; } -static uint64_t lsll1(uint64_t x) { return x << 1; } -static uint64_t lsll63(uint64_t x) { return x << 63; } -static uint32_t lsri1(uint32_t x) { return x >> 1; } -static uint32_t lsri31(uint32_t x) { return x >> 31; } -static uint64_t lsrl1(uint64_t x) { return x >> 1; } -static uint64_t lsrl63(uint64_t x) { return x >> 63; } -static int32_t asri1(int32_t x) { return x >> 1; } -static int32_t asri31(int32_t x) { return x >> 31; } -static int64_t asrl1(int64_t x) { return x >> 1; } -static int64_t asrl63(int64_t x) { return x >> 63; } - -void opi(void) -{ - int x = 1000; - pll(addip0(x)); - pll(sublp0(x)); - pll(addip123(x)); - pll(addlm123(x)); - pll(sublp4095(x)); - pll(subim503808(x)); - pll(addp12345(x)); - pll(subp12345(x)); - pll(mvni(x)); - pll(negl(x)); - pll(rsbi123(x)); - pll(rsbl123(x)); - pll(andi0(x)); - pll(andlm1(x)); - pll(orrl0(x)); - pll(orrim1(x)); - pll(eori0(x)); - pll(eorlm1(x)); - pll(and0xf0(x)); - pll(orr0xf0(x)); - pll(eor0xf0(x)); - pll(lsli0(x)); - pll(lsri0(x)); - pll(asrl0(x)); - pll(lsli1(x)); - pll(lsli31(x)); - pll(lsll1(x)); - pll(lsll63(x)); - pll(lsri1(x)); - pll(lsri31(x)); - pll(lsrl1(x)); - pll(lsrl63(x)); - pll(asri1(x)); - pll(asri31(x)); - pll(asrl1(x)); - pll(asrl63(x)); -} - -void pcs(void) -{ - arg(); - ret(); - stdarg(); - movi(); - opi(); -} - -int test() -{ - pcs(); - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test185/testsuite_185.c b/project/tests/in_progress/for_main/tests_suite/test185/testsuite_185.c deleted file mode 100644 index 90565561..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test185/testsuite_185.c +++ /dev/null @@ -1,20 +0,0 @@ -#include - -#define P(A,B) A ## B ; bob -#define Q(A,B) A ## B+ - -int test(void) -{ - int bob, jim = 21; - bob = P(jim,) *= 2; - printf("jim: %d, bob: %d\n", jim, bob); - jim = 60 Q(+,)3; - printf("jim: %d\n", jim); - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test186/testsuite_186.c b/project/tests/in_progress/for_main/tests_suite/test186/testsuite_186.c deleted file mode 100644 index 247eeb0b..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test186/testsuite_186.c +++ /dev/null @@ -1,14 +0,0 @@ -#include - -int -test(void) -{ - sizeof((int) 1); - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test188/testsuite_188.c b/project/tests/in_progress/for_main/tests_suite/test188/testsuite_188.c deleted file mode 100644 index 2032d6fa..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test188/testsuite_188.c +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include - -int test() -{ - char a[10]; - - strcpy(a, "hello"); - printf("%s\n", a); - - strncpy(a, "gosh", 2); - printf("%s\n", a); - - printf("%d\n", strcmp(a, "apple") > 0); - printf("%d\n", strcmp(a, "goere") > 0); - printf("%d\n", strcmp(a, "zebra") < 0); - - printf("%d\n", strlen(a)); - - strcat(a, "!"); - printf("%s\n", a); - - printf("%d\n", strncmp(a, "apple", 2) > 0); - printf("%d\n", strncmp(a, "goere", 2) == 0); - printf("%d\n", strncmp(a, "goerg", 2) == 0); - printf("%d\n", strncmp(a, "zebra", 2) < 0); - - printf("%s\n", strchr(a, 'o')); - printf("%s\n", strrchr(a, 'l')); - printf("%d\n", strrchr(a, 'x') == NULL); - - memset(&a[1], 'r', 4); - printf("%s\n", a); - - memcpy(&a[2], a, 2); - printf("%s\n", a); - - printf("%d\n", memcmp(a, "apple", 4) > 0); - printf("%d\n", memcmp(a, "grgr", 4) == 0); - printf("%d\n", memcmp(a, "zebra", 4) < 0); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test191/testsuite_191.c b/project/tests/in_progress/for_main/tests_suite/test191/testsuite_191.c deleted file mode 100644 index edc5d84f..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test191/testsuite_191.c +++ /dev/null @@ -1,288 +0,0 @@ -typedef unsigned char u8; -typedef struct {} empty_s; -struct contains_empty { - u8 a; - empty_s empty; - u8 b; -}; -struct contains_empty ce = { { (1) }, (empty_s){}, 022, }; -/* The following decl of 'q' would demonstrate the TCC bug in init_putv when - handling copying compound literals. (Compound literals - aren't acceptable constant initializers in isoc99, but - we accept them like gcc, except for this case) -//char *q = (char *){ "trara" }; */ -struct SS {u8 a[3], b; }; -struct SS sinit16[] = { { 1 }, 2 }; -struct S -{ - u8 a,b; - u8 c[2]; -}; - -struct T -{ - u8 s[16]; - u8 a; -}; - -struct U -{ - u8 a; - struct S s; - u8 b; - struct T t; -}; - -struct V -{ - struct S s; - struct T t; - u8 a; -}; - -struct W -{ - struct V t; - struct S s[]; -}; - -struct S gs = ((struct S){1, 2, 3, 4}); -struct S gs2 = {1, 2, {3, 4}}; -struct T gt = {"hello", 42}; -struct U gu = {3, 5,6,7,8, 4, "huhu", 43}; -struct U gu2 = {3, {5,6,7,8}, 4, {"huhu", 43}}; -/* Optional braces around scalar initializers. Accepted, but with - a warning. */ -struct U gu3 = { {3}, {5,6,7,8,}, 4, {"huhu", 43}}; -/* Many superfluous braces and leaving out one initializer for U.s.c[1] */ -struct U gu4 = { 3, {5,6,7,}, 5, { "bla", {44}} }; -/* Superfluous braces and useless parens around values */ -struct S gs3 = { (1), {(2)}, {(((3))), {4}}}; -/* Superfluous braces, and leaving out braces for V.t, plus cast */ -struct V gv = {{{3},4,{5,6}}, "haha", (u8)45, 46}; -/* Compound literal */ -struct V gv2 = {(struct S){7,8,{9,10}}, {"hihi", 47}, 48}; -/* Parens around compound literal */ -struct V gv3 = {((struct S){7,8,{9,10}}), {"hoho", 49}, 50}; -/* Initialization of a flex array member (warns in GCC) */ -struct W gw = {{1,2,3,4}, {1,2,3,4,5}}; - -union UU { - u8 a; - u8 b; -}; -struct SU { - union UU u; - u8 c; -}; -struct SU gsu = {5,6}; - -/* Unnamed struct/union members aren't ISO C, but it's a widely accepted - extension. See below for further extensions to that under -fms-extension.*/ -union UV { - struct {u8 a,b;}; - struct S s; -}; -union UV guv = {{6,5}}; -union UV guv2 = {{.b = 7, .a = 8}}; -union UV guv3 = {.b = 8, .a = 7}; - -/* Under -fms-extensions also the following is valid: -union UV2 { - struct Anon {u8 a,b;}; // unnamed member, but tagged struct, ... - struct S s; -}; -struct Anon gan = { 10, 11 }; // ... which makes it available here. -union UV2 guv4 = {{4,3}}; // and the other inits from above as well -*/ - -struct in6_addr { - union { - u8 u6_addr8[16]; - unsigned short u6_addr16[8]; - } u; -}; -struct flowi6 { - struct in6_addr saddr, daddr; -}; -struct pkthdr { - struct in6_addr daddr, saddr; -}; -struct pkthdr phdr = { { { 6,5,4,3 } }, { { 9,8,7,6 } } }; - -struct Wrap { - void *func; -}; -int global; -void inc_global (void) -{ - global++; -} - -struct Wrap global_wrap[] = { - ((struct Wrap) {inc_global}), - inc_global, -}; - -#include -void print_ (const char *name, const u8 *p, long size) -{ - printf ("%s:", name); - while (size--) { - printf (" %x", *p++); - } - printf ("\n"); -} -#define print(x) print_(#x, (u8*)&x, sizeof (x)) -#if 1 -void foo (struct W *w, struct pkthdr *phdr_) -{ - struct S ls = {1, 2, 3, 4}; - struct S ls2 = {1, 2, {3, 4}}; - struct T lt = {"hello", 42}; - struct U lu = {3, 5,6,7,8, 4, "huhu", 43}; - struct U lu1 = {3, ls, 4, {"huhu", 43}}; - struct U lu2 = {3, (ls), 4, {"huhu", 43}}; - const struct S *pls = &ls; - struct S ls21 = *pls; - struct U lu22 = {3, *pls, 4, {"huhu", 43}}; - /* Incomplete bracing. */ - struct U lu21 = {3, ls, 4, "huhu", 43}; - /* Optional braces around scalar initializers. Accepted, but with - a warning. */ - struct U lu3 = { 3, {5,6,7,8,}, 4, {"huhu", 43}}; - /* Many superfluous braces and leaving out one initializer for U.s.c[1] */ - struct U lu4 = { 3, {5,6,7,}, 5, { "bla", 44} }; - /* Superfluous braces and useless parens around values */ - struct S ls3 = { (1), (2), {(((3))), 4}}; - /* Superfluous braces, and leaving out braces for V.t, plus cast */ - struct V lv = {{3,4,{5,6}}, "haha", (u8)45, 46}; - /* Compound literal */ - struct V lv2 = {(struct S)w->t.s, {"hihi", 47}, 48}; - /* Parens around compound literal */ - struct V lv3 = {((struct S){7,8,{9,10}}), ((const struct W *)w)->t.t, 50}; - const struct pkthdr *phdr = phdr_; - struct flowi6 flow = { .daddr = phdr->daddr, .saddr = phdr->saddr }; - int elt = 0x42; - /* Range init, overlapping */ - struct T lt2 = { { [1 ... 5] = 9, [6 ... 10] = elt, [4 ... 7] = elt+1 }, 1 }; - print(ls); - print(ls2); - print(lt); - print(lu); - print(lu1); - print(lu2); - print(ls21); - print(lu21); - print(lu22); - print(lu3); - print(lu4); - print(ls3); - print(lv); - print(lv2); - print(lv3); - print(lt2); - print(flow); -} -#endif - -void test_compound_with_relocs (void) -{ - struct Wrap local_wrap[] = { - ((struct Wrap) {inc_global}), - inc_global, - }; - void (*p)(void); - p = global_wrap[0].func; p(); - p = global_wrap[1].func; p(); - p = local_wrap[0].func; p(); - p = local_wrap[1].func; p(); -} - -void sys_ni(void) { printf("ni\n"); } -void sys_one(void) { printf("one\n"); } -void sys_two(void) { printf("two\n"); } -void sys_three(void) { printf("three\n"); } -typedef void (*fptr)(void); -const fptr table[3] = { - [0 ... 2] = &sys_ni, - [0] = sys_one, - [1] = sys_two, - [2] = sys_three, -}; - -void test_multi_relocs(void) -{ - int i; - for (i = 0; i < sizeof(table)/sizeof(table[0]); i++) - table[i](); -} - -/* Following is from GCC gcc.c-torture/execute/20050613-1.c. */ - -struct SEA { int i; int j; int k; int l; }; -struct SEB { struct SEA a; int r[1]; }; -struct SEC { struct SEA a; int r[0]; }; -struct SED { struct SEA a; int r[]; }; - -static void -test_correct_filling (struct SEA *x) -{ - static int i; - if (x->i != 0 || x->j != 5 || x->k != 0 || x->l != 0) - printf("sea_fill%d: wrong\n", i); - else - printf("sea_fill%d: okay\n", i); - i++; -} - -int -test_zero_init (void) -{ - /* The peculiarity here is that only a.j is initialized. That - means that all other members must be zero initialized. TCC - once didn't do that for sub-level designators. */ - struct SEB b = { .a.j = 5 }; - struct SEC c = { .a.j = 5 }; - struct SED d = { .a.j = 5 }; - test_correct_filling (&b.a); - test_correct_filling (&c.a); - test_correct_filling (&d.a); - return 0; -} - -int test() -{ - print(ce); - print(gs); - print(gs2); - print(gt); - print(gu); - print(gu2); - print(gu3); - print(gu4); - print(gs3); - print(gv); - print(gv2); - print(gv3); - print(sinit16); - print(gw); - print(gsu); - print(guv); - print(guv.b); - print(guv2); - print(guv3); - print(phdr); - foo(&gw, &phdr); - //printf("q: %s\n", q); - test_compound_with_relocs(); - test_multi_relocs(); - test_zero_init(); - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test194/testsuite_194.c b/project/tests/in_progress/for_main/tests_suite/test194/testsuite_194.c deleted file mode 100644 index c73a6a5a..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test194/testsuite_194.c +++ /dev/null @@ -1,55 +0,0 @@ -#include -int -foo(int x[100]) -{ - int y[100]; - int *p; - - y[0] = 2000; - - if(x[0] != 1000) - { - return 1; - } - - p = x; - - if(p[0] != 1000) - { - return 2; - } - - p = y; - - if(p[0] != 2000) - { - return 3; - } - - if(sizeof(x) != sizeof(void*)) - { - return 4; - } - - if(sizeof(y) <= sizeof(x)) - { - return 5; - } - - return 0; -} - -int -test() -{ - int x[100]; - x[0] = 1000; - - return foo(x); -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test195/testsuite_195.c b/project/tests/in_progress/for_main/tests_suite/test195/testsuite_195.c deleted file mode 100644 index 31b94f00..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test195/testsuite_195.c +++ /dev/null @@ -1,58 +0,0 @@ -#include - -int test() -{ - FILE *f = fopen("fred.txt", "w"); - fwrite("hello\nhello\n", 1, 12, f); - fclose(f); - - char freddy[7]; - f = fopen("fred.txt", "r"); - if (fread(freddy, 1, 6, f) != 6) - printf("couldn't read fred.txt\n"); - - freddy[6] = '\0'; - fclose(f); - - printf("%s", freddy); - - int InChar; - char ShowChar; - f = fopen("fred.txt", "r"); - while ( (InChar = fgetc(f)) != EOF) - { - ShowChar = InChar; - if (ShowChar < ' ') - ShowChar = '.'; - - printf("ch: %d '%c'\n", InChar, ShowChar); - } - fclose(f); - - f = fopen("fred.txt", "r"); - while ( (InChar = getc(f)) != EOF) - { - ShowChar = InChar; - if (ShowChar < ' ') - ShowChar = '.'; - - printf("ch: %d '%c'\n", InChar, ShowChar); - } - fclose(f); - - f = fopen("fred.txt", "r"); - while (fgets(freddy, sizeof(freddy), f) != NULL) - printf("x: %s", freddy); - - fclose(f); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test197/testsuite_197.c b/project/tests/in_progress/for_main/tests_suite/test197/testsuite_197.c deleted file mode 100644 index 4ff6f279..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test197/testsuite_197.c +++ /dev/null @@ -1,62 +0,0 @@ -#include - -void fred() -{ - printf("In fred()\n"); - goto done; - printf("In middle\n"); -done: - printf("At end\n"); -} - -void joe() -{ - int b = 5678; - - printf("In joe()\n"); - - { - int c = 1234; - printf("c = %d\n", c); - goto outer; - printf("uh-oh\n"); - } - -outer: - - printf("done\n"); -} - -void henry() -{ - int a; - - printf("In henry()\n"); - goto inner; - - { - int b; -inner: - b = 1234; - printf("b = %d\n", b); - } - - printf("done\n"); -} - -int test() -{ - fred(); - joe(); - henry(); - - return 0; -} - -/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test200/testsuite_200.c b/project/tests/in_progress/for_main/tests_suite/test200/testsuite_200.c deleted file mode 100644 index 583383de..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test200/testsuite_200.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -struct S {int a; int b;}; -struct S arr[2] = {[1] = {3, 4}, [0] = {1, 2}}; - -int -test() -{ - if(arr[0].a != 1) - return 1; - if(arr[0].b != 2) - return 2; - if(arr[1].a != 3) - return 3; - if(arr[1].b != 4) - return 4; - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test204/testsuite_204.c b/project/tests/in_progress/for_main/tests_suite/test204/testsuite_204.c deleted file mode 100644 index 8a54b4ff..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test204/testsuite_204.c +++ /dev/null @@ -1,19 +0,0 @@ -#include -int x, x = 3, x; - -int -test() -{ - if (x != 3) - return 0; - - x = 0; - return x; -} - -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test207/testsuite_207.c b/project/tests/in_progress/for_main/tests_suite/test207/testsuite_207.c deleted file mode 100644 index 4cb5b544..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test207/testsuite_207.c +++ /dev/null @@ -1,78 +0,0 @@ -#include - -const int a = 0; - -struct a { - int a; -}; - -struct b { - int a; -}; - -int a_f() -{ - return 20; -} - -int b_f() -{ - return 10; -} - -typedef int (*fptr)(int); -int foo(int i) -{ - return i; -} - -typedef int int_type1; - -#define gen_sw(a) _Generic(a, const char *: 1, default: 8, int: 123); - -int test() -{ - int i = 0; - signed long int l = 2; - struct b titi; - const int * const ptr; - const char *ti; - int_type1 i2; - - i = _Generic(a, int: a_f, const int: b_f)(); - printf("%d\n", i); - i = _Generic(a, int: a_f() / 2, const int: b_f() / 2); - printf("%d\n", i); - i = _Generic(ptr, int *:1, int * const:2, default:20); - printf("%d\n", i); - i = gen_sw(a); - printf("%d\n", i); - i = _Generic(titi, struct a:1, struct b:2, default:20); - printf("%d\n", i); - i = _Generic(i2, char: 1, int : 0); - printf("%d\n", i); - i = _Generic(a, char:1, int[4]:2, default:5); - printf("%d\n", i); - i = _Generic(17, int :1, int **:2); - printf("%d\n", i); - i = _Generic(17L, int :1, long :2, long long : 3); - printf("%d\n", i); - i = _Generic("17, io", char *: 3, const char *: 1); - printf("%d\n", i); - i = _Generic(ti, const unsigned char *:1, const char *:4, char *:3, - const signed char *:2); - printf("%d\n", i); - printf("%s\n", _Generic(i + 2L, long: "long", int: "int", - long long: "long long")); - i = _Generic(l, long: 1, int: 2); - printf("%d\n", i); - i = _Generic(foo, fptr: 3, int: 4); - printf("%d\n", i); - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test208/testsuite_208.c b/project/tests/in_progress/for_main/tests_suite/test208/testsuite_208.c deleted file mode 100644 index 05355da1..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test208/testsuite_208.c +++ /dev/null @@ -1,16 +0,0 @@ -#include -int -test() -{ - if(0 ? 1 : 0) - return 1; - if(1 ? 0 : 1) - return 2; - return 0; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test210/testsuite_210.c b/project/tests/in_progress/for_main/tests_suite/test210/testsuite_210.c deleted file mode 100644 index d94aae73..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test210/testsuite_210.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -/* Disgusting, no? But it compiles and runs just fine. I feel a combination of - pride and revulsion at this discovery. If no one's thought of it before, - I think I'll name it after myself. - It amazes me that after 10 years of writing C there are still - little corners that I haven't explored fully. - - Tom Duff */ - -int test() -{ - int count, n; - short *from, *to; - short a[39], b[39]; - - for(n = 0; n < 39; n++) { - a[n] = n; - b[n] = 0; - } - from = a; - to = b; - count = 39; - n = (count + 7) / 8; - switch (count % 8) { - case 0: do { *to++ = *from++; - case 7: *to++ = *from++; - case 6: *to++ = *from++; - case 5: *to++ = *from++; - case 4: *to++ = *from++; - case 3: *to++ = *from++; - case 2: *to++ = *from++; - case 1: *to++ = *from++; - } while (--n > 0); - } - for(n = 0; n < 39; n++) - if(a[n] != b[n]) - return 1; - return 0; -}int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test211/testsuite_211.c b/project/tests/in_progress/for_main/tests_suite/test211/testsuite_211.c deleted file mode 100644 index 25287479..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test211/testsuite_211.c +++ /dev/null @@ -1,31 +0,0 @@ -#include -struct wchar { - char *data; char mem[1]; -}; -struct wint { - char *data; int mem[1]; -}; -int f1char (void) { - char s[9]="nonono"; - struct wchar q = {"bugs"}; - return !s[0]; -} -int f1int (void) { - char s[9]="nonono"; - struct wint q = {"bugs"}; - return !s[0]; -} -int test (void) { - char s[9]="nonono"; - static struct wchar q = {"bugs", {'c'}}; - //printf ("tcc has %s %s\n", s, q.data); - if (f1char() || f1int()) - printf ("bla\n"); - return !s[0]; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} diff --git a/project/tests/in_progress/for_main/tests_suite/test218/testsuite_218.c b/project/tests/in_progress/for_main/tests_suite/test218/testsuite_218.c deleted file mode 100644 index 137ed9f4..00000000 --- a/project/tests/in_progress/for_main/tests_suite/test218/testsuite_218.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -#define M(x) x -#define A(a,b) a(b) - -int -test(void) -{ - char *a = A(M,"hi"); - - return (a[1] == 'i') ? 0 : 1; -} -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/test_suit_modified/00001/00001.c b/project/tests/in_progress/test_suit_modified/00001/00001.c new file mode 100644 index 00000000..ba6e09a6 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00001/00001.c @@ -0,0 +1,13 @@ +int +test() +{ + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00002/00002.c b/project/tests/in_progress/test_suit_modified/00002/00002.c new file mode 100644 index 00000000..fd2d0c4c --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00002/00002.c @@ -0,0 +1,13 @@ +int +test() +{ + return 3-3; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00003/00003.c b/project/tests/in_progress/test_suit_modified/00003/00003.c new file mode 100644 index 00000000..e4a6a5c6 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00003/00003.c @@ -0,0 +1,16 @@ +int +test() +{ + int x; + + x = 4; + return x - 4; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00004/00004.c b/project/tests/in_progress/test_suit_modified/00004/00004.c new file mode 100644 index 00000000..8633400d --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00004/00004.c @@ -0,0 +1,20 @@ +int +test() +{ + int x; + int *p; + + x = 4; + p = &x; + *p = 0; + + return *p; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00005/00005.c b/project/tests/in_progress/test_suit_modified/00005/00005.c new file mode 100644 index 00000000..18a8460a --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00005/00005.c @@ -0,0 +1,31 @@ +int +test() +{ + int x; + int *p; + int **pp; + + x = 0; + p = &x; + pp = &p; + + if(*p) + return 1; + if(**pp) + return 1; + else + **pp = 1; + + if(x) + return 0; + else + return 1; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00006/00006.c b/project/tests/in_progress/test_suit_modified/00006/00006.c new file mode 100644 index 00000000..068ce23d --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00006/00006.c @@ -0,0 +1,18 @@ +int +test() +{ + int x; + + x = 50; + while (x) + x = x - 1; + return x; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test107/testsuite_107.c b/project/tests/in_progress/test_suit_modified/00007/00007.c similarity index 67% rename from project/tests/in_progress/for_main/tests_suite/test107/testsuite_107.c rename to project/tests/in_progress/test_suit_modified/00007/00007.c index f61b943f..dde4fa8f 100644 --- a/project/tests/in_progress/for_main/tests_suite/test107/testsuite_107.c +++ b/project/tests/in_progress/test_suit_modified/00007/00007.c @@ -1,4 +1,3 @@ -#include int test() { @@ -14,9 +13,11 @@ test() x = x - 1; return x; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00008/00008.c b/project/tests/in_progress/test_suit_modified/00008/00008.c new file mode 100644 index 00000000..abf1b6c0 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00008/00008.c @@ -0,0 +1,19 @@ +int +test() +{ + int x; + + x = 50; + do + x = x - 1; + while(x); + return x; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00009/00009.c b/project/tests/in_progress/test_suit_modified/00009/00009.c new file mode 100644 index 00000000..46a10a55 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00009/00009.c @@ -0,0 +1,19 @@ +int +test() +{ + int x; + + x = 1; + x = x * 10; + x = x / 2; + x = x % 3; + return x - 2; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00011/00011.c b/project/tests/in_progress/test_suit_modified/00011/00011.c new file mode 100644 index 00000000..db29bcc0 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00011/00011.c @@ -0,0 +1,16 @@ +int +test() +{ + int x; + int y; + x = y = 0; + return x; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00012/00012.c b/project/tests/in_progress/test_suit_modified/00012/00012.c new file mode 100644 index 00000000..60d99eb7 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00012/00012.c @@ -0,0 +1,13 @@ +int +test() +{ + return (2 + 2) * 2 - 8; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00015/00015.c b/project/tests/in_progress/test_suit_modified/00015/00015.c new file mode 100644 index 00000000..038ada86 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00015/00015.c @@ -0,0 +1,18 @@ +int +test() +{ + int arr[2]; + + arr[0] = 1; + arr[1] = 2; + + return arr[0] + arr[1] - 3; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test069/testsuite_069.c b/project/tests/in_progress/test_suit_modified/00016/00016.c similarity index 57% rename from project/tests/in_progress/for_main/tests_suite/test069/testsuite_069.c rename to project/tests/in_progress/test_suit_modified/00016/00016.c index 51c55635..7dab88a5 100644 --- a/project/tests/in_progress/for_main/tests_suite/test069/testsuite_069.c +++ b/project/tests/in_progress/test_suit_modified/00016/00016.c @@ -1,4 +1,3 @@ -#include int test() { @@ -9,9 +8,11 @@ test() *p = 0; return arr[1]; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test029/testsuite_029.c b/project/tests/in_progress/test_suit_modified/00017/00017.c similarity index 60% rename from project/tests/in_progress/for_main/tests_suite/test029/testsuite_029.c rename to project/tests/in_progress/test_suit_modified/00017/00017.c index 3aae8912..4a3a6def 100644 --- a/project/tests/in_progress/for_main/tests_suite/test029/testsuite_029.c +++ b/project/tests/in_progress/test_suit_modified/00017/00017.c @@ -1,4 +1,3 @@ -#include int test() { @@ -8,9 +7,11 @@ test() s.y = 5; return s.y - s.x - 2; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test097/testsuite_097.c b/project/tests/in_progress/test_suit_modified/00018/00018.c similarity index 66% rename from project/tests/in_progress/for_main/tests_suite/test097/testsuite_097.c rename to project/tests/in_progress/test_suit_modified/00018/00018.c index dad9c73b..17276e55 100644 --- a/project/tests/in_progress/for_main/tests_suite/test097/testsuite_097.c +++ b/project/tests/in_progress/test_suit_modified/00018/00018.c @@ -1,4 +1,3 @@ -#include int test() { @@ -12,9 +11,11 @@ test() return p->y + p->x - 3; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test174/testsuite_174.c b/project/tests/in_progress/test_suit_modified/00019/00019.c similarity index 63% rename from project/tests/in_progress/for_main/tests_suite/test174/testsuite_174.c rename to project/tests/in_progress/test_suit_modified/00019/00019.c index 72d7bb49..51f86dc0 100644 --- a/project/tests/in_progress/for_main/tests_suite/test174/testsuite_174.c +++ b/project/tests/in_progress/test_suit_modified/00019/00019.c @@ -1,4 +1,3 @@ -#include int test() { @@ -9,9 +8,11 @@ test() return s.p->p->p->p->p->x; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00020/00020.c b/project/tests/in_progress/test_suit_modified/00020/00020.c new file mode 100644 index 00000000..102a005d --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00020/00020.c @@ -0,0 +1,18 @@ +int +test() +{ + int x, *p, **pp; + + x = 0; + p = &x; + pp = &p; + return **pp; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00021/00021.c b/project/tests/in_progress/test_suit_modified/00021/00021.c new file mode 100644 index 00000000..f5de1728 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00021/00021.c @@ -0,0 +1,20 @@ +int +foo(int a, int b) +{ + return 2 + a - b; +} + +int +test() +{ + return foo(1, 3); +} + + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00022/00022.c b/project/tests/in_progress/test_suit_modified/00022/00022.c new file mode 100644 index 00000000..8d183806 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00022/00022.c @@ -0,0 +1,17 @@ +typedef int x; + +int +test() +{ + x v; + v = 0; + return v; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00023/00023.c b/project/tests/in_progress/test_suit_modified/00023/00023.c new file mode 100644 index 00000000..4338f75b --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00023/00023.c @@ -0,0 +1,17 @@ +int x; + +int +test() +{ + x = 0; + return x; +} + + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00024/00024.c b/project/tests/in_progress/test_suit_modified/00024/00024.c new file mode 100644 index 00000000..e995113a --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00024/00024.c @@ -0,0 +1,20 @@ +typedef struct { int x; int y; } s; + +s v; + +int +test() +{ + v.x = 1; + v.y = 2; + return 3 - v.x - v.y; +} + + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00027/00027.c b/project/tests/in_progress/test_suit_modified/00027/00027.c new file mode 100644 index 00000000..cab02408 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00027/00027.c @@ -0,0 +1,18 @@ +int +test() +{ + int x; + + x = 1; + x = x | 4; + return x - 5; +} + + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00028/00028.c b/project/tests/in_progress/test_suit_modified/00028/00028.c new file mode 100644 index 00000000..e15c3d79 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00028/00028.c @@ -0,0 +1,18 @@ +int +test() +{ + int x; + + x = 1; + x = x & 3; + return x - 1; +} + + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00029/00029.c b/project/tests/in_progress/test_suit_modified/00029/00029.c new file mode 100644 index 00000000..5426ff80 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00029/00029.c @@ -0,0 +1,18 @@ +int +test() +{ + int x; + + x = 1; + x = x ^ 3; + return x - 2; +} + + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00030/00030.c b/project/tests/in_progress/test_suit_modified/00030/00030.c new file mode 100644 index 00000000..a7b9baff --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00030/00030.c @@ -0,0 +1,32 @@ +int +f() +{ + return 100; +} + +int +test() +{ + if (f() > 1000) + return 1; + if (f() >= 1000) + return 1; + if (1000 < f()) + return 1; + if (1000 <= f()) + return 1; + if (1000 == f()) + return 1; + if (100 != f()) + return 1; + return 0; +} + + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test072/testsuite_072.c b/project/tests/in_progress/test_suit_modified/00031/00031.c similarity index 85% rename from project/tests/in_progress/for_main/tests_suite/test072/testsuite_072.c rename to project/tests/in_progress/test_suit_modified/00031/00031.c index 02afb262..e83483a1 100644 --- a/project/tests/in_progress/for_main/tests_suite/test072/testsuite_072.c +++ b/project/tests/in_progress/test_suit_modified/00031/00031.c @@ -1,4 +1,3 @@ -#include int zero() { @@ -47,9 +46,11 @@ test() return 0; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test154/testsuite_154.c b/project/tests/in_progress/test_suit_modified/00033/00033.c similarity index 87% rename from project/tests/in_progress/for_main/tests_suite/test154/testsuite_154.c rename to project/tests/in_progress/test_suit_modified/00033/00033.c index 3e8833e3..12d3c0f6 100644 --- a/project/tests/in_progress/for_main/tests_suite/test154/testsuite_154.c +++ b/project/tests/in_progress/test_suit_modified/00033/00033.c @@ -1,4 +1,3 @@ -#include int g; int @@ -44,9 +43,11 @@ test() return 0; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test041/testsuite_041.c b/project/tests/in_progress/test_suit_modified/00034/00034.c similarity index 81% rename from project/tests/in_progress/for_main/tests_suite/test041/testsuite_041.c rename to project/tests/in_progress/test_suit_modified/00034/00034.c index 3062eaac..9b7e4973 100644 --- a/project/tests/in_progress/for_main/tests_suite/test041/testsuite_041.c +++ b/project/tests/in_progress/test_suit_modified/00034/00034.c @@ -1,4 +1,3 @@ -#include int test() { @@ -31,9 +30,11 @@ test() return x - 15; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00035/00035.c b/project/tests/in_progress/test_suit_modified/00035/00035.c new file mode 100644 index 00000000..65e32ac2 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00035/00035.c @@ -0,0 +1,23 @@ +int +test() +{ + int x; + + x = 4; + if(!x != 0) + return 1; + if(!!x != 1) + return 1; + if(-x != 0 - 4) + return 1; + return 0; +} + + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00036/00036.c b/project/tests/in_progress/test_suit_modified/00036/00036.c new file mode 100644 index 00000000..a18dde08 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00036/00036.c @@ -0,0 +1,27 @@ +int +test() +{ + int x; + + x = 0; + x += 2; + x += 2; + if (x != 4) + return 1; + x -= 1; + if (x != 3) + return 2; + x *= 2; + if (x != 6) + return 3; + + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test118/testsuite_118.c b/project/tests/in_progress/test_suit_modified/00039/00039.c similarity index 62% rename from project/tests/in_progress/for_main/tests_suite/test118/testsuite_118.c rename to project/tests/in_progress/test_suit_modified/00039/00039.c index 2122875f..bb8eb980 100644 --- a/project/tests/in_progress/for_main/tests_suite/test118/testsuite_118.c +++ b/project/tests/in_progress/test_suit_modified/00039/00039.c @@ -1,4 +1,3 @@ -#include int test() { @@ -12,9 +11,11 @@ test() return 1; return 0; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test051/testsuite_051.c b/project/tests/in_progress/test_suit_modified/00042/00042.c similarity index 65% rename from project/tests/in_progress/for_main/tests_suite/test051/testsuite_051.c rename to project/tests/in_progress/test_suit_modified/00042/00042.c index c3a57d3f..ad0fecca 100644 --- a/project/tests/in_progress/for_main/tests_suite/test051/testsuite_051.c +++ b/project/tests/in_progress/test_suit_modified/00042/00042.c @@ -1,4 +1,3 @@ -#include int test() { @@ -10,9 +9,11 @@ test() return 1; return 0; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00043/00043.c b/project/tests/in_progress/test_suit_modified/00043/00043.c new file mode 100644 index 00000000..7c9b16a6 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00043/00043.c @@ -0,0 +1,27 @@ +struct s { + int x; + struct { + int y; + int z; + } nest; +}; + +int +test() { + struct s v; + v.x = 1; + v.nest.y = 2; + v.nest.z = 3; + if (v.x + v.nest.y + v.nest.z != 6) + return 1; + return 0; +} + + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00044/00044.c b/project/tests/in_progress/test_suit_modified/00044/00044.c new file mode 100644 index 00000000..cb3c17d2 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00044/00044.c @@ -0,0 +1,24 @@ +struct T; + +struct T { + int x; +}; + +int +test() +{ + struct T v; + { struct T { int z; }; } + v.x = 2; + if(v.x != 2) + return 1; + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test104/testsuite_104.c b/project/tests/in_progress/test_suit_modified/00046/00046.c similarity index 83% rename from project/tests/in_progress/for_main/tests_suite/test104/testsuite_104.c rename to project/tests/in_progress/test_suit_modified/00046/00046.c index 8400df07..319a5a50 100644 --- a/project/tests/in_progress/for_main/tests_suite/test104/testsuite_104.c +++ b/project/tests/in_progress/test_suit_modified/00046/00046.c @@ -1,4 +1,3 @@ -#include typedef struct { int a; union { @@ -32,9 +31,11 @@ test() return 0; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test155/testsuite_155.c b/project/tests/in_progress/test_suit_modified/00047/00047.c similarity index 71% rename from project/tests/in_progress/for_main/tests_suite/test155/testsuite_155.c rename to project/tests/in_progress/test_suit_modified/00047/00047.c index 9893e80a..ac1f60b0 100644 --- a/project/tests/in_progress/for_main/tests_suite/test155/testsuite_155.c +++ b/project/tests/in_progress/test_suit_modified/00047/00047.c @@ -1,4 +1,3 @@ -#include struct { int a; int b; int c; } s = {1, 2, 3}; int @@ -13,9 +12,11 @@ test() return 0; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test094/testsuite_094.c b/project/tests/in_progress/test_suit_modified/00048/00048.c similarity index 68% rename from project/tests/in_progress/for_main/tests_suite/test094/testsuite_094.c rename to project/tests/in_progress/test_suit_modified/00048/00048.c index cfe5fa90..b29792bd 100644 --- a/project/tests/in_progress/for_main/tests_suite/test094/testsuite_094.c +++ b/project/tests/in_progress/test_suit_modified/00048/00048.c @@ -1,4 +1,3 @@ -#include struct S {int a; int b;}; struct S s = { .b = 2, .a = 1}; @@ -11,9 +10,11 @@ test() return 2; return 0; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test159/testsuite_159.c b/project/tests/in_progress/test_suit_modified/00049/00049.c similarity index 70% rename from project/tests/in_progress/for_main/tests_suite/test159/testsuite_159.c rename to project/tests/in_progress/test_suit_modified/00049/00049.c index 3fe62945..ae5cb117 100644 --- a/project/tests/in_progress/for_main/tests_suite/test159/testsuite_159.c +++ b/project/tests/in_progress/test_suit_modified/00049/00049.c @@ -1,4 +1,3 @@ -#include int x = 10; struct S {int a; int *p;}; @@ -13,9 +12,11 @@ test() return 2; return 0; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00052/00052.c b/project/tests/in_progress/test_suit_modified/00052/00052.c new file mode 100644 index 00000000..997ce39d --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00052/00052.c @@ -0,0 +1,19 @@ +int +test() +{ + struct T { int x; }; + { + struct T s; + s.x = 0; + return s.x; + } +} + + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test037/testsuite_037.c b/project/tests/in_progress/test_suit_modified/00054/00054.c similarity index 69% rename from project/tests/in_progress/for_main/tests_suite/test037/testsuite_037.c rename to project/tests/in_progress/test_suit_modified/00054/00054.c index 6c56b27f..2acb9b52 100644 --- a/project/tests/in_progress/for_main/tests_suite/test037/testsuite_037.c +++ b/project/tests/in_progress/test_suit_modified/00054/00054.c @@ -1,4 +1,3 @@ -#include enum E { x, y, @@ -21,9 +20,11 @@ test() return e; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test056/testsuite_056.c b/project/tests/in_progress/test_suit_modified/00055/00055.c similarity index 70% rename from project/tests/in_progress/for_main/tests_suite/test056/testsuite_056.c rename to project/tests/in_progress/test_suit_modified/00055/00055.c index 436eeac7..26f973aa 100644 --- a/project/tests/in_progress/for_main/tests_suite/test056/testsuite_056.c +++ b/project/tests/in_progress/test_suit_modified/00055/00055.c @@ -1,4 +1,3 @@ -#include enum E { x, y = 2, @@ -21,9 +20,11 @@ test() return e; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test161/testsuite_161.c b/project/tests/in_progress/test_suit_modified/00056/00056.c similarity index 56% rename from project/tests/in_progress/for_main/tests_suite/test161/testsuite_161.c rename to project/tests/in_progress/test_suit_modified/00056/00056.c index a2478f4c..8890feff 100644 --- a/project/tests/in_progress/for_main/tests_suite/test161/testsuite_161.c +++ b/project/tests/in_progress/test_suit_modified/00056/00056.c @@ -1,6 +1,6 @@ #include -int test() +int test() { int a; a = 42; @@ -10,15 +10,19 @@ int test() printf("%d\n", b); int c = 12, d = 34; - printf("%d, %d\n", c, d); + printf("%d\n", c); + printf("%d\n", d); return 0; } // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test075/testsuite_075.c b/project/tests/in_progress/test_suit_modified/00059/00059.c similarity index 51% rename from project/tests/in_progress/for_main/tests_suite/test075/testsuite_075.c rename to project/tests/in_progress/test_suit_modified/00059/00059.c index 7b6bb68e..eb6f5ec8 100644 --- a/project/tests/in_progress/for_main/tests_suite/test075/testsuite_075.c +++ b/project/tests/in_progress/test_suit_modified/00059/00059.c @@ -1,4 +1,3 @@ -#include int test() { @@ -7,9 +6,11 @@ test() return 0; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00060/00060.c b/project/tests/in_progress/test_suit_modified/00060/00060.c new file mode 100644 index 00000000..ca49d46b --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00060/00060.c @@ -0,0 +1,19 @@ +// line comment + +int +test() +{ + /* + multiline + comment + */ + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00061/00061.c b/project/tests/in_progress/test_suit_modified/00061/00061.c new file mode 100644 index 00000000..400d5132 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00061/00061.c @@ -0,0 +1,15 @@ +#define FOO 0 + +int test() +{ + return FOO; +} + + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00062/00062.c b/project/tests/in_progress/test_suit_modified/00062/00062.c new file mode 100644 index 00000000..36201cf3 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00062/00062.c @@ -0,0 +1,34 @@ +#ifdef FOO + XXX +#ifdef BAR + XXX +#endif + XXX +#endif + +#define FOO 1 + +#ifdef FOO + +#ifdef FOO +int x = 0; +#endif + +int +test() +{ + return x; +} +#endif + + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} + + + diff --git a/project/tests/in_progress/test_suit_modified/00063/00063.c b/project/tests/in_progress/test_suit_modified/00063/00063.c new file mode 100644 index 00000000..008d87c2 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00063/00063.c @@ -0,0 +1,28 @@ +#define BAR 0 +#ifdef BAR + #ifdef FOO + XXX + #ifdef FOO + XXX + #endif + #else + #define FOO + #ifdef FOO + int x = BAR; + #endif + #endif +#endif + +int +test() +{ + return BAR; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00064/00064.c b/project/tests/in_progress/test_suit_modified/00064/00064.c new file mode 100644 index 00000000..6a0cc6b7 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00064/00064.c @@ -0,0 +1,15 @@ +#define X 6 / 2 + +int +test() +{ + return X - 3; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00065/00065.c b/project/tests/in_progress/test_suit_modified/00065/00065.c new file mode 100644 index 00000000..3e8699d1 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00065/00065.c @@ -0,0 +1,16 @@ +#define ADD(X, Y) (X + Y) + + +int +test() +{ + return ADD(1, 2) - 3; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00066/00066.c b/project/tests/in_progress/test_suit_modified/00066/00066.c new file mode 100644 index 00000000..19197afe --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00066/00066.c @@ -0,0 +1,19 @@ +#define A 3 +#define FOO(X,Y,Z) X + Y + Z +#define SEMI ; + +int +test() +{ + if(FOO(1, 2, A) != 6) + return 1 SEMI + return FOO(0,0,0); +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00067/00067.c b/project/tests/in_progress/test_suit_modified/00067/00067.c new file mode 100644 index 00000000..b5f96f24 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00067/00067.c @@ -0,0 +1,26 @@ +#if 1 +int x = 0; +#endif + +#if 0 +int x = 1; +#if 1 + X +#endif +#ifndef AAA + X +#endif +#endif + +int test() +{ + return x; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00068/00068.c b/project/tests/in_progress/test_suit_modified/00068/00068.c new file mode 100644 index 00000000..18f506d0 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00068/00068.c @@ -0,0 +1,21 @@ +#if 0 +X +#elif 1 +int x = 0; +#else +X +#endif + +int +test() +{ + return x; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00069/00069.c b/project/tests/in_progress/test_suit_modified/00069/00069.c new file mode 100644 index 00000000..87023e57 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00069/00069.c @@ -0,0 +1,21 @@ +#if 0 +X +#elif 0 +X +#elif 1 +int x = 0; +#endif + +int +test() +{ + return x; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00070/00070.c b/project/tests/in_progress/test_suit_modified/00070/00070.c new file mode 100644 index 00000000..1c048c73 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00070/00070.c @@ -0,0 +1,23 @@ +#ifndef DEF +int x = 0; +#endif + +#define DEF + +#ifndef DEF +X +#endif + +int +test() +{ + return x; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00071/00071.c b/project/tests/in_progress/test_suit_modified/00071/00071.c new file mode 100644 index 00000000..c82d7b34 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00071/00071.c @@ -0,0 +1,20 @@ +#define X 1 +#undef X + +#ifdef X +FAIL +#endif + +int +test() +{ + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00074/00074.c b/project/tests/in_progress/test_suit_modified/00074/00074.c new file mode 100644 index 00000000..c7048cbc --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00074/00074.c @@ -0,0 +1,40 @@ +#if defined X +X +#endif + +#if defined(X) +X +#endif + +#if X +X +#endif + +#define X 0 + +#if X +X +#endif + +#if defined(X) +int x = 0; +#endif + +#undef X +#define X 1 + +#if X +int +test() +{ + return 0; +} +#endif + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00075/00075.c b/project/tests/in_progress/test_suit_modified/00075/00075.c new file mode 100644 index 00000000..aff09cbf --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00075/00075.c @@ -0,0 +1,174 @@ +#if (-2) != -2 +#error fail +#endif + +#if (0 || 0) != 0 +#error fail +#endif + +#if (1 || 0) != 1 +#error fail +#endif + +#if (1 || 1) != 1 +#error fail +#endif + +#if (0 && 0) != 0 +#error fail +#endif + +#if (1 && 0) != 0 +#error fail +#endif + +#if (0 && 1) != 0 +#error fail +#endif + +#if (1 && 1) != 1 +#error fail +#endif + +#if (0xf0 | 1) != 0xf1 +#error fail +#endif + +#if (0xf0 & 1) != 0 +#error fail +#endif + +#if (0xf0 & 0x1f) != 0x10 +#error fail +#endif + +#if (1 ^ 1) != 0 +#error fail +#endif + +#if (1 == 1) != 1 +#error fail +#endif + +#if (1 == 0) != 0 +#error fail +#endif + +#if (1 != 1) != 0 +#error fail +#endif + +#if (0 != 1) != 1 +#error fail +#endif + +#if (0 > 1) != 0 +#error fail +#endif + +#if (0 < 1) != 1 +#error fail +#endif + +#if (0 > -1) != 1 +#error fail +#endif + +#if (0 < -1) != 0 +#error fail +#endif + +#if (0 >= 1) != 0 +#error fail +#endif + +#if (0 <= 1) != 1 +#error fail +#endif + +#if (0 >= -1) != 1 +#error fail +#endif + +#if (0 <= -1) != 0 +#error fail +#endif + +#if (0 < 0) != 0 +#error fail +#endif + +#if (0 <= 0) != 1 +#error fail +#endif + +#if (0 > 0) != 0 +#error fail +#endif + +#if (0 >= 0) != 1 +#error fail +#endif + +#if (1 << 1) != 2 +#error fail +#endif + +#if (2 >> 1) != 1 +#error fail +#endif + +#if (2 + 1) != 3 +#error fail +#endif + +#if (2 - 3) != -1 +#error fail +#endif + +#if (2 * 3) != 6 +#error fail +#endif + +#if (6 / 3) != 2 +#error fail +#endif + +#if (7 % 3) != 1 +#error fail +#endif + +#if (2+2*3+2) != 10 +#error fail +#endif + +#if ((2+2)*(3+2)) != 20 +#error fail +#endif + +#if (2 + 2 + 2 + 2 == 2 + 2 * 3) != 1 +#error fail +#endif + +#if (0 ? 1 : 3) != 3 +#error fail +#endif + +#if (1 ? 3 : 1) != 3 +#error fail +#endif + +int +test() +{ + return 0; +} + + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00077/00077.c b/project/tests/in_progress/test_suit_modified/00077/00077.c new file mode 100644 index 00000000..64373d13 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00077/00077.c @@ -0,0 +1,76 @@ +#include + +int +foo(int x[100]) +// foo(int x[]) +// foo(int *x) +{ + int y[100]; + int *p; + + y[0] = 2000; + printf("y[0] = %d\n", y[0]); + printf("x[0] = %d\n", *x); + // printf("x[0] = %d\n", x[0]); + +// if(x[0] != 1000) + if(*x != 1000) + { + printf("x[0] != 1000\n"); + return 1; + } + printf("x[0] == 1000\n"); + + p = x; + +// if(p[0] != 1000) + if(*p != 1000) + { + return 2; + } + printf("p[0] == 1000\n"); + +// p = y; + p = &y[0]; + +// if(p[0] != 2000) + if(*p != 2000) + { + return 3; + } + printf("p[0] == 2000\n"); + + if(sizeof(x) != sizeof(void*)) + { + printf("sizeof(x) != sizeof(void*)\n"); + return 4; + } + printf("sizeof(x) == sizeof(void*)\n"); + + if(sizeof(y) <= sizeof(x)) + { + printf("sizeof(y) <= sizeof(x)\n"); + return 5; + } + printf("sizeof(y) = %d, sizeof(x) = %d\n", sizeof(y), sizeof(x)); + + return 0; +} + +int +test() +{ +// int x = 5; + int x[100]; + x[0] = 1000; + + return foo(&x[0]); +// return foo(x); +} + +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00077/00077m1.c b/project/tests/in_progress/test_suit_modified/00077/00077m1.c new file mode 100644 index 00000000..64373d13 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00077/00077m1.c @@ -0,0 +1,76 @@ +#include + +int +foo(int x[100]) +// foo(int x[]) +// foo(int *x) +{ + int y[100]; + int *p; + + y[0] = 2000; + printf("y[0] = %d\n", y[0]); + printf("x[0] = %d\n", *x); + // printf("x[0] = %d\n", x[0]); + +// if(x[0] != 1000) + if(*x != 1000) + { + printf("x[0] != 1000\n"); + return 1; + } + printf("x[0] == 1000\n"); + + p = x; + +// if(p[0] != 1000) + if(*p != 1000) + { + return 2; + } + printf("p[0] == 1000\n"); + +// p = y; + p = &y[0]; + +// if(p[0] != 2000) + if(*p != 2000) + { + return 3; + } + printf("p[0] == 2000\n"); + + if(sizeof(x) != sizeof(void*)) + { + printf("sizeof(x) != sizeof(void*)\n"); + return 4; + } + printf("sizeof(x) == sizeof(void*)\n"); + + if(sizeof(y) <= sizeof(x)) + { + printf("sizeof(y) <= sizeof(x)\n"); + return 5; + } + printf("sizeof(y) = %d, sizeof(x) = %d\n", sizeof(y), sizeof(x)); + + return 0; +} + +int +test() +{ +// int x = 5; + int x[100]; + x[0] = 1000; + + return foo(&x[0]); +// return foo(x); +} + +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00079/00079.c b/project/tests/in_progress/test_suit_modified/00079/00079.c new file mode 100644 index 00000000..9056479a --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00079/00079.c @@ -0,0 +1,25 @@ +#define x(y) ((y) + 1) + +int +test() +{ + int x; + int y; + + y = 0; + x = x(y); + + if(x != 1) + return 1; + + return 0; +} + + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test141/testsuite_141.c b/project/tests/in_progress/test_suit_modified/00080/00080.c similarity index 56% rename from project/tests/in_progress/for_main/tests_suite/test141/testsuite_141.c rename to project/tests/in_progress/test_suit_modified/00080/00080.c index 59d40393..4978d6ee 100644 --- a/project/tests/in_progress/for_main/tests_suite/test141/testsuite_141.c +++ b/project/tests/in_progress/test_suit_modified/00080/00080.c @@ -1,4 +1,3 @@ -#include void voidfn() { @@ -11,9 +10,11 @@ test() voidfn(); return 0; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00081/00081.c b/project/tests/in_progress/test_suit_modified/00081/00081.c new file mode 100644 index 00000000..43a003c5 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00081/00081.c @@ -0,0 +1,19 @@ +int +test() +{ + long long x; + + x = 0; + x = x + 1; + if (x != 1) + return 1; + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00083/00083.c b/project/tests/in_progress/test_suit_modified/00083/00083.c new file mode 100644 index 00000000..00602e20 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00083/00083.c @@ -0,0 +1,55 @@ +#define CALL(FUN, ...) FUN(__VA_ARGS__) + +int +one(int a) +{ + if (a != 1) + return 1; + + return 0; +} + +int +two(int a, int b) +{ + if (a != 1) + return 1; + if (b != 2) + return 1; + + return 0; +} + +int +three(int a, int b, int c) +{ + if (a != 1) + return 1; + if (b != 2) + return 1; + if (c != 3) + return 1; + + return 0; +} + +int +test() +{ + if (CALL(one, 1)) + return 2; + if (CALL(two, 1, 2)) + return 3; + if (CALL(three, 1, 2, 3)) + return 4; + + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00084/00084.c b/project/tests/in_progress/test_suit_modified/00084/00084.c new file mode 100644 index 00000000..b3553469 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00084/00084.c @@ -0,0 +1,62 @@ +#define ARGS(...) __VA_ARGS__ + +int +none() +{ + return 0; +} + +int +one(int a) +{ + if (a != 1) + return 1; + + return 0; +} + +int +two(int a, int b) +{ + if (a != 1) + return 1; + if (b != 2) + return 1; + + return 0; +} + +int +three(int a, int b, int c) +{ + if (a != 1) + return 1; + if (b != 2) + return 1; + if (c != 3) + return 1; + + return 0; +} + +int +test() +{ + if (none(ARGS())) + return 1; + if (one(ARGS(1))) + return 2; + if (two(ARGS(1, 2))) + return 3; + if (three(ARGS(1, 2, 3))) + return 4; + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00085/00085.c b/project/tests/in_progress/test_suit_modified/00085/00085.c new file mode 100644 index 00000000..04941e0d --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00085/00085.c @@ -0,0 +1,34 @@ +#define ZERO_0() 0 +#define ZERO_1(A) 0 +#define ZERO_2(A, B) 0 +#define ZERO_VAR(...) 0 +#define ZERO_1_VAR(A, ...) 0 + +int +test() +{ + if (ZERO_0()) + return 1; + if (ZERO_1(1)) + return 1; + if (ZERO_2(1, 2)) + return 1; + if (ZERO_VAR(1)) + return 1; + if (ZERO_VAR(1, 2)) + return 1; + if (ZERO_1_VAR(1, 2)) + return 1; + if (ZERO_1_VAR(1, 2, 3)) + return 1; + + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00086/00086.c b/project/tests/in_progress/test_suit_modified/00086/00086.c new file mode 100644 index 00000000..3e6dfd91 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00086/00086.c @@ -0,0 +1,19 @@ +int +test() +{ + short x; + + x = 0; + x = x + 1; + if (x != 1) + return 1; + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test028/testsuite_028.c b/project/tests/in_progress/test_suit_modified/00090/00090.c similarity index 68% rename from project/tests/in_progress/for_main/tests_suite/test028/testsuite_028.c rename to project/tests/in_progress/test_suit_modified/00090/00090.c index 0ccebded..f1142078 100644 --- a/project/tests/in_progress/for_main/tests_suite/test028/testsuite_028.c +++ b/project/tests/in_progress/test_suit_modified/00090/00090.c @@ -1,4 +1,3 @@ -#include int a[3] = {0, 1, 2}; int @@ -13,9 +12,11 @@ test() return 0; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00094/00094.c b/project/tests/in_progress/test_suit_modified/00094/00094.c new file mode 100644 index 00000000..29809597 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00094/00094.c @@ -0,0 +1,14 @@ +extern int x; + +int test() +{ + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00097/00097.c b/project/tests/in_progress/test_suit_modified/00097/00097.c new file mode 100644 index 00000000..6217f55a --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00097/00097.c @@ -0,0 +1,22 @@ +#define NULL ((void*)0) +#define NULL ((void*)0) + +#define FOO(X, Y) (X + Y + Z) +#define FOO(X, Y) (X + Y + Z) + +#define BAR(X, Y, ...) (X + Y + Z) +#define BAR(X, Y, ...) (X + Y + Z) + +int +test() +{ + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00098/00098.c b/project/tests/in_progress/test_suit_modified/00098/00098.c new file mode 100644 index 00000000..221e20c2 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00098/00098.c @@ -0,0 +1,13 @@ +int +test() +{ + return L'\0'; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test062/testsuite_062.c b/project/tests/in_progress/test_suit_modified/00099/00099.c similarity index 65% rename from project/tests/in_progress/for_main/tests_suite/test062/testsuite_062.c rename to project/tests/in_progress/test_suit_modified/00099/00099.c index a737815e..52f966c1 100644 --- a/project/tests/in_progress/for_main/tests_suite/test062/testsuite_062.c +++ b/project/tests/in_progress/test_suit_modified/00099/00099.c @@ -1,4 +1,3 @@ -#include typedef struct { int n; } Vec; @@ -12,9 +11,11 @@ int test() { return 0; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00100/00100.c b/project/tests/in_progress/test_suit_modified/00100/00100.c new file mode 100644 index 00000000..8a639170 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00100/00100.c @@ -0,0 +1,19 @@ +int +foo(void) +{ + return 0; +} + +int +test() +{ + return foo(); +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test006/testsuite_006.c b/project/tests/in_progress/test_suit_modified/00101/00101.c similarity index 68% rename from project/tests/in_progress/for_main/tests_suite/test006/testsuite_006.c rename to project/tests/in_progress/test_suit_modified/00101/00101.c index d83f3f7b..8896024e 100644 --- a/project/tests/in_progress/for_main/tests_suite/test006/testsuite_006.c +++ b/project/tests/in_progress/test_suit_modified/00101/00101.c @@ -1,4 +1,3 @@ -#include int test() { @@ -9,9 +8,11 @@ test() while (0); return c; } -int main () { - int x; - x = test(); + +#include +int main() +{ + int x = test(); printf("%d\n", x); - return 0; -} \ No newline at end of file + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00102/00102.c b/project/tests/in_progress/test_suit_modified/00102/00102.c new file mode 100644 index 00000000..7a572006 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00102/00102.c @@ -0,0 +1,19 @@ +int +test() +{ + int x; + + x = 1; + if ((x << 1) != 2) + return 1; + + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test213/testsuite_213.c b/project/tests/in_progress/test_suit_modified/00103/00103.c similarity index 65% rename from project/tests/in_progress/for_main/tests_suite/test213/testsuite_213.c rename to project/tests/in_progress/test_suit_modified/00103/00103.c index a47f9836..071bd0ac 100644 --- a/project/tests/in_progress/for_main/tests_suite/test213/testsuite_213.c +++ b/project/tests/in_progress/test_suit_modified/00103/00103.c @@ -1,4 +1,3 @@ -#include int test() { @@ -13,9 +12,11 @@ test() return **(int**)bar; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test215/testsuite_215.c b/project/tests/in_progress/test_suit_modified/00105/00105.c similarity index 59% rename from project/tests/in_progress/for_main/tests_suite/test215/testsuite_215.c rename to project/tests/in_progress/test_suit_modified/00105/00105.c index d320e660..82aedfa0 100644 --- a/project/tests/in_progress/for_main/tests_suite/test215/testsuite_215.c +++ b/project/tests/in_progress/test_suit_modified/00105/00105.c @@ -1,4 +1,3 @@ -#include int test() { @@ -10,9 +9,11 @@ test() return 0; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00106/00106.c b/project/tests/in_progress/test_suit_modified/00106/00106.c new file mode 100644 index 00000000..b6b144ae --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00106/00106.c @@ -0,0 +1,18 @@ +struct S1 { int x; }; +struct S2 { struct S1 s1; }; + +int +test() +{ + struct S2 s2; + s2.s1.x = 1; + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00107/00107.c b/project/tests/in_progress/test_suit_modified/00107/00107.c new file mode 100644 index 00000000..eece870e --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00107/00107.c @@ -0,0 +1,16 @@ +typedef int myint; +myint x = (myint)1; + +int +test(void) +{ + return x-1; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00108/00108.c b/project/tests/in_progress/test_suit_modified/00108/00108.c new file mode 100644 index 00000000..57a4f9bd --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00108/00108.c @@ -0,0 +1,17 @@ +int foo(void); +int foo(void); +#define FOO 0 + +int +test() +{ + return FOO; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00110/00110.c b/project/tests/in_progress/test_suit_modified/00110/00110.c new file mode 100644 index 00000000..0b346f2b --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00110/00110.c @@ -0,0 +1,16 @@ +extern int x; +int x; + +int +test() +{ + return x; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00111/00111.c b/project/tests/in_progress/test_suit_modified/00111/00111.c new file mode 100644 index 00000000..c58d486b --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00111/00111.c @@ -0,0 +1,17 @@ +int +test() +{ + short s = 1; + long l = 1; + + s -= l; + return s; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00112/00112.c b/project/tests/in_progress/test_suit_modified/00112/00112.c new file mode 100644 index 00000000..fae3a9e0 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00112/00112.c @@ -0,0 +1,13 @@ +int +test() +{ + return "abc" == (void *)0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00114/00114.c b/project/tests/in_progress/test_suit_modified/00114/00114.c new file mode 100644 index 00000000..05eb445f --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00114/00114.c @@ -0,0 +1,15 @@ +int main(void); + +int +test() +{ + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test082/testsuite_082.c b/project/tests/in_progress/test_suit_modified/00115/00115.c similarity index 74% rename from project/tests/in_progress/for_main/tests_suite/test082/testsuite_082.c rename to project/tests/in_progress/test_suit_modified/00115/00115.c index 8b214d01..16cc1cdb 100644 --- a/project/tests/in_progress/for_main/tests_suite/test082/testsuite_082.c +++ b/project/tests/in_progress/test_suit_modified/00115/00115.c @@ -1,4 +1,3 @@ -#include #define B "b" char s[] = "a" B "c"; @@ -16,9 +15,11 @@ test() return 4; return 0; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00116/00116.c b/project/tests/in_progress/test_suit_modified/00116/00116.c new file mode 100644 index 00000000..b4dbc0e2 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00116/00116.c @@ -0,0 +1,19 @@ +int +f(int f) +{ + return f; +} + +int +test() +{ + return f(0); +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00117/00117.c b/project/tests/in_progress/test_suit_modified/00117/00117.c new file mode 100644 index 00000000..d78ce765 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00117/00117.c @@ -0,0 +1,13 @@ +int test() +{ + int x[] = { 1, 0 }; + return x[1]; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test001/testsuite_001.c b/project/tests/in_progress/test_suit_modified/00118/00118.c similarity index 52% rename from project/tests/in_progress/for_main/tests_suite/test001/testsuite_001.c rename to project/tests/in_progress/test_suit_modified/00118/00118.c index 14bfdbed..7f783513 100644 --- a/project/tests/in_progress/for_main/tests_suite/test001/testsuite_001.c +++ b/project/tests/in_progress/test_suit_modified/00118/00118.c @@ -1,13 +1,14 @@ -#include int test() { struct { int x; } s = { 0 }; return s.x; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00119/00119.c b/project/tests/in_progress/test_suit_modified/00119/00119.c new file mode 100644 index 00000000..96287003 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00119/00119.c @@ -0,0 +1,15 @@ +double x = 100; + +int +test() +{ + return x < 1; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test061/testsuite_061.c b/project/tests/in_progress/test_suit_modified/00120/00120.c similarity index 51% rename from project/tests/in_progress/for_main/tests_suite/test061/testsuite_061.c rename to project/tests/in_progress/test_suit_modified/00120/00120.c index ef959196..92b81c3d 100644 --- a/project/tests/in_progress/for_main/tests_suite/test061/testsuite_061.c +++ b/project/tests/in_progress/test_suit_modified/00120/00120.c @@ -1,4 +1,3 @@ -#include struct { enum { X } x; } s; @@ -9,9 +8,11 @@ test() { return X; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00121/00121.c b/project/tests/in_progress/test_suit_modified/00121/00121.c new file mode 100644 index 00000000..83a8e223 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00121/00121.c @@ -0,0 +1,27 @@ +int f(int a), g(int a), a; + +int +test() +{ + return f(1) - g(1); +} + +int +f(int a) +{ + return a; +} + +int +g(int a) +{ + return a; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00122/00122.c b/project/tests/in_progress/test_suit_modified/00122/00122.c new file mode 100644 index 00000000..0aa25d98 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00122/00122.c @@ -0,0 +1,14 @@ +#define F(a, b) a +int +test() +{ + return F(, 1) 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00123/00123.c b/project/tests/in_progress/test_suit_modified/00123/00123.c new file mode 100644 index 00000000..65a35615 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00123/00123.c @@ -0,0 +1,15 @@ +double x = 100.0; + +int +test() +{ + return x < 1; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00125/00125.c b/project/tests/in_progress/test_suit_modified/00125/00125.c new file mode 100644 index 00000000..4f2f67b2 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00125/00125.c @@ -0,0 +1,16 @@ +#include + +int +test(void) +{ + printf("hello world\n"); + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00126/00126.c b/project/tests/in_progress/test_suit_modified/00126/00126.c new file mode 100644 index 00000000..208732b7 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00126/00126.c @@ -0,0 +1,22 @@ +int +test() +{ + int x; + + x = 3; + x = !x; + x = !x; + x = ~x; + x = -x; + if(x != 2) + return 1; + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00127/00127.c b/project/tests/in_progress/test_suit_modified/00127/00127.c new file mode 100644 index 00000000..22218f95 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00127/00127.c @@ -0,0 +1,28 @@ +int c; + +int +test() +{ + if(0) { + return 1; + } else if(0) { + } else { + if(1) { + if(c) + return 1; + else + return 0; + } else { + return 1; + } + } + return 1; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test003/testsuite_003.c b/project/tests/in_progress/test_suit_modified/00131/00131.c similarity index 71% rename from project/tests/in_progress/for_main/tests_suite/test003/testsuite_003.c rename to project/tests/in_progress/test_suit_modified/00131/00131.c index 96321b48..ca7b1987 100644 --- a/project/tests/in_progress/for_main/tests_suite/test003/testsuite_003.c +++ b/project/tests/in_progress/test_suit_modified/00131/00131.c @@ -1,6 +1,6 @@ #include -int test() +int test() { printf("Hello\n"); printf("Hello\n"); /* this is a comment */ printf("Hello\n"); @@ -12,9 +12,11 @@ int test() } // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test083/testsuite_083.c b/project/tests/in_progress/test_suit_modified/00133/00133.c similarity index 80% rename from project/tests/in_progress/for_main/tests_suite/test083/testsuite_083.c rename to project/tests/in_progress/test_suit_modified/00133/00133.c index 4396f7c7..4d92648b 100644 --- a/project/tests/in_progress/for_main/tests_suite/test083/testsuite_083.c +++ b/project/tests/in_progress/test_suit_modified/00133/00133.c @@ -1,4 +1,3 @@ -#include int test(void) { int i; @@ -23,9 +22,11 @@ int test(void) u = -1u < 0; return 0; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test145/testsuite_145.c b/project/tests/in_progress/test_suit_modified/00136/00136.c similarity index 83% rename from project/tests/in_progress/for_main/tests_suite/test145/testsuite_145.c rename to project/tests/in_progress/test_suit_modified/00136/00136.c index 1bf41f74..a824d889 100644 --- a/project/tests/in_progress/for_main/tests_suite/test145/testsuite_145.c +++ b/project/tests/in_progress/test_suit_modified/00136/00136.c @@ -1,4 +1,3 @@ -#include #define FOO #ifdef FOO @@ -51,9 +50,11 @@ test() int u; #error bad branch #endif -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + + #include + int main() + { + int x = test(); + printf("%d\n", x); + return x; + } diff --git a/project/tests/in_progress/test_suit_modified/00139/00139.c b/project/tests/in_progress/test_suit_modified/00139/00139.c new file mode 100644 index 00000000..ab3a1cdf --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00139/00139.c @@ -0,0 +1,23 @@ +/* + * f(2) will expand to 2*g, which will expand to 2*f, and in this + * moment f will not be expanded because the macro definition is + * a function alike macro, and in this case there is no arguments. + */ +#define f(a) a*g +#define g f + +int +test(void) +{ + int f = 0; + + return f(2); +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test216/testsuite_216.c b/project/tests/in_progress/test_suit_modified/00140/00140.c similarity index 79% rename from project/tests/in_progress/for_main/tests_suite/test216/testsuite_216.c rename to project/tests/in_progress/test_suit_modified/00140/00140.c index 94874d61..8ff8afc1 100644 --- a/project/tests/in_progress/for_main/tests_suite/test216/testsuite_216.c +++ b/project/tests/in_progress/test_suit_modified/00140/00140.c @@ -1,4 +1,3 @@ -#include struct foo { int i, j, k; char *p; @@ -24,9 +23,11 @@ test(void) return 0; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00141/00141.c b/project/tests/in_progress/test_suit_modified/00141/00141.c new file mode 100644 index 00000000..af7fa669 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00141/00141.c @@ -0,0 +1,22 @@ +#define CAT(x,y) x ## y +#define XCAT(x,y) CAT(x,y) +#define FOO foo +#define BAR bar + +int +test(void) +{ + int foo, bar, foobar; + + CAT(foo,bar) = foo + bar; + XCAT(FOO,BAR) = foo + bar; + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00142/00142.c b/project/tests/in_progress/test_suit_modified/00142/00142.c new file mode 100644 index 00000000..4ba4d3af --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00142/00142.c @@ -0,0 +1,23 @@ +#if defined(FOO) +int a; +#elif !defined(FOO) && defined(BAR) +int b; +#elif !defined(FOO) && !defined(BAR) +int c; +#else +int d; +#endif + +int +test(void) +{ + return c; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00145/00145.c b/project/tests/in_progress/test_suit_modified/00145/00145.c new file mode 100644 index 00000000..7a707aeb --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00145/00145.c @@ -0,0 +1,25 @@ +#if 0 != (0 && (0/0)) + #error 0 != (0 && (0/0)) +#endif + +#if 1 != (-1 || (0/0)) + #error 1 != (-1 || (0/0)) +#endif + +#if 3 != (-1 ? 3 : (0/0)) + #error 3 != (-1 ? 3 : (0/0)) +#endif + +int +test() +{ + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test034/testsuite_034.c b/project/tests/in_progress/test_suit_modified/00146/00146.c similarity index 67% rename from project/tests/in_progress/for_main/tests_suite/test034/testsuite_034.c rename to project/tests/in_progress/test_suit_modified/00146/00146.c index d2c5961e..a36091ae 100644 --- a/project/tests/in_progress/for_main/tests_suite/test034/testsuite_034.c +++ b/project/tests/in_progress/test_suit_modified/00146/00146.c @@ -1,4 +1,3 @@ -#include struct S { int a; int b; }; struct S s = {1, 2}; @@ -11,9 +10,11 @@ test() return 2; return 0; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test139/testsuite_139.c b/project/tests/in_progress/test_suit_modified/00147/00147.c similarity index 71% rename from project/tests/in_progress/for_main/tests_suite/test139/testsuite_139.c rename to project/tests/in_progress/test_suit_modified/00147/00147.c index a6131969..5f890301 100644 --- a/project/tests/in_progress/for_main/tests_suite/test139/testsuite_139.c +++ b/project/tests/in_progress/test_suit_modified/00147/00147.c @@ -1,4 +1,3 @@ -#include int arr[3] = {[2] = 2, [0] = 0, [1] = 1}; int @@ -12,9 +11,11 @@ test() return 3; return 0; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00152/00152.c b/project/tests/in_progress/test_suit_modified/00152/00152.c new file mode 100644 index 00000000..35f5fdf2 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00152/00152.c @@ -0,0 +1,21 @@ +#undef line +#define line 1000 + +#line line +#if 1000 != __LINE__ + #error " # line line" not work as expected +#endif + +int +test() +{ + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00153/00153.c b/project/tests/in_progress/test_suit_modified/00153/00153.c new file mode 100644 index 00000000..f97f9ecb --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00153/00153.c @@ -0,0 +1,21 @@ +#define x f +#define y() f + +typedef struct { int f; } S; + +int +test() +{ + S s; + + s.x = 0; + return s.y(); +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test169/testsuite_169.c b/project/tests/in_progress/test_suit_modified/00156/00156.c similarity index 64% rename from project/tests/in_progress/for_main/tests_suite/test169/testsuite_169.c rename to project/tests/in_progress/test_suit_modified/00156/00156.c index 4bccf01a..cdb77bb3 100644 --- a/project/tests/in_progress/for_main/tests_suite/test169/testsuite_169.c +++ b/project/tests/in_progress/test_suit_modified/00156/00156.c @@ -1,6 +1,6 @@ #include -int test() +int test() { int Count; @@ -13,9 +13,11 @@ int test() } // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test177/testsuite_177.c b/project/tests/in_progress/test_suit_modified/00157/00157.c similarity index 74% rename from project/tests/in_progress/for_main/tests_suite/test177/testsuite_177.c rename to project/tests/in_progress/test_suit_modified/00157/00157.c index e0e97ca1..d9511c74 100644 --- a/project/tests/in_progress/for_main/tests_suite/test177/testsuite_177.c +++ b/project/tests/in_progress/test_suit_modified/00157/00157.c @@ -1,6 +1,6 @@ #include -int test() +int test() { int Count; int Array[10]; @@ -19,9 +19,11 @@ int test() } // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test214/testsuite_214.c b/project/tests/in_progress/test_suit_modified/00158/00158.c similarity index 82% rename from project/tests/in_progress/for_main/tests_suite/test214/testsuite_214.c rename to project/tests/in_progress/test_suit_modified/00158/00158.c index 69feac6b..151f65bb 100644 --- a/project/tests/in_progress/for_main/tests_suite/test214/testsuite_214.c +++ b/project/tests/in_progress/test_suit_modified/00158/00158.c @@ -27,9 +27,11 @@ int test() } // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test059/testsuite_059.c b/project/tests/in_progress/test_suit_modified/00160/00160.c similarity index 74% rename from project/tests/in_progress/for_main/tests_suite/test059/testsuite_059.c rename to project/tests/in_progress/test_suit_modified/00160/00160.c index df08aed0..41af1008 100644 --- a/project/tests/in_progress/for_main/tests_suite/test059/testsuite_059.c +++ b/project/tests/in_progress/test_suit_modified/00160/00160.c @@ -22,9 +22,11 @@ int test() } // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test049/testsuite_049.c b/project/tests/in_progress/test_suit_modified/00161/00161.c similarity index 74% rename from project/tests/in_progress/for_main/tests_suite/test049/testsuite_049.c rename to project/tests/in_progress/test_suit_modified/00161/00161.c index 6e71f147..53a78606 100644 --- a/project/tests/in_progress/for_main/tests_suite/test049/testsuite_049.c +++ b/project/tests/in_progress/test_suit_modified/00161/00161.c @@ -21,10 +21,12 @@ int test() return 0; } +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} + // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/test_suit_modified/00162/00162.c b/project/tests/in_progress/test_suit_modified/00162/00162.c new file mode 100644 index 00000000..1231cfff --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00162/00162.c @@ -0,0 +1,42 @@ +void foo(int [5]); +void fooc(int x[const 5]); +void foos(int x[static 5]); +void foov(int x[volatile 5]); +void foor(int x[restrict 5]); +void fooc(int [const 5]); +void foos(int [static 5]); +void foov(int [volatile 5]); +void foor(int [restrict 5]); +void fooc(int (* const x)); +void foos(int *x); +void foov(int * volatile x); +void foor(int * restrict x); +void fooc(int x[volatile 5]) +{ + x[3] = 42; +#ifdef INVALID + x = 0; +#endif +} +void foovm(int x[const *]); +void foovm(int * const x); +#ifdef INVALID +void wrongc(int x[3][const 4]); +void wrongvm(int x[static *]); +void foovm(int x[const *]) +{ + x[2] = 1; +} +#endif +int test() +{ + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test018/testsuite_018.c b/project/tests/in_progress/test_suit_modified/00164/00164.c similarity index 89% rename from project/tests/in_progress/for_main/tests_suite/test018/testsuite_018.c rename to project/tests/in_progress/test_suit_modified/00164/00164.c index a210f3fe..59372170 100644 --- a/project/tests/in_progress/for_main/tests_suite/test018/testsuite_018.c +++ b/project/tests/in_progress/test_suit_modified/00164/00164.c @@ -38,9 +38,11 @@ int test() } // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test189/testsuite_189.c b/project/tests/in_progress/test_suit_modified/00165/00165.c similarity index 71% rename from project/tests/in_progress/for_main/tests_suite/test189/testsuite_189.c rename to project/tests/in_progress/test_suit_modified/00165/00165.c index 03875ba6..e3b46721 100644 --- a/project/tests/in_progress/for_main/tests_suite/test189/testsuite_189.c +++ b/project/tests/in_progress/test_suit_modified/00165/00165.c @@ -12,9 +12,11 @@ int test() } // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test105/testsuite_105.c b/project/tests/in_progress/test_suit_modified/00166/00166.c similarity index 74% rename from project/tests/in_progress/for_main/tests_suite/test105/testsuite_105.c rename to project/tests/in_progress/test_suit_modified/00166/00166.c index c02ed903..651fddee 100644 --- a/project/tests/in_progress/for_main/tests_suite/test105/testsuite_105.c +++ b/project/tests/in_progress/test_suit_modified/00166/00166.c @@ -16,9 +16,11 @@ int test() } // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test101/testsuite_101.c b/project/tests/in_progress/test_suit_modified/00167/00167.c similarity index 75% rename from project/tests/in_progress/for_main/tests_suite/test101/testsuite_101.c rename to project/tests/in_progress/test_suit_modified/00167/00167.c index 5901e7b7..7457b52d 100644 --- a/project/tests/in_progress/for_main/tests_suite/test101/testsuite_101.c +++ b/project/tests/in_progress/test_suit_modified/00167/00167.c @@ -19,9 +19,11 @@ int test() } // vim: set expandtab ts=4 sw=3 sts=3 tw=80 : -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test147/testsuite_147.c b/project/tests/in_progress/test_suit_modified/00168/00168.c similarity index 76% rename from project/tests/in_progress/for_main/tests_suite/test147/testsuite_147.c rename to project/tests/in_progress/test_suit_modified/00168/00168.c index f769a635..697c60c7 100644 --- a/project/tests/in_progress/for_main/tests_suite/test147/testsuite_147.c +++ b/project/tests/in_progress/test_suit_modified/00168/00168.c @@ -19,9 +19,11 @@ int test() } /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test202/testsuite_202.c b/project/tests/in_progress/test_suit_modified/00169/00169.c similarity index 76% rename from project/tests/in_progress/for_main/tests_suite/test202/testsuite_202.c rename to project/tests/in_progress/test_suit_modified/00169/00169.c index b4264190..09b666d6 100644 --- a/project/tests/in_progress/for_main/tests_suite/test202/testsuite_202.c +++ b/project/tests/in_progress/test_suit_modified/00169/00169.c @@ -19,9 +19,11 @@ int test() } /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test187/testsuite_187.c b/project/tests/in_progress/test_suit_modified/00171/00171.c similarity index 77% rename from project/tests/in_progress/for_main/tests_suite/test187/testsuite_187.c rename to project/tests/in_progress/test_suit_modified/00171/00171.c index dde8fae1..e50a9723 100644 --- a/project/tests/in_progress/for_main/tests_suite/test187/testsuite_187.c +++ b/project/tests/in_progress/test_suit_modified/00171/00171.c @@ -1,5 +1,7 @@ #include +#define NULL 0 + int test() { int a; @@ -26,9 +28,11 @@ int test() } /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test086/testsuite_086.c b/project/tests/in_progress/test_suit_modified/00172/00172.c similarity index 79% rename from project/tests/in_progress/for_main/tests_suite/test086/testsuite_086.c rename to project/tests/in_progress/test_suit_modified/00172/00172.c index 6021d902..56307b47 100644 --- a/project/tests/in_progress/for_main/tests_suite/test086/testsuite_086.c +++ b/project/tests/in_progress/test_suit_modified/00172/00172.c @@ -22,9 +22,11 @@ int test() } /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test068/testsuite_068.c b/project/tests/in_progress/test_suit_modified/00176qsort/00176.c similarity index 76% rename from project/tests/in_progress/for_main/tests_suite/test068/testsuite_068.c rename to project/tests/in_progress/test_suit_modified/00176qsort/00176.c index 9c6bb3ab..1dbfb539 100644 --- a/project/tests/in_progress/for_main/tests_suite/test068/testsuite_068.c +++ b/project/tests/in_progress/test_suit_modified/00176qsort/00176.c @@ -47,6 +47,7 @@ void quicksort(int left, int right) int test() { int i; + int tmp; array[0] = 62; array[1] = 83; @@ -65,25 +66,34 @@ int test() array[14] = 74; array[15] = 55; - for (i = 0; i < 16; i++) - printf("%d ", array[i]); + for (i = 0; i < 16; i++) { + tmp = array[i]; + printf("%d\n", tmp); + } - printf("\n"); +// printf("\n"); quicksort(0, 15); - for (i = 0; i < 16; i++) - printf("%d ", array[i]); +// for (i = 0; i < 16; i++) +// printf("%d ", array[i]); + + for (i = 0; i < 16; i++) { + tmp = array[i]; + printf("%d\n", tmp); + } - printf("\n"); +// printf("%d\n"); return 0; } /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test109/testsuite_109.c b/project/tests/in_progress/test_suit_modified/00177c/00177.c similarity index 70% rename from project/tests/in_progress/for_main/tests_suite/test109/testsuite_109.c rename to project/tests/in_progress/test_suit_modified/00177c/00177.c index 1e90293b..78784429 100644 --- a/project/tests/in_progress/for_main/tests_suite/test109/testsuite_109.c +++ b/project/tests/in_progress/test_suit_modified/00177c/00177.c @@ -9,15 +9,17 @@ int test() printf("%d\n", '\x0e'); printf("%d\n", '\x10'); printf("%d\n", '\x40'); - printf("test \x40\n"); +// printf("test \x40\n"); return 0; } /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00177s/00177.c b/project/tests/in_progress/test_suit_modified/00177s/00177.c new file mode 100644 index 00000000..81d84f2d --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00177s/00177.c @@ -0,0 +1,26 @@ +#include + +int test() +{ +// printf("%d\n", '\1'); +// printf("%d\n", '\10'); +// printf("%d\n", '\100'); +// printf("%d\n", '\x01'); +// printf("%d\n", '\x0e'); +// printf("%d\n", '\x10'); +// printf("%d\n", '\x40'); + + printf("%s\n", "test \x40\n"); + + return 0; +} + +/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/main/array/00185i.c b/project/tests/in_progress/test_suit_modified/00185i/00185.c similarity index 100% rename from project/tests/main/array/00185i.c rename to project/tests/in_progress/test_suit_modified/00185i/00185.c diff --git a/project/tests/main/array/00185l.c b/project/tests/in_progress/test_suit_modified/00185l/00185.c similarity index 100% rename from project/tests/main/array/00185l.c rename to project/tests/in_progress/test_suit_modified/00185l/00185.c diff --git a/project/tests/in_progress/for_main/tests_suite/test043/testsuite_043.c b/project/tests/in_progress/test_suit_modified/00188/00188.c similarity index 87% rename from project/tests/in_progress/for_main/tests_suite/test043/testsuite_043.c rename to project/tests/in_progress/test_suit_modified/00188/00188.c index f0a187b0..58ef0ac6 100644 --- a/project/tests/in_progress/for_main/tests_suite/test043/testsuite_043.c +++ b/project/tests/in_progress/test_suit_modified/00188/00188.c @@ -1,8 +1,8 @@ #include -int test() +int main() { - printf("#include test\n"); + printf("include test\n"); #if 1 #if 0 @@ -83,9 +83,3 @@ int test() } /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test096/testsuite_096.c b/project/tests/in_progress/test_suit_modified/00190/00190.c similarity index 54% rename from project/tests/in_progress/for_main/tests_suite/test096/testsuite_096.c rename to project/tests/in_progress/test_suit_modified/00190/00190.c index de677ea1..48339657 100644 --- a/project/tests/in_progress/for_main/tests_suite/test096/testsuite_096.c +++ b/project/tests/in_progress/test_suit_modified/00190/00190.c @@ -2,10 +2,11 @@ void fred(void) { - printf("yo\n"); + int x = 1000; + printf("%d\n", x); } -int test() +int main() { fred(); @@ -13,9 +14,3 @@ int test() } /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/test_suit_modified/00191/00191.c b/project/tests/in_progress/test_suit_modified/00191/00191.c new file mode 100644 index 00000000..f63705a5 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00191/00191.c @@ -0,0 +1,27 @@ +#include + +int test() +{ + int a; + + for (a = 0; a < 2; a++) + { + int b = a; + printf("%d\n", a); + printf("%d\n", b); + } + +// printf("it's all good\n"); + + return 0; +} + +/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test217/testsuite_217.c b/project/tests/in_progress/test_suit_modified/00192/00192.c similarity index 71% rename from project/tests/in_progress/for_main/tests_suite/test217/testsuite_217.c rename to project/tests/in_progress/test_suit_modified/00192/00192.c index caaf0cc0..1a563d26 100644 --- a/project/tests/in_progress/for_main/tests_suite/test217/testsuite_217.c +++ b/project/tests/in_progress/test_suit_modified/00192/00192.c @@ -16,9 +16,11 @@ int test() } /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00193/00193.c b/project/tests/in_progress/test_suit_modified/00193/00193.c new file mode 100644 index 00000000..1e06b449 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00193/00193.c @@ -0,0 +1,31 @@ +#include + +void fred(int x) +{ + switch (x) + { + case 1: printf("%d\n", x); return; + case 2: printf("%d\n", x); break; + case 3: printf("%d\n", x); return; + } + +} + +int test() +{ + fred(1); + fred(2); + fred(3); + + return 0; +} + +/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00194/00194.c b/project/tests/in_progress/test_suit_modified/00194/00194.c new file mode 100644 index 00000000..a328b90b --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00194/00194.c @@ -0,0 +1,36 @@ +#include + +int test() +{ + int a; + char b; + + a = 0; + while (a < 2) + { + a++; + printf("%d\n", a); +// printf("%d\n", a++); + break; + + b = 'A'; + while (b < 'C') + { + printf("%c\n", b++); + } +// printf("e"); + } + printf("%d\n", a); + + return 0; +} + +/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test073/testsuite_073.c b/project/tests/in_progress/test_suit_modified/00195/00195.c similarity index 60% rename from project/tests/in_progress/for_main/tests_suite/test073/testsuite_073.c rename to project/tests/in_progress/test_suit_modified/00195/00195.c index 39644ab9..6be3e157 100644 --- a/project/tests/in_progress/for_main/tests_suite/test073/testsuite_073.c +++ b/project/tests/in_progress/test_suit_modified/00195/00195.c @@ -15,15 +15,18 @@ int test() point_array[my_point].x = 12.34; point_array[my_point].y = 56.78; - printf("%f, %f\n", point_array[my_point].x, point_array[my_point].y); + printf("%f\n", point_array[my_point].x); + printf("%f\n", point_array[my_point].y); return 0; } /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00196/00196.c b/project/tests/in_progress/test_suit_modified/00196/00196.c new file mode 100644 index 00000000..f3c22f5a --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00196/00196.c @@ -0,0 +1,46 @@ +#include + +int fred() +{ +// printf("fred\n"); + return 0; +} + +int joe() +{ +// printf("joe\n"); + return 1; +} + +int test() +{ + int x; + x = fred() && joe(); + printf("%d\n", x); + x = fred() || joe(); + printf("%d\n", x); + x = joe() && fred(); + printf("%d\n", x); + x = joe() || fred(); + printf("%d\n", x); + x = fred() && (1 + joe()); + printf("%d\n", x); + x = fred() || (0 + joe()); + printf("%d\n", x); + x = joe() && (0 + fred()); + printf("%d\n", x); + x = joe() || (1 + fred()); + printf("%d\n", x); + + return 0; +} + +/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test206/testsuite_206.c b/project/tests/in_progress/test_suit_modified/00198/00198.c similarity index 83% rename from project/tests/in_progress/for_main/tests_suite/test206/testsuite_206.c rename to project/tests/in_progress/test_suit_modified/00198/00198.c index 17b21159..d0395b20 100644 --- a/project/tests/in_progress/for_main/tests_suite/test206/testsuite_206.c +++ b/project/tests/in_progress/test_suit_modified/00198/00198.c @@ -2,7 +2,7 @@ enum fred { a, b, c }; -int test() +int main() { printf("a=%d\n", a); printf("b=%d\n", b); @@ -25,9 +25,3 @@ int test() } /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/test_suit_modified/00198/00198a.c b/project/tests/in_progress/test_suit_modified/00198/00198a.c new file mode 100644 index 00000000..1f2387df --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00198/00198a.c @@ -0,0 +1,16 @@ +#include + +typedef enum fred { a, b, c } x; + +int main() +{ + printf("a=%d\n", a); + printf("b=%d\n", b); + printf("c=%d\n", c); + + enum fred d; + + return 0; +} + +/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/project/tests/in_progress/test_suit_modified/00198/00198b.c b/project/tests/in_progress/test_suit_modified/00198/00198b.c new file mode 100644 index 00000000..e40d3930 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00198/00198b.c @@ -0,0 +1,14 @@ +#include + +int main() +{ + enum { e, f, g } h; + + printf("e=%d\n", e); + printf("f=%d\n", f); + printf("g=%d\n", g); + + return 0; +} + +/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/project/tests/in_progress/test_suit_modified/00198/00198c.c b/project/tests/in_progress/test_suit_modified/00198/00198c.c new file mode 100644 index 00000000..033dc0f6 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00198/00198c.c @@ -0,0 +1,14 @@ +#include + +int main() +{ + typedef enum { e, f, g } h; + + printf("e=%d\n", e); + printf("f=%d\n", f); + printf("g=%d\n", g); + + return 0; +} + +/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/project/tests/in_progress/test_suit_modified/00198/00198d.c b/project/tests/in_progress/test_suit_modified/00198/00198d.c new file mode 100644 index 00000000..f91d1c08 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00198/00198d.c @@ -0,0 +1,16 @@ +#include + +enum fred { a, b, c }; + +int main() +{ + printf("a=%d\n", a); + printf("b=%d\n", b); + printf("c=%d\n", c); + + enum fred d; + + return 0; +} + +/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/ diff --git a/project/tests/in_progress/for_main/tests_suite/test035/testsuite_035.c b/project/tests/in_progress/test_suit_modified/00201/00201.c similarity index 53% rename from project/tests/in_progress/for_main/tests_suite/test035/testsuite_035.c rename to project/tests/in_progress/test_suit_modified/00201/00201.c index 51e45322..8adc6ff3 100644 --- a/project/tests/in_progress/for_main/tests_suite/test035/testsuite_035.c +++ b/project/tests/in_progress/test_suit_modified/00201/00201.c @@ -4,15 +4,11 @@ #define CAT(a,b) CAT2(a,b) #define AB(x) CAT(x,y) -int test(void) +int main(void) { int xy = 42; - printf("%d\n", CAT(A,B)(x)); + int t; + t = CAT(A,B)(x); + printf("%d\n", t); return 0; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/test_suit_modified/00202/00202.c b/project/tests/in_progress/test_suit_modified/00202/00202.c new file mode 100644 index 00000000..a4df622f --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00202/00202.c @@ -0,0 +1,25 @@ +#include + +#define P(A,B) A ## B ; bob +#define Q(A,B) A ## B+ + +int test(void) +{ + int bob, jim = 21; + bob = P(jim,) *= 2; +// printf("jim: %d, bob: %d\n", jim, bob); + printf("%d\n", jim); + printf("%d\n", bob); + jim = 60 Q(+,)3; +// printf("jim: %d\n", jim); + printf("%d\n", jim); + return 0; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00203/00203.c b/project/tests/in_progress/test_suit_modified/00203/00203.c new file mode 100644 index 00000000..6c9e80ac --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00203/00203.c @@ -0,0 +1,33 @@ +#include + +int test() +{ + long long int res = 3LL; + + if (res < -2147483648LL) { +// printf("Error: 0 < -2147483648\n"); + res = 1LL; + printf("%lld\n", res); + return 1; + } + else + if (2147483647LL < 2) { +// printf("Error: 2147483647 < 0\n"); + res = 2LL; + printf("%lld\n", res); + return 2; + } + else +// printf("long long constant test ok.\n"); + printf("%lld\n", res); + + return 3; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/test_suit_modified/00203stmt/00203.c b/project/tests/in_progress/test_suit_modified/00203stmt/00203.c new file mode 100644 index 00000000..1144f6c1 --- /dev/null +++ b/project/tests/in_progress/test_suit_modified/00203stmt/00203.c @@ -0,0 +1,33 @@ +#include + +int test() +{ + long long int res = 3LL; + + if (res < -2147483648LL) { +// printf("Error: 0 < -2147483648\n"); + res = 1LL; + printf("%lld\n", res); + return 1; + } + else + if (2147483647LL < 2) { +// printf("Error: 2147483647 < 0\n"); + res = 2LL; + printf("%lld\n", res); + return 2; + } + else { +// printf("long long constant test ok.\n"); + printf("%lld\n", res); + } + return 3; +} + +#include +int main() +{ + int x = test(); + printf("%d\n", x); + return x; +} diff --git a/project/tests/in_progress/for_main/tests_suite/test015/testsuite_015.c b/project/tests/in_progress/test_suit_modified/00206/00206.c similarity index 63% rename from project/tests/in_progress/for_main/tests_suite/test015/testsuite_015.c rename to project/tests/in_progress/test_suit_modified/00206/00206.c index 975b7d87..e8fc89a1 100644 --- a/project/tests/in_progress/for_main/tests_suite/test015/testsuite_015.c +++ b/project/tests/in_progress/test_suit_modified/00206/00206.c @@ -1,6 +1,6 @@ #include -int test() +int main() { /* must not affect how #pragma ppop_macro works */ #define pop_macro foobar1 @@ -10,27 +10,21 @@ int test() #undef abort #define abort "111" - printf("abort = %s\n", abort); + printf("%s\n", abort); #pragma push_macro("abort") #undef abort #define abort "222" - printf("abort = %s\n", abort); + printf("%s\n", abort); #pragma push_macro("abort") #undef abort #define abort "333" - printf("abort = %s\n", abort); + printf("%s\n", abort); #pragma pop_macro("abort") - printf("abort = %s\n", abort); + printf("%s\n", abort); #pragma pop_macro("abort") - printf("abort = %s\n", abort); + printf("%s\n", abort); } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/tests_suite/test144/testsuite_144.c b/project/tests/in_progress/test_suit_modified/00211/00211.c similarity index 61% rename from project/tests/in_progress/for_main/tests_suite/test144/testsuite_144.c rename to project/tests/in_progress/test_suit_modified/00211/00211.c index 1f6d7545..2e1fdd1c 100644 --- a/project/tests/in_progress/for_main/tests_suite/test144/testsuite_144.c +++ b/project/tests/in_progress/test_suit_modified/00211/00211.c @@ -1,4 +1,3 @@ -#include extern int printf(const char *format, ...); #define ACPI_TYPE_INVALID 0x1E @@ -6,14 +5,10 @@ extern int printf(const char *format, ...); int array[NUM_NS_TYPES]; #define n 0xe -int test() +int main() { - printf("n+1 = %d\n", n+1); + int x; + x = n+1; + printf("%d\n", x); // printf("n+1 = %d\n", 0xe+1); } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/in_progress/for_main/bad/operations/sizeof/00212/00212.c b/project/tests/in_progress/test_suit_modified/00212/00212.c similarity index 100% rename from project/tests/in_progress/for_main/bad/operations/sizeof/00212/00212.c rename to project/tests/in_progress/test_suit_modified/00212/00212.c diff --git a/project/tests/in_progress/for_main/tests_suite/test219/testsuite_219.c b/project/tests/in_progress/test_suit_modified/00218/00218.c similarity index 93% rename from project/tests/in_progress/for_main/tests_suite/test219/testsuite_219.c rename to project/tests/in_progress/test_suit_modified/00218/00218.c index 10543f03..bb6dc35d 100644 --- a/project/tests/in_progress/for_main/tests_suite/test219/testsuite_219.c +++ b/project/tests/in_progress/test_suit_modified/00218/00218.c @@ -1,4 +1,3 @@ -#include /* This checks if enums needing 8 bit but only having positive values are correctly zero extended (instead of sign extended) when stored into/loaded from a 8 bit bit-field of enum type (which @@ -48,7 +47,7 @@ int convert_like_real (tree convs) printf("unsigned enum bit-fields broken\n"); } -int test() +int main() { union tree_node convs; @@ -56,9 +55,3 @@ int test() convert_like_real (&convs); return 0; } -int main () { - int x; - x = test(); - printf("%d\n", x); - return 0; -} \ No newline at end of file diff --git a/project/tests/main/array/array_and_struct/array_in_struct/array_in_struct_01.c b/project/tests/main/array/array_and_struct/array_in_struct/array_in_struct_01.c new file mode 100644 index 00000000..14aa1787 --- /dev/null +++ b/project/tests/main/array/array_and_struct/array_in_struct/array_in_struct_01.c @@ -0,0 +1,17 @@ +//clang -Xclang -ast-dump -fsyntax-only array_in_struct_01.c +//clang -O0 -Wall -masm=intel -S -fno-asynchronous-unwind-tables -fcf-protection=none array_in_struct_01.c +//clang -emit-llvm -S -o array_in_struct_01.ll array_in_struct_01.c + +// #include + +struct Triangle { int side[3];} trian; + +int main() { + trian.side[0] = 3; + trian.side[1] = 4; + trian.side[2] = 5; + printf("trian: perimeter = %d\n", + trian.side[0]+trian.side[1]+trian.side[2]); + + return 0; +} diff --git a/project/tests/main/array/array_and_struct/array_of_struct/array_of_struct_01.c b/project/tests/main/array/array_and_struct/array_of_struct/array_of_struct_01.c new file mode 100644 index 00000000..27896d52 --- /dev/null +++ b/project/tests/main/array/array_and_struct/array_of_struct/array_of_struct_01.c @@ -0,0 +1,21 @@ +//clang -Xclang -ast-dump -fsyntax-only array_of_struct_01.c +//clang -O0 -Wall -masm=intel -S -fno-asynchronous-unwind-tables -fcf-protection=none array_of_struct_01.c +//clang -emit-llvm -S -o array_of_struct_01.ll array_of_struct_01.c + +// #include + +struct Triangle { int a, b, c;} trian_array[5]; +int i; + +int main() { + trian_array[i].a = 33; + int count = 0; + for(i = 0; i < 5; ++i) { + trian_array[i].a = 3 + i; + trian_array[i].b = 4 + i; + trian_array[i].c = 5 + i; + printf("trian %d: perimeter = %d\n", ++count, + trian_array[i].a+trian_array[i].b+trian_array[i].c); + } + return 0; // trian_array[i].a; +} diff --git a/project/tests/main/array/array_and_struct/array_of_struct/array_of_struct_02.c b/project/tests/main/array/array_and_struct/array_of_struct/array_of_struct_02.c new file mode 100644 index 00000000..9425ddfd --- /dev/null +++ b/project/tests/main/array/array_and_struct/array_of_struct/array_of_struct_02.c @@ -0,0 +1,21 @@ +//clang -Xclang -ast-dump -fsyntax-only array_of_struct_02.c +//clang -O0 -Wall -masm=intel -S -fno-asynchronous-unwind-tables -fcf-protection=none array_of_struct_02.c +//clang -emit-llvm -S -o array_of_struct_02.ll array_of_struct_02.c + +#include + +struct Triangle { int a, b, c;} trian_array[5][3]; +int i, j; +int main() { + int count = 0; + for(i = 0; i < 5; ++i) { + for(j = 0; j < 3; ++j) { + trian_array[i][j].a = 3 + i + j; + trian_array[i][j].b = 4 + i + j; + trian_array[i][j].c = 5 + i + j; + printf("trian %d: perimeter = %d\n", ++count, + trian_array[i][j].a+trian_array[i][j].b+trian_array[i][j].c); + } + } + return 0; +} diff --git a/project/tests/main/array/array_and_struct/array_of_struct/array_of_struct_03.c b/project/tests/main/array/array_and_struct/array_of_struct/array_of_struct_03.c new file mode 100644 index 00000000..cea74f2b --- /dev/null +++ b/project/tests/main/array/array_and_struct/array_of_struct/array_of_struct_03.c @@ -0,0 +1,23 @@ +//clang -Xclang -ast-dump -fsyntax-only array_of_struct_03.c +//clang -O0 -Wall -masm=intel -S -fno-asynchronous-unwind-tables -fcf-protection=none array_of_struct_03.c +//clang -emit-llvm -S -o array_of_struct_03.ll array_of_struct_03.c + +#include + +struct Triangle { int a, b, c;} trian_array[5][3][2]; +int i, j, k; +int main() { + int count = 0; + for(i = 0; i < 5; ++i) { + for(j = 0; j < 3; ++j) { + for(k = 0; k < 2; ++k) { + trian_array[i][j][k].a = 3 + i + j + k; + trian_array[i][j][k].b = 4 + i + j + k; + trian_array[i][j][k].c = 5 + i + j + k; + printf("trian %d: perimeter = %d\n", ++count, + trian_array[i][j][k].a+trian_array[i][j][k].b+trian_array[i][j][k].c); + } + } + } + return 0; +} diff --git a/project/tests/main/array/array_and_struct/array_of_struct_in_array/array_of_struct_in_array_01.c b/project/tests/main/array/array_and_struct/array_of_struct_in_array/array_of_struct_in_array_01.c new file mode 100644 index 00000000..badb1ef2 --- /dev/null +++ b/project/tests/main/array/array_and_struct/array_of_struct_in_array/array_of_struct_in_array_01.c @@ -0,0 +1,22 @@ +//clang -Xclang -ast-dump -fsyntax-only array_of_struct_01.c +//clang -O0 -Wall -masm=intel -S -fno-asynchronous-unwind-tables -fcf-protection=none array_of_struct_01.c +//clang -emit-llvm -S -o array_of_struct_01.ll array_of_struct_01.c + +#include + +struct Triangle { int side[3];} trian_array[5]; +int i; + +int main() { + int count = 0; + for(i = 0; i < 5; ++i) { + trian_array[i].side[0] = 3 + i; + trian_array[i].side[1] = 4 + i; + trian_array[i].side[2] = 5 + i; + printf("trian %d: perimeter = %d\n", ++count, + trian_array[i].side[0] + + trian_array[i].side[1] + + trian_array[i].side[2] ); + } + return 0; // trian_array[i].a; +} diff --git a/project/tests/main/array/array_and_struct/array_of_struct_in_array/array_of_struct_in_array_02.c b/project/tests/main/array/array_and_struct/array_of_struct_in_array/array_of_struct_in_array_02.c new file mode 100644 index 00000000..58bbfc56 --- /dev/null +++ b/project/tests/main/array/array_and_struct/array_of_struct_in_array/array_of_struct_in_array_02.c @@ -0,0 +1,23 @@ +//clang -Xclang -ast-dump -fsyntax-only array_of_struct_02.c +//clang -O0 -Wall -masm=intel -S -fno-asynchronous-unwind-tables -fcf-protection=none array_of_struct_02.c +//clang -emit-llvm -S -o array_of_struct_02.ll array_of_struct_02.c + +#include + +struct Triangle { int side[3];} trian_array[5][3]; +int i, j; +int main() { + int count = 0; + for(i = 0; i < 5; ++i) { + for(j = 0; j < 3; ++j) { + trian_array[i][j].side[0] = 3 + i + j; + trian_array[i][j].side[1] = 4 + i + j; + trian_array[i][j].side[2] = 5 + i + j; + printf("trian %d: perimeter = %d\n", ++count, + trian_array[i][j].side[0] + +trian_array[i][j].side[1] + +trian_array[i][j].side[2]); + } + } + return 0; +} diff --git a/project/tests/main/array/array_and_struct/array_of_struct_in_array/array_of_struct_in_array_03.c b/project/tests/main/array/array_and_struct/array_of_struct_in_array/array_of_struct_in_array_03.c new file mode 100644 index 00000000..57c6af55 --- /dev/null +++ b/project/tests/main/array/array_and_struct/array_of_struct_in_array/array_of_struct_in_array_03.c @@ -0,0 +1,25 @@ +//clang -Xclang -ast-dump -fsyntax-only array_of_struct_03.c +//clang -O0 -Wall -masm=intel -S -fno-asynchronous-unwind-tables -fcf-protection=none array_of_struct_03.c +//clang -emit-llvm -S -o array_of_struct_03.ll array_of_struct_03.c + +#include + +struct Triangle { int side[3];} trian_array[5][3][2]; +int i, j, k; +int main() { + int count = 0; + for(i = 0; i < 5; ++i) { + for(j = 0; j < 3; ++j) { + for(k = 0; k < 2; ++k) { + trian_array[i][j][k].side[0] = 3 + i + j + k; + trian_array[i][j][k].side[1] = 4 + i + j + k; + trian_array[i][j][k].side[2] = 5 + i + j + k; + printf("trian %d: perimeter = %d\n", ++count, + trian_array[i][j][k].side[0] + + trian_array[i][j][k].side[1] + + trian_array[i][j][k].side[2]); + } + } + } + return 0; +} diff --git a/project/tests/main/array/long_long/global/long_long_global_array_13.c b/project/tests/main/array/long_long/global/long_long_global_array_13.c index b72d7a6f..984751c9 100644 --- a/project/tests/main/array/long_long/global/long_long_global_array_13.c +++ b/project/tests/main/array/long_long/global/long_long_global_array_13.c @@ -17,4 +17,4 @@ int main() { printf("%d\n", 2[2[obj[2].b].c]); printf("%d\n", 2[2[2[obj].b].c]); return 0; -} \ No newline at end of file +} diff --git a/project/tests/main/char/char03.c b/project/tests/main/char/char03.c index ce7109f1..e930fbdd 100644 --- a/project/tests/main/char/char03.c +++ b/project/tests/main/char/char03.c @@ -1,9 +1,25 @@ +//clang -Xclang -ast-dump -fsyntax-only char03.c +//clang -O0 -Wall -masm=intel -S -fno-asynchronous-unwind-tables -fcf-protection=none char03.c +//clang -emit-llvm -S -o char03.ll char03.c + #include "stdio.h" char c = 'h'; int a = 5; char str[] = "hell"; int main() { -// printf("a = %d;\nc = %d;\na = %c;\nc = %lc;\nstr = %s;\nstr[2] = %c;\n", a, c, a, c, str, str[2]); - printf("a = %d;\nc = %d;\na = %d;\nc = %ld;\nstr = %s;\nstr[2] = %d;\n", a, c, a, c, str, str[2]); + printf("a = %d;\n", a); + printf("c = %d;\n", c); +// printf("a = %c;\n", a); +// printf("c = %c;\n", c); + printf("str = %s;\n", str); + printf("str[2] = %d;\n", str[2]); + + printf("a = %d;\nc = %d;\nstr = %s;\nstr[2] = %d;\n", a, c, str, str[2]); + + printf("a = %d;\nc = %d;\nstr = %s;\nstr[2] = %d;\n" + "a = %d;\nc = %d;\nstr = %s;\nstr[2] = %d;\n" + ,a, c, str, str[2] + ,a, c, str, str[2]); + return 0; } diff --git a/project/tests/main/operations/sizeof/sizeof_types/sizeof_ptr/sizeof_ptr_array1/sizeof_ptr_array1.c b/project/tests/main/operations/sizeof/sizeof_types/sizeof_ptr/sizeof_ptr_array1/sizeof_ptr_array1.c new file mode 100644 index 00000000..783e2cd3 --- /dev/null +++ b/project/tests/main/operations/sizeof/sizeof_types/sizeof_ptr/sizeof_ptr_array1/sizeof_ptr_array1.c @@ -0,0 +1,31 @@ +//clang -Xclang -ast-dump -fsyntax-only sizeof_variing.c +//clang -O0 -Wall -masm=intel -S -fno-asynchronous-unwind-tables -fcf-protection=none sizeof_variing.c +//clang -emit-llvm -S -o sizeof_variing.ll sizeof_variing.c + +#include + +struct Rectangle {int x, y;}; +struct Triangle {int a, b, c;}; + +unsigned long size; +int *ptr_array_int[10]; +long *ptr_array_long[10]; +struct Rectangle *ptr_array_struct_rect[10]; +struct Triangle *ptr_array_struct_trian[10]; + + +int main() { + size = sizeof(ptr_array_int); + printf("sizeof(int *ptr_array_int) = %ld\n", size); + + size = sizeof(ptr_array_long); + printf("sizeof(int *ptr_array_long) = %ld\n", size); + + size = sizeof(ptr_array_struct_rect); + printf("sizeof(struct Rectangle *ptr_array_struct_rect) = %ld\n", size); + + size = sizeof(ptr_array_struct_trian); + printf("sizeof(struct Triangle *ptr_array_struct_trian) = %ld\n", size); + + return 0; +} diff --git a/project/tests/main/operations/sizeof/sizeof_types/sizeof_ptr/sizeof_ptr_array2/sizeof_ptr_array2.c b/project/tests/main/operations/sizeof/sizeof_types/sizeof_ptr/sizeof_ptr_array2/sizeof_ptr_array2.c new file mode 100644 index 00000000..a647c743 --- /dev/null +++ b/project/tests/main/operations/sizeof/sizeof_types/sizeof_ptr/sizeof_ptr_array2/sizeof_ptr_array2.c @@ -0,0 +1,31 @@ +//clang -Xclang -ast-dump -fsyntax-only sizeof_variing.c +//clang -O0 -Wall -masm=intel -S -fno-asynchronous-unwind-tables -fcf-protection=none sizeof_variing.c +//clang -emit-llvm -S -o sizeof_variing.ll sizeof_variing.c + +#include + +struct Rectangle {int x, y;}; +struct Triangle {int a, b, c;}; + +unsigned long size; +int *ptr_array_int[10][3]; +long *ptr_array_long[10][3]; +struct Rectangle *ptr_array_struct_rect[3][10]; +struct Triangle *ptr_array_struct_trian[10][3]; + + +int main() { + size = sizeof(ptr_array_int); + printf("sizeof(int *ptr_array_int) = %ld\n", size); + + size = sizeof(ptr_array_long); + printf("sizeof(int *ptr_array_long) = %ld\n", size); + + size = sizeof(ptr_array_struct_rect); + printf("sizeof(struct Rectangle *ptr_array_struct_rect) = %ld\n", size); + + size = sizeof(ptr_array_struct_trian); + printf("sizeof(struct Triangle *ptr_array_struct_trian) = %ld\n", size); + + return 0; +} diff --git a/project/tests/main/operations/sizeof/sizeof_types/sizeof_ptr/sizeof_ptr_type/sizeof_ptr_type.c b/project/tests/main/operations/sizeof/sizeof_types/sizeof_ptr/sizeof_ptr_type/sizeof_ptr_type.c new file mode 100644 index 00000000..9a7384e7 --- /dev/null +++ b/project/tests/main/operations/sizeof/sizeof_types/sizeof_ptr/sizeof_ptr_type/sizeof_ptr_type.c @@ -0,0 +1,31 @@ +//clang -Xclang -ast-dump -fsyntax-only sizeof_ptr_int.c +//clang -O0 -Wall -masm=intel -S -fno-asynchronous-unwind-tables -fcf-protection=none sizeof_ptr_int.c +//clang -emit-llvm -S -o sizeof_ptr_int.ll sizeof_ptr_int.c + +#include + +struct Rectangle {int x, y;}; +struct Triangle {int a, b, c;}; + +// unsigned long size; +unsigned long size; +int *ptr_int; +int *ptr_long; +struct Rectangle *ptr_struct_rect; +struct Triangle *ptr_struct_trian; + +int main() { + size = sizeof(ptr_int); + printf("sizeof(int *ptr_int) = %ld\n", size); + + size = sizeof(ptr_long); + printf("sizeof(int *ptr_long) = %ld\n", size); + + size = sizeof(ptr_struct_rect); + printf("sizeof(struct Rectangle *ptr_struct_rect) = %ld\n", size); + + size = sizeof(ptr_struct_trian); + printf("sizeof(struct Triangle *ptr_struct_trian) = %ld\n", size); + + return 0; +} diff --git a/project/tests/main/pointers/array-ptr/arrayNd/array1d_01.c b/project/tests/main/pointers/array-ptr/arrayNd/array1d_01.c new file mode 100644 index 00000000..d9aeb398 --- /dev/null +++ b/project/tests/main/pointers/array-ptr/arrayNd/array1d_01.c @@ -0,0 +1,20 @@ +//clang -Xclang -ast-dump -fsyntax-only array_ptr01.c +//clang -O0 -Wall -masm=intel -S -fno-asynchronous-unwind-tables -fcf-protection=none array_ptr01.c +//clang -emit-llvm -S -o array_ptr01.ll array_ptr01.c + +#include +int array[5]; +int x; + +int main() { + array[0] = 10; + array[1] = 11; + array[2] = 12; + array[3] = 13; + array[4] = 14; + for(int i = 0; i < 5; ++i) { + printf("array[%d] = %d\n", i, array[i]); + } + + return array[0]; +} diff --git a/project/tests/main/pointers/array-ptr/arrayNd/array2d_01.c b/project/tests/main/pointers/array-ptr/arrayNd/array2d_01.c new file mode 100644 index 00000000..add2343b --- /dev/null +++ b/project/tests/main/pointers/array-ptr/arrayNd/array2d_01.c @@ -0,0 +1,24 @@ +#include "stdio.h" + +long a[2][3] = {0,1,2,10,11,12}; +int i, j; + +int main() { +// printf("sizeof a = %ld\n", sizeof(a)); +// printf("sizeof *a = %ld\n", sizeof(*a)); +// printf("sizeof **a = %ld\n", sizeof(**a)); + + printf("a[0][0] = %ld\n", a[0][0]); + printf("a[0][1] = %ld\n", a[0][1]); + printf("a[0][2] = %ld\n", a[0][2]); + printf("a[1][0] = %ld\n", a[1][0]); + printf("a[1][1] = %ld\n", a[1][1]); + printf("a[1][2] = %ld\n", a[1][2]); + + for(i = 0; i < 2; ++i) + for(j = 0; j < 3; ++j) { + a[i][j] += 100; + printf("a[%d][%d] = %ld\n", i, j, a[i][j]); + } + return 0; +} diff --git a/project/tests/main/pointers/array-ptr/arrayNd/array3d_01.c b/project/tests/main/pointers/array-ptr/arrayNd/array3d_01.c new file mode 100644 index 00000000..b672b8df --- /dev/null +++ b/project/tests/main/pointers/array-ptr/arrayNd/array3d_01.c @@ -0,0 +1,23 @@ +#include "stdio.h" + +long a[2][3][4]; +int i, j, k; + +int main() { +// printf("sizeof a = %ld\n", sizeof(a)); +// printf("sizeof *a = %ld\n", sizeof(*a)); +// printf("sizeof **a = %ld\n", sizeof(**a)); +// printf("sizeof ***a = %ld\n", sizeof(***a)); + + + for(i = 0; i < 2; ++i) { + for(j = 0; j < 3; ++j) { + for(k = 0; k < 4; ++k) { + a[i][j][k] = 100 * i + 10 * j + k; + printf("a[%d][%d][%d] = %ld\n", i, j, k, a[i][j][k]); + } + } + } + + return 0; +} diff --git a/project/tests/main/pointers/array-ptr/array_ptr/array_ptr_double.c b/project/tests/main/pointers/array-ptr/array_ptr/array_ptr_double.c new file mode 100644 index 00000000..6ccdd363 --- /dev/null +++ b/project/tests/main/pointers/array-ptr/array_ptr/array_ptr_double.c @@ -0,0 +1,33 @@ +//clang -Xclang -ast-dump -fsyntax-only array_ptr03.c +//clang -O0 -Wall -masm=intel -S -fno-asynchronous-unwind-tables -fcf-protection=none array_ptr03.c +//clang -emit-llvm -S -o array_ptr03.ll array_ptr03.c + +#include +double array[5] = {10.0, 11.0, 12.0, 13.0, 14.0}; +double *ptr_double01; +double *ptr_double02; +int x = 1; + +int main() { + printf("array[0] = %f\n", *array); + + ptr_double01 = &x; + printf("*ptr_double01 = %f\n", *ptr_double01); + + ptr_double01 = array + 1; + printf("*ptr_double01 = %f\n", *ptr_double01); + + ptr_double02 = ptr_double01 + 2; + printf("*ptr_double02 = %f\n", *ptr_double02); + + ptr_double02 = ptr_double02 + x; + printf("*ptr_double02 = %f\n", *ptr_double02); + + ptr_double02 = ptr_double02 - 3; + printf("*ptr_double02 = %f\n", *ptr_double02); + + ptr_double02 = ptr_double01 - x; + printf("*ptr_double01 = %f\n", *ptr_double01); + + return 0; +} diff --git a/project/tests/main/pointers/array-ptr/array_ptr/array_ptr_int.c b/project/tests/main/pointers/array-ptr/array_ptr/array_ptr_int.c new file mode 100644 index 00000000..9a364f0b --- /dev/null +++ b/project/tests/main/pointers/array-ptr/array_ptr/array_ptr_int.c @@ -0,0 +1,39 @@ +//clang -Xclang -ast-dump -fsyntax-only array_ptr02.c +//clang -O0 -Wall -masm=intel -S -fno-asynchronous-unwind-tables -fcf-protection=none array_ptr02.c +//clang -emit-llvm -S -o array_ptr02.ll array_ptr02.c + +#include +int array[5] = {10, 11, 12, 13, 14}; +int *ptr_int01; +int *ptr_int02; +int x = 1; + +int main() { + printf("array[0] = %d\n", *array); + + ptr_int01 = &x; + printf("*ptr_int01 = %d\n", *ptr_int01); + + ptr_int01 = array + 1; + printf("*ptr_int01 = %d\n", *ptr_int01); + + ptr_int02 = ptr_int01 + 2; + printf("*ptr_int02 = %d\n", *ptr_int02); + + ptr_int02 = ptr_int02 + x; + printf("*ptr_int02 = %d\n", *ptr_int02); + + ptr_int02 = ptr_int02 - 3; + printf("*ptr_int02 = %d\n", *ptr_int02); + + ptr_int02 = ptr_int01 - x; + printf("*ptr_int01 = %d\n", *ptr_int01); + + *array = x; + printf("*array = %d\n", *array); + + *(array + 1) = *(array +3); + printf("*array = %d\n", *(array+1)); + + return *ptr_int02; +} diff --git a/project/tests/main/pointers/array-ptr/array_ptr/array_ptr_int_llops.c b/project/tests/main/pointers/array-ptr/array_ptr/array_ptr_int_llops.c new file mode 100644 index 00000000..abd296df --- /dev/null +++ b/project/tests/main/pointers/array-ptr/array_ptr/array_ptr_int_llops.c @@ -0,0 +1,25 @@ +//clang -Xclang -ast-dump -fsyntax-only array_ptr04.c +//clang -O0 -Wall -masm=intel -S -fno-asynchronous-unwind-tables -fcf-protection=none array_ptr04.c +//clang -emit-llvm -S -o array_ptr04.ll array_ptr04.c + +#include +int array[5] = {10, 11, 12, 13, 14}; +int *ptr_int01; +int *ptr_int02; +int x = 1; + +int main() { + ptr_int01 = array; + + while(ptr_int01 < array+5) { + printf("*ptr_int01 = %d\n", *ptr_int01); + ptr_int01 += 1; + } + + do { + ptr_int01 -= 1; + printf("*ptr_int01 = %d\n", *ptr_int01); + } while(ptr_int01 != array); + + return 0; +} diff --git a/project/tests/main/pointers/array-ptr/array_ptr/array_ptr_substr_int_double.c b/project/tests/main/pointers/array-ptr/array_ptr/array_ptr_substr_int_double.c new file mode 100644 index 00000000..44f11fa8 --- /dev/null +++ b/project/tests/main/pointers/array-ptr/array_ptr/array_ptr_substr_int_double.c @@ -0,0 +1,39 @@ +//clang -Xclang -ast-dump -fsyntax-only array_ptr04.c +//clang -O0 -Wall -masm=intel -S -fno-asynchronous-unwind-tables -fcf-protection=none array_ptr04.c +//clang -emit-llvm -S -o array_ptr04.ll array_ptr04.c + +#include +int array[5] = {10, 11, 12, 13, 14}; +int *ptr_int01; +int *ptr_int02; +double *ptr_double01; +double darray[5] = {110, 111, 112, 113, 114}; +int x = 1; + +int main() { + ptr_int01 = array + 1; + printf("*ptr_int01 = %d\n", *ptr_int01); + + ptr_int02 = ptr_int01 + 3; + printf("*ptr_int02 = %d\n", *ptr_int02); + + x = ptr_int02 - ptr_int01; + printf("x = %d\n", x); + + x = ptr_int01 - ptr_int02; + printf("x = %d\n", x); + + x = ptr_int02 - array; + printf("x = %d\n", x); + + x = array - ptr_int02; + printf("x = %d\n", x); + + ptr_double01 = darray + 2; + printf("*ptr_double01 = %f\n", *ptr_double01); + + x = ptr_double01 - darray; + printf("x = %d\n", x); + + return x; +} diff --git a/project/tests/main/pointers/global/long_long_global_array_ptr.c b/project/tests/main/pointers/global/long_long_global_array_ptr.c index 1c71c403..5a922a93 100644 --- a/project/tests/main/pointers/global/long_long_global_array_ptr.c +++ b/project/tests/main/pointers/global/long_long_global_array_ptr.c @@ -18,7 +18,8 @@ int main() { long long x; i = 0; - ptr = &A; +// ptr = &A; + ptr = A; while(i < n) { x = *ptr; printf("%lld\n", x); diff --git a/project/tests/in_progress/for_main/bad/operators/switch/switch01/switch01.c b/project/tests/main/switch_and_if_else/switch/switch01.c similarity index 77% rename from project/tests/in_progress/for_main/bad/operators/switch/switch01/switch01.c rename to project/tests/main/switch_and_if_else/switch/switch01.c index 88786931..2f444375 100644 --- a/project/tests/in_progress/for_main/bad/operators/switch/switch01/switch01.c +++ b/project/tests/main/switch_and_if_else/switch/switch01.c @@ -26,22 +26,22 @@ void op10() { void test_switch() { switch (x) { - case 1: - op1(); - break; - case 2: - case 3: - op23(); - break; - case 4: - op4(); - case 5: - op5(); - break; - case 6: - default: - op10(); - break; + case 1: + op1(); + break; + case 2: + case 3: + op23(); + break; + case 4: + op4(); + case 5: + op5(); + break; + case 6: + default: + op10(); + break; } } diff --git a/project/tests/in_progress/for_main/bad/operators/switch/switch02/switch02.c b/project/tests/main/switch_and_if_else/switch/switch02.c similarity index 82% rename from project/tests/in_progress/for_main/bad/operators/switch/switch02/switch02.c rename to project/tests/main/switch_and_if_else/switch/switch02.c index abac8c3d..35ac2cde 100644 --- a/project/tests/in_progress/for_main/bad/operators/switch/switch02/switch02.c +++ b/project/tests/main/switch_and_if_else/switch/switch02.c @@ -26,18 +26,18 @@ void op10() { void test_switch() { switch (x) { - case 1: - op1(); - case 2: - case 3: - op23(); - case 4: - op4(); - case 5: - op5(); - case 6: - default: - op10(); + case 1: + op1(); + case 2: + case 3: + op23(); + case 4: + op4(); + case 5: + op5(); + case 6: + default: + op10(); } } diff --git a/project/tests/main/tests_suite/test080/testsuite080.c b/project/tests/main/tests_suite/test080/testsuite080.c new file mode 100644 index 00000000..1fb6371e --- /dev/null +++ b/project/tests/main/tests_suite/test080/testsuite080.c @@ -0,0 +1,15 @@ +//clang -Xclang -ast-dump -fsyntax-only 00080.c +#include + +int c; + +void voidfn() { + c = 10; + return; +} + +int main() { + voidfn(); + printf("%lld\n", c); + return 0; +} diff --git a/project/tests/unit_tests/CMakeLists.txt b/project/tests/unit_tests/CMakeLists.txt old mode 100755 new mode 100644 index 09c98593..3aed1c22 --- a/project/tests/unit_tests/CMakeLists.txt +++ b/project/tests/unit_tests/CMakeLists.txt @@ -1,6 +1,6 @@ include_directories( - . - ../../src/transpiler + . + ../../src/transpiler ) find_package(GTest REQUIRED) @@ -17,9 +17,9 @@ add_executable(unit_tests if (UNIX) find_package(Threads REQUIRED) target_link_libraries( - unit_tests - ${GTEST_LIBRARIES} - Threads::Threads + unit_tests + ${GTEST_LIBRARIES} + Threads::Threads ) endif () diff --git a/project/tests/unit_tests/util_test.cpp b/project/tests/unit_tests/util_test.cpp old mode 100644 new mode 100755 index bc731e5c..0c3c2226 --- a/project/tests/unit_tests/util_test.cpp +++ b/project/tests/unit_tests/util_test.cpp @@ -2,7 +2,6 @@ // Created by yarrya on 22.08.22. // #include -// #include #include "util.h" diff --git a/readme.md b/readme.md index 99fd162a..be5d9962 100644 --- a/readme.md +++ b/readme.md @@ -49,7 +49,8 @@ Again, we recommend [Ubuntu 22.04+](https://ubuntu.com/download) and you will ne [cmake 3.18+](https://cmake.org/download/), [gcc 11.2.+](http://mirror.linux-ia64.org/gnu/gcc/releases/), [g++ 11.2.+](https://pkgs.org/download/g++), -[ninja-build 1.10.1+](https://ninja-build.org/) +[ninja-build 1.10.1+](https://ninja-build.org/), +[clang 14.0.0+](https://releases.llvm.org/14.0.0/tools/clang/docs/) and [python3 3.9.7+](https://www.python.org/downloads/). You will also need requirements for [the EO project](https://github.com/objectionary/eo) ([Maven 3.3+](https://maven.apache.org) and Java 8+) diff --git a/result/eo/c2eo/coperators/as-char.eo b/result/eo/c2eo/coperators/as-char.eo new file mode 100644 index 00000000..9712f75a --- /dev/null +++ b/result/eo/c2eo/coperators/as-char.eo @@ -0,0 +1,4 @@ ++package c2eo.coperators + +[a] > as-char + a.as-bytes.slice 7 1 > @ diff --git a/result/eo/c2eo/coperators/as-int16.eo b/result/eo/c2eo/coperators/as-int16.eo index e381194a..ad9eeb76 100644 --- a/result/eo/c2eo/coperators/as-int16.eo +++ b/result/eo/c2eo/coperators/as-int16.eo @@ -3,8 +3,4 @@ +package c2eo.coperators [a] > as-int16 - (number a).as-int > value! - if. > @ - (value.as-bytes.slice 6 1).as-int.gte 0 - (00-00-00-00-00-00.concat (value.as-bytes.slice 6 2)).as-int - (FF-FF-FF-FF-FF-FF.concat (value.as-bytes.slice 6 2)).as-int + ((number a).as-int.as-bytes.slice 6 2).as-int > @ diff --git a/result/eo/c2eo/coperators/as-int32.eo b/result/eo/c2eo/coperators/as-int32.eo index 4beb4bc8..be8df975 100644 --- a/result/eo/c2eo/coperators/as-int32.eo +++ b/result/eo/c2eo/coperators/as-int32.eo @@ -3,8 +3,4 @@ +package c2eo.coperators [a] > as-int32 - (number a).as-int > value! - if. > @ - (value.as-bytes.slice 4 1).as-int.gte 0 - (00-00-00-00.concat (value.as-bytes.slice 4 4)).as-int - (FF-FF-FF-FF.concat (value.as-bytes.slice 4 4)).as-int + ((number a).as-int.as-bytes.slice 4 4).as-int > @ diff --git a/result/eo/c2eo/coperators/as-int8.eo b/result/eo/c2eo/coperators/as-int8.eo index 463b5a94..2ea9139f 100644 --- a/result/eo/c2eo/coperators/as-int8.eo +++ b/result/eo/c2eo/coperators/as-int8.eo @@ -3,8 +3,4 @@ +package c2eo.coperators [a] > as-int8 - (number a).as-int > value! - if. > @ - (value.as-bytes.slice 7 1).as-int.gte 0 - (00-00-00-00-00-00-00.concat (value.as-bytes.slice 7 1)).as-int - (FF-FF-FF-FF-FF-FF-FF.concat (value.as-bytes.slice 7 1)).as-int + ((number a).as-int.as-bytes.slice 7 1).as-int > @ diff --git a/result/eo/c2eo/coperators/post-dec-float32.eo b/result/eo/c2eo/coperators/post-dec-float32.eo index 069db052..ce3f555c 100644 --- a/result/eo/c2eo/coperators/post-dec-float32.eo +++ b/result/eo/c2eo/coperators/post-dec-float32.eo @@ -5,5 +5,5 @@ [a] > post-dec-float32 seq > @ - write-as-float32 a ((read-as-float32 a).minus 1) - (read-as-float32 a).plus 1 + write-as-float32 a ((read-as-float32 a).minus 1.0) + (read-as-float32 a).plus 1.0 diff --git a/result/eo/c2eo/coperators/post-dec-float64.eo b/result/eo/c2eo/coperators/post-dec-float64.eo index 79c4f6d3..8f7b56c5 100644 --- a/result/eo/c2eo/coperators/post-dec-float64.eo +++ b/result/eo/c2eo/coperators/post-dec-float64.eo @@ -5,5 +5,5 @@ [a] > post-dec-float64 seq > @ - write-as-float64 a ((read-as-float64 a).minus 1) - (read-as-float64 a).plus 1 + write-as-float64 a ((read-as-float64 a).minus 1.0) + (read-as-float64 a).plus 1.0 diff --git a/result/eo/c2eo/coperators/post-inc-float32.eo b/result/eo/c2eo/coperators/post-inc-float32.eo index b132be48..d34ea7eb 100644 --- a/result/eo/c2eo/coperators/post-inc-float32.eo +++ b/result/eo/c2eo/coperators/post-inc-float32.eo @@ -5,5 +5,5 @@ [a] > post-inc-float32 seq > @ - write-as-float32 a ((read-as-float32 a).plus 1) - (read-as-float32 a).minus 1 + write-as-float32 a ((read-as-float32 a).plus 1.0) + (read-as-float32 a).minus 1.0 diff --git a/result/eo/c2eo/coperators/post-inc-float64.eo b/result/eo/c2eo/coperators/post-inc-float64.eo index 861a11e2..a0275d94 100644 --- a/result/eo/c2eo/coperators/post-inc-float64.eo +++ b/result/eo/c2eo/coperators/post-inc-float64.eo @@ -5,5 +5,5 @@ [a] > post-inc-float64 seq > @ - write-as-float64 a ((read-as-float64 a).plus 1) - (read-as-float64 a).minus 1 + write-as-float64 a ((read-as-float64 a).plus 1.0) + (read-as-float64 a).minus 1.0 diff --git a/result/eo/c2eo/coperators/pre-dec-float32.eo b/result/eo/c2eo/coperators/pre-dec-float32.eo index 9e9547b4..0096925d 100644 --- a/result/eo/c2eo/coperators/pre-dec-float32.eo +++ b/result/eo/c2eo/coperators/pre-dec-float32.eo @@ -4,4 +4,4 @@ +package c2eo.coperators [a] > pre-dec-float32 - write-as-float32 a ((read-as-float32 a).minus 1) > @ + write-as-float32 a ((read-as-float32 a).minus 1.0) > @ diff --git a/result/eo/c2eo/coperators/pre-dec-float64.eo b/result/eo/c2eo/coperators/pre-dec-float64.eo index 29ddcaf5..b1a21546 100644 --- a/result/eo/c2eo/coperators/pre-dec-float64.eo +++ b/result/eo/c2eo/coperators/pre-dec-float64.eo @@ -4,4 +4,4 @@ +package c2eo.coperators [a] > pre-dec-float64 - write-as-float64 a ((read-as-float64 a).minus 1) > @ + write-as-float64 a ((read-as-float64 a).minus 1.0) > @ diff --git a/result/eo/c2eo/coperators/pre-inc-float32.eo b/result/eo/c2eo/coperators/pre-inc-float32.eo index cddfddc6..0c2a6e77 100644 --- a/result/eo/c2eo/coperators/pre-inc-float32.eo +++ b/result/eo/c2eo/coperators/pre-inc-float32.eo @@ -4,4 +4,4 @@ +package c2eo.coperators [a] > pre-inc-float32 - write-as-float32 a ((read-as-float32 a).plus 1) > @ + write-as-float32 a ((read-as-float32 a).plus 1.0) > @ diff --git a/result/eo/c2eo/coperators/pre-inc-float64.eo b/result/eo/c2eo/coperators/pre-inc-float64.eo index 716122f4..e8ae0611 100644 --- a/result/eo/c2eo/coperators/pre-inc-float64.eo +++ b/result/eo/c2eo/coperators/pre-inc-float64.eo @@ -4,4 +4,4 @@ +package c2eo.coperators [a] > pre-inc-float64 - write-as-float64 a ((read-as-float64 a).plus 1) > @ + write-as-float64 a ((read-as-float64 a).plus 1.0) > @ diff --git a/result/eo/c2eo/coperators/read-as-int16.eo b/result/eo/c2eo/coperators/read-as-int16.eo index 396f45da..50037eef 100644 --- a/result/eo/c2eo/coperators/read-as-int16.eo +++ b/result/eo/c2eo/coperators/read-as-int16.eo @@ -1,7 +1,4 @@ +package c2eo.coperators [a] > read-as-int16 - if. > @ - (a.read 1).as-int.gte 0 - (00-00-00-00-00-00.concat (a.read 2)).as-int - (FF-FF-FF-FF-FF-FF.concat (a.read 2)).as-int \ No newline at end of file + (a.read 2).as-int > @ diff --git a/result/eo/c2eo/coperators/read-as-int32.eo b/result/eo/c2eo/coperators/read-as-int32.eo index d133cffb..a39e546c 100644 --- a/result/eo/c2eo/coperators/read-as-int32.eo +++ b/result/eo/c2eo/coperators/read-as-int32.eo @@ -1,7 +1,4 @@ +package c2eo.coperators [a] > read-as-int32 - if. > @ - (a.read 1).as-int.gte 0 - (00-00-00-00.concat (a.read 4)).as-int - (FF-FF-FF-FF.concat (a.read 4)).as-int + (a.read 4).as-int > @ diff --git a/result/eo/c2eo/coperators/read-as-int8.eo b/result/eo/c2eo/coperators/read-as-int8.eo index f36baec7..b06b388c 100644 --- a/result/eo/c2eo/coperators/read-as-int8.eo +++ b/result/eo/c2eo/coperators/read-as-int8.eo @@ -1,7 +1,4 @@ +package c2eo.coperators [a] > read-as-int8 - if. > @ - (a.read 1).as-int.gte 0 - (00-00-00-00-00-00-00.concat (a.read 1)).as-int - (FF-FF-FF-FF-FF-FF-FF.concat (a.read 1)).as-int \ No newline at end of file + (a.read 1).as-int > @ diff --git a/result/eo/c2eo/coperators/read-as-uint32.eo b/result/eo/c2eo/coperators/read-as-uint32.eo index feb98a70..5125deb3 100644 --- a/result/eo/c2eo/coperators/read-as-uint32.eo +++ b/result/eo/c2eo/coperators/read-as-uint32.eo @@ -1,4 +1,4 @@ +package c2eo.coperators [a] > read-as-uint32 - (00-00-00-00-00-00.concat (a.read 4)).as-int > @ + (00-00-00-00.concat (a.read 4)).as-int > @ diff --git a/result/pom.xml b/result/pom.xml index 1b09f73a..829ed23d 100644 --- a/result/pom.xml +++ b/result/pom.xml @@ -28,7 +28,7 @@ SOFTWARE. c2eo-transpiler 1.0-SNAPSHOT - 0.27.1 + 0.27.2