brintos

brintos / llvm-project-archived public Read only

0
0
Text · 977 B · d66494f Raw
34 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wc++11-compat -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s2 3// Verify that the appropriate fixits are emitted for narrowing conversions in4// initializer lists.5 6typedef short int16_t;7 8void fixits() {9  int x = 999;10  struct {char c;} c2 = {x};11  // CHECK: warning:{{.*}} cannot be narrowed12  // CHECK: fix-it:{{.*}}:26}:"static_cast<char>("13  // CHECK: fix-it:{{.*}}:27}:")"14  struct {int16_t i;} i16 = {70000};15  // CHECK: warning:{{.*}} cannot be narrowed16  // CHECK: fix-it:{{.*}}:30}:"static_cast<int16_t>("17  // CHECK: fix-it:{{.*}}:35}:")"18}19 20template<typename T>21void maybe_shrink_int(T t) {22  struct {T t;} t2 = {700};23}24 25void test_template() {26  maybe_shrink_int((char)3);27  // CHECK: warning:{{.*}} cannot be narrowed28  // CHECK: note:{{.*}} in instantiation29  // CHECK: note:{{.*}} silence30  // FIXME: This should be static_cast<T>.31  // CHECK: fix-it:{{.*}}"static_cast<char>("32  // CHECK: fix-it:{{.*}}")"33}34