diff options
| author | Douglas Gregor <dgregor@apple.com> | 2009-02-24 04:26:15 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2009-02-24 04:26:15 +0000 |
| commit | de681d43eb42158d76a217e7ed6f26ad5f946d7e (patch) | |
| tree | 1bc72082bbbca13aaa1f0a7c51747113ebb92289 /clang/test | |
| parent | 729a8202d0ba660acdc19ddb96420c3363bf2362 (diff) | |
| download | bcm5719-llvm-de681d43eb42158d76a217e7ed6f26ad5f946d7e.tar.gz bcm5719-llvm-de681d43eb42158d76a217e7ed6f26ad5f946d7e.zip | |
In C, when we see a function declaration within a local scope, export
that declaration to global scope so that it can be found from other
scopes. This allows us to diagnose redeclaration errors for external
declarations across scopes. We also warn when name lookup finds such
an out-of-scope declaration. This is part of <rdar://problem/6127293>;
we'll also need to do the same thing for variables.
llvm-svn: 65373
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Sema/function-redecl.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/clang/test/Sema/function-redecl.c b/clang/test/Sema/function-redecl.c index 4be03227227..daa5044dd08 100644 --- a/clang/test/Sema/function-redecl.c +++ b/clang/test/Sema/function-redecl.c @@ -58,3 +58,31 @@ void test2() { } } } + +// <rdar://problem/6127293> +int outer1(int); // expected-note{{previous declaration is here}} +struct outer3 { }; +int outer4(int); +int outer5; // expected-note{{previous definition is here}} +int *outer7(int); + +void outer_test() { + int outer1(float); // expected-error{{conflicting types for 'outer1'}} + int outer2(int); // expected-note{{previous declaration is here}} + int outer3(int); // expected-note{{previous declaration is here}} + int outer4(int); // expected-note{{previous declaration is here}} + int outer5(int); // expected-error{{redefinition of 'outer5' as different kind of symbol}} + int* outer6(int); // expected-note{{previous declaration is here}} + int *outer7(int); + + int *ip7 = outer7(6); +} + +int outer2(float); // expected-error{{conflicting types for 'outer2'}} +int outer3(float); // expected-error{{conflicting types for 'outer3'}} +int outer4(float); // expected-error{{conflicting types for 'outer4'}} + +void outer_test2(int x) { + int* ip = outer6(x); // expected-warning{{use of out-of-scope declaration of 'outer6'}} + int *ip2 = outer7(x); +} |

