[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / SemaCXX / typeid.cpp
blob26cad1c88f4d6b96ddc7f3f9b49b42eda441aac5
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 void f()
5 (void)typeid(int); // expected-error {{you need to include <typeinfo> before using the 'typeid' operator}}
8 namespace std {
9 struct type_info { const char *name; };
12 void g()
14 (void)typeid(int);
17 struct X; // expected-note 3{{forward declaration}}
19 void g1(X &x) {
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'}}
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]'}}
31 // expected-note@+1 {{read of object 'typeid(int).name' whose value is not known}}
32 constexpr const char *name = typeid(int).name; // expected-error {{constant expression}}