Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | /* RUN: %clang_cc1 -fsyntax-only -verify -std=c90 -pedantic %s |
Eli Friedman | 5320285 | 2009-05-03 22:36:05 +0000 | [diff] [blame] | 2 | */ |
Steve Naroff | 08f1967 | 2008-01-13 17:10:08 +0000 | [diff] [blame] | 3 | void |
4 | foo (void) | ||||
5 | { | ||||
6 | struct b; | ||||
7 | struct b* x = 0; | ||||
8 | struct b* y = &*x; | ||||
9 | } | ||||
10 | |||||
11 | void foo2 (void) | ||||
12 | { | ||||
13 | typedef int (*arrayptr)[]; | ||||
14 | arrayptr x = 0; | ||||
15 | arrayptr y = &*x; | ||||
16 | } | ||||
17 | |||||
18 | void foo3 (void) | ||||
19 | { | ||||
20 | void* x = 0; | ||||
Eli Friedman | 5320285 | 2009-05-03 22:36:05 +0000 | [diff] [blame] | 21 | void* y = &*x; /* expected-warning{{address of an expression of type 'void'}} */ |
Steve Naroff | 75ceedf | 2008-02-10 00:30:18 +0000 | [diff] [blame] | 22 | } |
23 | |||||
24 | extern const void cv1; | ||||
Steve Naroff | a0992b6 | 2008-02-18 15:14:59 +0000 | [diff] [blame] | 25 | |
Steve Naroff | 75ceedf | 2008-02-10 00:30:18 +0000 | [diff] [blame] | 26 | const void *foo4 (void) |
27 | { | ||||
28 | return &cv1; | ||||
Steve Naroff | 08f1967 | 2008-01-13 17:10:08 +0000 | [diff] [blame] | 29 | } |
30 | |||||
Steve Naroff | acb818a | 2008-02-10 01:39:04 +0000 | [diff] [blame] | 31 | extern void cv2; |
32 | void *foo5 (void) | ||||
33 | { | ||||
Eli Friedman | 5320285 | 2009-05-03 22:36:05 +0000 | [diff] [blame] | 34 | return &cv2; /* expected-warning{{address of an expression of type 'void'}} */ |
Steve Naroff | acb818a | 2008-02-10 01:39:04 +0000 | [diff] [blame] | 35 | } |
Steve Naroff | a0992b6 | 2008-02-18 15:14:59 +0000 | [diff] [blame] | 36 | |
37 | typedef const void CVT; | ||||
38 | extern CVT cv3; | ||||
39 | |||||
40 | const void *foo6 (void) | ||||
41 | { | ||||
42 | return &cv3; | ||||
43 | } | ||||
44 |