1a5728872c7702ddd09537c95bc3cbd20e1f2fb09Daniel Dunbar// RUN: %clang_cc1 -fsyntax-only -verify %s
2c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
3c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlvoid f()
4c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl{
52fe9b7fb07dff15dd15dd8755a9a9e6de0fe46fcRichard Trieu  (void)typeid(int); // expected-error {{you need to include <typeinfo> before using the 'typeid' operator}}
6c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl}
7c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
8c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlnamespace std {
9c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  class type_info;
10c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl}
11c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl
12c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redlvoid g()
13c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl{
14c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl  (void)typeid(int);
15c42e1183846228a7fa5143ad76507d6d60f5c6f3Sebastian Redl}
16765ccba920269eefbf572ec4bcd6ac7b6e9f9f77Douglas Gregor
17765ccba920269eefbf572ec4bcd6ac7b6e9f9f77Douglas Gregorstruct X; // expected-note 3{{forward declaration}}
18765ccba920269eefbf572ec4bcd6ac7b6e9f9f77Douglas Gregor
19765ccba920269eefbf572ec4bcd6ac7b6e9f9f77Douglas Gregorvoid g1(X &x) {
207c2342dd4c9947806842e5aca3d2bb2e542853c9John McCall  (void)typeid(X); // expected-error{{'typeid' of incomplete type 'X'}}
217c2342dd4c9947806842e5aca3d2bb2e542853c9John McCall  (void)typeid(X&); // expected-error{{'typeid' of incomplete type 'X'}}
227c2342dd4c9947806842e5aca3d2bb2e542853c9John McCall  (void)typeid(x); // expected-error{{'typeid' of incomplete type 'X'}}
23765ccba920269eefbf572ec4bcd6ac7b6e9f9f77Douglas Gregor}
240e2c34f92f00628d48968dfea096d36381f494cbStephen Hines
250e2c34f92f00628d48968dfea096d36381f494cbStephen Hinesvoid h(int i) {
260e2c34f92f00628d48968dfea096d36381f494cbStephen Hines  char V[i];
270e2c34f92f00628d48968dfea096d36381f494cbStephen Hines  typeid(V);        // expected-error{{'typeid' of variably modified type 'char [i]'}}
280e2c34f92f00628d48968dfea096d36381f494cbStephen Hines  typeid(char [i]); // expected-error{{'typeid' of variably modified type 'char [i]'}}
290e2c34f92f00628d48968dfea096d36381f494cbStephen Hines}
30