]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp
Vendor import of clang trunk r290819:
[FreeBSD/FreeBSD.git] / test / CXX / dcl.decl / dcl.init / dcl.init.list / p7-0x-fixits.cpp
1 // RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wc++11-compat -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
2
3 // Verify that the appropriate fixits are emitted for narrowing conversions in
4 // initializer lists.
5
6 typedef short int16_t;
7
8 void fixits() {
9   int x = 999;
10   struct {char c;} c2 = {x};
11   // CHECK: warning:{{.*}} cannot be narrowed
12   // CHECK: fix-it:{{.*}}:26}:"static_cast<char>("
13   // CHECK: fix-it:{{.*}}:27}:")"
14   struct {int16_t i;} i16 = {70000};
15   // CHECK: warning:{{.*}} cannot be narrowed
16   // CHECK: fix-it:{{.*}}:30}:"static_cast<int16_t>("
17   // CHECK: fix-it:{{.*}}:35}:")"
18 }
19
20 template<typename T>
21 void maybe_shrink_int(T t) {
22   struct {T t;} t2 = {700};
23 }
24
25 void test_template() {
26   maybe_shrink_int((char)3);
27   // CHECK: warning:{{.*}} cannot be narrowed
28   // CHECK: note:{{.*}} in instantiation
29   // CHECK: note:{{.*}} silence
30   // FIXME: This should be static_cast<T>.
31   // CHECK: fix-it:{{.*}}"static_cast<char>("
32   // CHECK: fix-it:{{.*}}")"
33 }