Skip to content

Commit a655b68

Browse files
add tests
1 parent 71f3caf commit a655b68

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

clang/test/3C/function_typedef.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: rm -rf %t*
2+
// RUN: 3c -base-dir=%S -alltypes -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_ALL","CHECK" %s
3+
// RUN: 3c -base-dir=%S -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_NOALL","CHECK" %s
4+
// RUN: 3c -base-dir=%S -addcr %s -- | %clang -c -fcheckedc-extension -x c -o /dev/null -
5+
// RUN: 3c -base-dir=%S -output-dir=%t.checked -alltypes %s --
6+
// RUN: 3c -base-dir=%t.checked -alltypes %t.checked/function_typedef.c -- | diff %t.checked/function_typedef.c
7+
8+
// Tests for the single file case in issue #430
9+
// Functions declared using a typedef should be rewritten in a way that doesn't
10+
// crash 3C or generate uncompilable code. The expected output for these tests
11+
// expected to change when issue #437.
12+
13+
typedef void foo(int*);
14+
foo foo_impl;
15+
void foo_imp(int *a) {};
16+
17+
typedef int *bar();
18+
bar bar_impl;
19+
int *bar_impl() {
20+
return 0;
21+
};
22+
23+
typedef int *baz(int *);
24+
baz baz_impl;
25+
int *baz_impl(int *a) {
26+
return 0;
27+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: rm -rf %t*
2+
// RUN: 3c -base-dir=%S -addcr -output-dir=%t.checked %S/function_typedef_multi.c %S/function_typedef_multi.h --
3+
// RUN: test ! -f %t.checked/function_typedef_multi.h -a ! -f %t.checked/function_typedef_multi.c
4+
5+
// Test for the two file case in issue #430
6+
// This test caused an assertion to fail prior to PR #436
7+
// This test function_typedef_multi.h. The header is deliberately not included
8+
// in this file. Including the header prevented the assertion fail even without
9+
// the changes in PR #436.
10+
11+
int foo(int a, int b[1]) {
12+
return 0;
13+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Used with function_typedef_multi.c
2+
typedef int a(int, int[1]);
3+
a foo;

0 commit comments

Comments
 (0)