Bruno Ricci | d3b7528 | 2020-06-19 13:35:50 +0100 | [diff] [blame] | 1 | // Test without serialization: |
| 2 | // RUN: %clang_cc1 -triple wasm32-unknown-unknown -ast-dump %s \ |
| 3 | // RUN: | FileCheck --strict-whitespace %s |
Dan Gohman | 0d4e243 | 2020-06-05 14:27:52 -0700 | [diff] [blame] | 4 | |
Bruno Ricci | d3b7528 | 2020-06-19 13:35:50 +0100 | [diff] [blame] | 5 | // Test with serialization: |
| 6 | // RUN: %clang_cc1 -triple wasm32-unknown-unknown -emit-pch -o %t %s |
| 7 | // RUN: %clang_cc1 -triple wasm32-unknown-unknown -x c -include-pch %t -ast-dump-all /dev/null \ |
| 8 | // RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \ |
| 9 | // RUN: | FileCheck --strict-whitespace %s |
| 10 | // |
Dan Gohman | 0d4e243 | 2020-06-05 14:27:52 -0700 | [diff] [blame] | 11 | // Test that functions can be redeclared and they retain their attributes. |
| 12 | |
| 13 | __attribute__((import_name("import_red"), import_module("mod"))) void red(void); |
| 14 | __attribute__((import_name("import_orange"), import_module("mod"))) void orange(void); |
| 15 | __attribute__((import_name("import_yellow"), import_module("mod"))) void yellow(void); |
| 16 | |
| 17 | void red(void); |
| 18 | void orange(void); |
| 19 | void yellow(void); |
| 20 | |
| 21 | void calls(void) { |
| 22 | red(); |
| 23 | orange(); |
| 24 | yellow(); |
| 25 | } |
| 26 | |
| 27 | // CHECK: |-FunctionDecl {{.+}} used red 'void (void)' |
| 28 | // CHECK: | |-WebAssemblyImportNameAttr {{.+}} "import_red" |
| 29 | // CHECK: | `-WebAssemblyImportModuleAttr {{.+}} "mod" |
| 30 | // CHECK: |-FunctionDecl {{.+}} used orange 'void (void)' |
| 31 | // CHECK: | |-WebAssemblyImportNameAttr {{.+}} "import_orange" |
| 32 | // CHECK: | `-WebAssemblyImportModuleAttr {{.+}} "mod" |
| 33 | // CHECK: |-FunctionDecl {{.+}} used yellow 'void (void)' |
| 34 | // CHECK: | |-WebAssemblyImportNameAttr {{.+}} "import_yellow" |
| 35 | // CHECK: | `-WebAssemblyImportModuleAttr {{.+}} "mod" |
| 36 | // CHECK: |-FunctionDecl {{.+}} used red 'void (void)' |
| 37 | // CHECK: | |-WebAssemblyImportNameAttr {{.+}} Inherited "import_red" |
| 38 | // CHECK: | `-WebAssemblyImportModuleAttr {{.+}} Inherited "mod" |
| 39 | // CHECK: |-FunctionDecl {{.+}} used orange 'void (void)' |
| 40 | // CHECK: | |-WebAssemblyImportNameAttr {{.+}} Inherited "import_orange" |
| 41 | // CHECK: | `-WebAssemblyImportModuleAttr {{.+}} Inherited "mod" |
| 42 | // CHECK: |-FunctionDecl {{.+}} used yellow 'void (void)' |
| 43 | // CHECK: | |-WebAssemblyImportNameAttr {{.+}} Inherited "import_yellow" |
| 44 | // CHECK: | `-WebAssemblyImportModuleAttr {{.+}} Inherited "mod" |