Momchil Velikov | 57c681f | 2017-08-10 15:43:06 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -std=c90 -verify -fsyntax-only |
| 2 | void t0(int x) { |
Richard Smith | 9bfa970 | 2017-10-04 01:49:22 +0000 | [diff] [blame] | 3 | int explicit_decl(); |
Momchil Velikov | 57c681f | 2017-08-10 15:43:06 +0000 | [diff] [blame] | 4 | int (*p)(); |
| 5 | if(x > 0) |
Richard Smith | 9bfa970 | 2017-10-04 01:49:22 +0000 | [diff] [blame] | 6 | x = g() + 1; // expected-note {{previous implicit declaration}} |
Momchil Velikov | 57c681f | 2017-08-10 15:43:06 +0000 | [diff] [blame] | 7 | p = g; |
| 8 | if(x < 0) { |
| 9 | extern void u(int (*)[h()]); |
| 10 | int (*q)() = h; |
| 11 | } |
| 12 | p = h; /* expected-error {{use of undeclared identifier 'h'}} */ |
| 13 | } |
| 14 | |
| 15 | void t1(int x) { |
| 16 | int (*p)(); |
| 17 | switch (x) { |
| 18 | g(); |
| 19 | case 0: |
| 20 | x = h() + 1; |
| 21 | break; |
| 22 | case 1: |
| 23 | p = g; |
| 24 | p = h; |
| 25 | break; |
| 26 | } |
| 27 | p = g; /* expected-error {{use of undeclared identifier 'g'}} */ |
| 28 | p = h; /* expected-error {{use of undeclared identifier 'h'}} */ |
Richard Smith | 9bfa970 | 2017-10-04 01:49:22 +0000 | [diff] [blame] | 29 | explicit_decl(); |
| 30 | p = explicit_decl; |
Momchil Velikov | 57c681f | 2017-08-10 15:43:06 +0000 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | int t2(int x) { |
| 34 | int y = ({ if (x > 0) x = g() + 1; 2*x; }); |
| 35 | int (*p)() = g; /* expected-error {{use of undeclared identifier 'g'}} */ |
| 36 | return y; |
| 37 | } |
| 38 | |
Richard Smith | 9bfa970 | 2017-10-04 01:49:22 +0000 | [diff] [blame] | 39 | int PR34822() { |
| 40 | {int i = sizeof(PR34822_foo());} /* expected-note {{previous definition is here}} */ |
| 41 | {extern int PR34822_foo;} /* expected-error {{redefinition of 'PR34822_foo' as different kind of symbol}} */ |
| 42 | |
| 43 | {extern int PR34822_bar;} /* expected-note {{previous declaration is here}} */ |
| 44 | {int i = sizeof(PR34822_bar());} /* expected-warning {{use of out-of-scope declaration of 'PR34822_bar' whose type is not compatible with that of an implicit declaration}} expected-error {{called object type 'int' is not a function or function pointer}} */ |
| 45 | } |
| 46 | |
Momchil Velikov | 57c681f | 2017-08-10 15:43:06 +0000 | [diff] [blame] | 47 | int (*p)() = g; /* expected-error {{use of undeclared identifier 'g'}} */ |
| 48 | int (*q)() = h; /* expected-error {{use of undeclared identifier 'h'}} */ |
| 49 | |
Richard Smith | 9bfa970 | 2017-10-04 01:49:22 +0000 | [diff] [blame] | 50 | float g(); /* expected-error {{conflicting types for 'g'}} */ |