blob: 48fcce0b4924f1c615b841466067537fd82ba154 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Sebastian Redlc42e1182008-11-11 11:37:55 +00002
3void f()
4{
Richard Trieu2fe9b7f2011-12-15 00:38:15 +00005 (void)typeid(int); // expected-error {{you need to include <typeinfo> before using the 'typeid' operator}}
Sebastian Redlc42e1182008-11-11 11:37:55 +00006}
7
Sebastian Redlc42e1182008-11-11 11:37:55 +00008namespace std {
9 class type_info;
10}
11
12void g()
13{
14 (void)typeid(int);
15}
Douglas Gregor765ccba2009-12-23 21:06:06 +000016
17struct X; // expected-note 3{{forward declaration}}
18
19void g1(X &x) {
John McCall7c2342d2010-03-10 11:27:22 +000020 (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 Gregor765ccba2009-12-23 21:06:06 +000023}
Stephen Hines0e2c34f2015-03-23 12:09:02 -070024
25void 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}