1*e45e091bSCongcong Cai // RUN: %check_clang_tidy -check-suffix=DEFAULT %s \ 2*e45e091bSCongcong Cai // RUN: bugprone-narrowing-conversions %t -- 3*e45e091bSCongcong Cai 4*e45e091bSCongcong Cai // RUN: %check_clang_tidy -check-suffix=WARN %s \ 5*e45e091bSCongcong Cai // RUN: bugprone-narrowing-conversions %t -- \ 6*e45e091bSCongcong Cai // RUN: -config='{CheckOptions: { \ 7*e45e091bSCongcong Cai // RUN: bugprone-narrowing-conversions.WarnWithinTemplateInstantiation: 1 \ 8*e45e091bSCongcong Cai // RUN: }}' 9*e45e091bSCongcong Cai 10*e45e091bSCongcong Cai template <typename OrigType> 11*e45e091bSCongcong Cai void assign_in_template(OrigType jj) { 12*e45e091bSCongcong Cai int ii; 13*e45e091bSCongcong Cai ii = jj; 14*e45e091bSCongcong Cai // DEFAULT: Warning disabled because WarnWithinTemplateInstantiation=0. 15*e45e091bSCongcong Cai // CHECK-MESSAGES-WARN: :[[@LINE-2]]:8: warning: narrowing conversion from 'long long' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions] 16*e45e091bSCongcong Cai } 17*e45e091bSCongcong Cai 18*e45e091bSCongcong Cai void narrow_inside_template_not_ok() { 19*e45e091bSCongcong Cai long long j = 123; 20*e45e091bSCongcong Cai assign_in_template(j); 21*e45e091bSCongcong Cai } 22*e45e091bSCongcong Cai 23*e45e091bSCongcong Cai void assign_outside_template(long long jj) { 24*e45e091bSCongcong Cai int ii; 25*e45e091bSCongcong Cai ii = jj; 26*e45e091bSCongcong Cai // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:8: warning: narrowing conversion from 'long long' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions] 27*e45e091bSCongcong Cai // CHECK-MESSAGES-WARN: :[[@LINE-2]]:8: warning: narrowing conversion from 'long long' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions] 28*e45e091bSCongcong Cai } 29*e45e091bSCongcong Cai 30*e45e091bSCongcong Cai void narrow_outside_template_not_ok() { 31*e45e091bSCongcong Cai long long j = 123; 32*e45e091bSCongcong Cai assign_outside_template(j); 33*e45e091bSCongcong Cai } 34