1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -verify -x c++ %s 2*f4a2713aSLionel Sambuc // RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -x c++ %s 2>&1 | FileCheck %s 3*f4a2713aSLionel Sambuc 4*f4a2713aSLionel Sambuc struct S { 5*f4a2713aSLionel Sambuc int n; 6*f4a2713aSLionel Sambuc }; 7*f4a2713aSLionel Sambuc 8*f4a2713aSLionel Sambuc struct T { 9*f4a2713aSLionel Sambuc T(); 10*f4a2713aSLionel Sambuc T(S, S); 11*f4a2713aSLionel Sambuc int n; 12*f4a2713aSLionel Sambuc }; 13*f4a2713aSLionel Sambuc 14*f4a2713aSLionel Sambuc struct U { 15*f4a2713aSLionel Sambuc ~U(); 16*f4a2713aSLionel Sambuc int n; 17*f4a2713aSLionel Sambuc }; 18*f4a2713aSLionel Sambuc 19*f4a2713aSLionel Sambuc struct V { 20*f4a2713aSLionel Sambuc ~V(); 21*f4a2713aSLionel Sambuc }; 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuc struct W : V { 24*f4a2713aSLionel Sambuc }; 25*f4a2713aSLionel Sambuc 26*f4a2713aSLionel Sambuc struct X : U { 27*f4a2713aSLionel Sambuc }; 28*f4a2713aSLionel Sambuc 29*f4a2713aSLionel Sambuc int F1(); 30*f4a2713aSLionel Sambuc S F2(); 31*f4a2713aSLionel Sambuc 32*f4a2713aSLionel Sambuc namespace N { test()33*f4a2713aSLionel Sambuc void test() { 34*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{35:9-35:11}:" = {}" 35*f4a2713aSLionel Sambuc S s1(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} 36*f4a2713aSLionel Sambuc 37*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{39:9-39:10}:";" 38*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{40:7-40:9}:" = {}" 39*f4a2713aSLionel Sambuc S s2, // expected-note {{change this ',' to a ';' to call 'F2'}} 40*f4a2713aSLionel Sambuc F2(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} 41*f4a2713aSLionel Sambuc 42*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{44:9-44:11}:"" 43*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{45:9-45:11}:"" 44*f4a2713aSLionel Sambuc T t1(), // expected-warning {{function declaration}} expected-note {{remove parentheses}} 45*f4a2713aSLionel Sambuc t2(); // expected-warning {{function declaration}} expected-note {{remove parentheses}} 46*f4a2713aSLionel Sambuc 47*f4a2713aSLionel Sambuc // Suggest parentheses only around the first argument. 48*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{50:10-50:10}:"(" 49*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{50:13-50:13}:")" 50*f4a2713aSLionel Sambuc T t3(S(), S()); // expected-warning {{disambiguated as a function declaration}} expected-note {{add a pair of parentheses}} 51*f4a2713aSLionel Sambuc 52*f4a2713aSLionel Sambuc // Check fixit position for pathological case 53*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{56:11-56:11}:"(" 54*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{56:20-56:20}:")" 55*f4a2713aSLionel Sambuc float k[1]; 56*f4a2713aSLionel Sambuc int l(int(k[0])); // expected-warning {{disambiguated as a function declaration}} expected-note {{add a pair of parentheses}} 57*f4a2713aSLionel Sambuc 58*f4a2713aSLionel Sambuc // Don't emit warning and fixit because this must be a function declaration due to void return type. 59*f4a2713aSLionel Sambuc typedef void VO; 60*f4a2713aSLionel Sambuc VO m(int (*p)[4]); 61*f4a2713aSLionel Sambuc 62*f4a2713aSLionel Sambuc // Don't emit warning and fixit because direct initializer is not permitted here. 63*f4a2713aSLionel Sambuc if (int n(int())){} // expected-error {{function type is not allowed here}} expected-error {{condition must have an initializer}} 64*f4a2713aSLionel Sambuc 65*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{66:8-66:10}:" = {}" 66*f4a2713aSLionel Sambuc U u(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} 67*f4a2713aSLionel Sambuc 68*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{69:8-69:10}:"" 69*f4a2713aSLionel Sambuc V v(); // expected-warning {{function declaration}} expected-note {{remove parentheses}} 70*f4a2713aSLionel Sambuc 71*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{72:8-72:10}:"" 72*f4a2713aSLionel Sambuc W w(); // expected-warning {{function declaration}} expected-note {{remove parentheses}} 73*f4a2713aSLionel Sambuc 74*f4a2713aSLionel Sambuc // TODO: Removing the parens here would not initialize U::n. 75*f4a2713aSLionel Sambuc // Maybe suggest an " = X()" initializer for this case? 76*f4a2713aSLionel Sambuc // Maybe suggest removing the parens anyway? 77*f4a2713aSLionel Sambuc X x(); // expected-warning {{function declaration}} 78*f4a2713aSLionel Sambuc 79*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{80:11-80:13}:" = 0" 80*f4a2713aSLionel Sambuc int n1(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} 81*f4a2713aSLionel Sambuc 82*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{84:11-84:12}:";" 83*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{85:7-85:9}:" = 0" 84*f4a2713aSLionel Sambuc int n2, // expected-note {{change this ',' to a ';' to call 'F1'}} 85*f4a2713aSLionel Sambuc F1(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} 86*f4a2713aSLionel Sambuc 87*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{88:13-88:15}:" = 0.0" 88*f4a2713aSLionel Sambuc double d(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} 89*f4a2713aSLionel Sambuc 90*f4a2713aSLionel Sambuc typedef void *Ptr; 91*f4a2713aSLionel Sambuc 92*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{93:10-93:12}:" = 0" 93*f4a2713aSLionel Sambuc Ptr p(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} 94*f4a2713aSLionel Sambuc 95*f4a2713aSLionel Sambuc #define NULL 0 96*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{97:10-97:12}:" = NULL" 97*f4a2713aSLionel Sambuc Ptr p(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} 98*f4a2713aSLionel Sambuc 99*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{100:11-100:13}:" = false" 100*f4a2713aSLionel Sambuc bool b(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} 101*f4a2713aSLionel Sambuc 102*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{103:11-103:13}:" = '\\0'" 103*f4a2713aSLionel Sambuc char c(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} 104*f4a2713aSLionel Sambuc 105*f4a2713aSLionel Sambuc // CHECK: fix-it:"{{.*}}":{106:15-106:17}:" = L'\\0'" 106*f4a2713aSLionel Sambuc wchar_t wc(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} 107*f4a2713aSLionel Sambuc } 108*f4a2713aSLionel Sambuc } 109