43 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s 2// RUN: %clang_cc1 -fsyntax-only -verify -std=gnu++98 %s 3// RUN: %clang_cc1 -fsyntax-only -verify -std=gnu++11 %s 4 5void f() {6 float v1 = float(1);7 int v2 = typeof(int)(1,2); // expected-error {{excess elements in scalar initializer}}8 typedef int arr[];9 arr(); // expected-error {{array types cannot be value-initialized}}10 typedef void fn_ty();11 fn_ty(); // expected-error {{cannot create object of function type 'fn_ty'}}12 fn_ty(0); // expected-error {{functional-style cast from 'int' to 'fn_ty'}}13 fn_ty(0, 0); // expected-error {{cannot create object of function type 'fn_ty'}}14#if __cplusplus >= 201103L15 fn_ty{}; // expected-error {{cannot create object of function type 'fn_ty'}}16 fn_ty{0}; // expected-error {{cannot create object of function type 'fn_ty'}}17 fn_ty{0, 0}; // expected-error {{cannot create object of function type 'fn_ty'}}18 fn_ty({}); // expected-error {{cannot create object of function type 'fn_ty'}}19#endif20 int v4 = int();21 int v5 = int; // expected-error {{expected '(' for function-style cast or type construction}}22 typedef int T;23 int *p;24 bool v6 = T(0) == p;25#if __cplusplus >= 201103L26 // expected-error@-2 {{comparison between pointer and integer ('T' (aka 'int') and 'int *')}}27#endif28 char *str;29 str = "a string";30#if __cplusplus <= 199711L31 // expected-warning@-2 {{conversion from string literal to 'char *' is deprecated}}32#else33 // expected-warning@-4 {{ISO C++11 does not allow conversion from string literal to 'char *'}}34#endif35 wchar_t *wstr;36 wstr = L"a wide string";37#if __cplusplus <= 199711L38 // expected-warning@-2 {{conversion from string literal to 'wchar_t *' is deprecated}}39#else40 // expected-warning@-4 {{ISO C++11 does not allow conversion from string literal to 'wchar_t *'}}41#endif42}43