Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Sebastian Redl | c42e118 | 2008-11-11 11:37:55 +0000 | [diff] [blame] | 2 | |
| 3 | void f() |
| 4 | { |
Richard Trieu | 2fe9b7f | 2011-12-15 00:38:15 +0000 | [diff] [blame] | 5 | (void)typeid(int); // expected-error {{you need to include <typeinfo> before using the 'typeid' operator}} |
Sebastian Redl | c42e118 | 2008-11-11 11:37:55 +0000 | [diff] [blame] | 6 | } |
| 7 | |
Sebastian Redl | c42e118 | 2008-11-11 11:37:55 +0000 | [diff] [blame] | 8 | namespace std { |
| 9 | class type_info; |
| 10 | } |
| 11 | |
| 12 | void g() |
| 13 | { |
| 14 | (void)typeid(int); |
| 15 | } |
Douglas Gregor | 765ccba | 2009-12-23 21:06:06 +0000 | [diff] [blame] | 16 | |
| 17 | struct X; // expected-note 3{{forward declaration}} |
| 18 | |
| 19 | void g1(X &x) { |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame] | 20 | (void)typeid(X); // expected-error{{'typeid' of incomplete type 'X'}} |
| 21 | (void)typeid(X&); // expected-error{{'typeid' of incomplete type 'X'}} |
| 22 | (void)typeid(x); // expected-error{{'typeid' of incomplete type 'X'}} |
Douglas Gregor | 765ccba | 2009-12-23 21:06:06 +0000 | [diff] [blame] | 23 | } |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 24 | |
| 25 | void h(int i) { |
| 26 | char V[i]; |
| 27 | typeid(V); // expected-error{{'typeid' of variably modified type 'char [i]'}} |
| 28 | typeid(char [i]); // expected-error{{'typeid' of variably modified type 'char [i]'}} |
| 29 | } |