warning: statement was disambiguated as declaration
because it is currently firing in cases where the declaration would
not actually parse as a statement. We'd love to bring this warning
back if we can make it more accurate.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61137
91177308-0d34-0410-b5e6-
96231b3b80d8
"expected '(' for function-style cast or type construction")
DIAG(err_expected_equal_after_declarator, ERROR,
"expected '=' after declarator")
-DIAG(warn_statement_disambiguation, WARNING,
- "statement was disambiguated as %0")
DIAG(warn_parens_disambiguated_as_function_decl, WARNING,
"parentheses were disambiguated as a function declarator")
DIAG(err_expected_member_or_base_name, ERROR,
TPR = TPResult::True();
assert(TPR == TPResult::True() || TPR == TPResult::False());
- if (TPR == TPResult::True() && Tok.isNot(tok::kw_void)) {
- // We have a declaration that looks like a functional cast; there's a high
- // chance that the author intended the statement to be an expression.
- // Emit a warning.
- Diag(Tok, diag::warn_statement_disambiguation)
- << "declaration" << SourceRange(Tok.getLocation(), TentativeParseLoc);
- } else if (TPR == TPResult::False() && Tok.is(tok::kw_void)) {
- // A functional cast to 'void' expression ? Warning..
- Diag(Tok, diag::warn_statement_disambiguation)
- << "expression" << SourceRange(Tok.getLocation(), TentativeParseLoc);
- }
-
return TPR == TPResult::True();
}
// Drop reference. Intentionally without qualifier change.
char *** var5 = const_cast<cppp>(var4);
const int ar[100] = {0};
- int (&rar)[100] = const_cast<iarr>(ar); // expected-warning {{statement was disambiguated as declaration}} expected-error {{const_cast from 'int const [100]' to 'iarr' is not allowed}}
+ int (&rar)[100] = const_cast<iarr>(ar); // expected-error {{const_cast from 'int const [100]' to 'iarr' is not allowed}}
// Array decay. Intentionally without qualifier change.
int *pi = const_cast<int*>(ar);
f fp = 0;
int(a)++; // expected-error {{expression is not assignable}}
__extension__ int(a)++; // expected-error {{expression is not assignable}}
typeof(int)(a,5)<<a; // expected-error {{function-style cast to a builtin type can only take one argument}}
- void(a), ++a; // expected-warning {{statement was disambiguated as expression}} expected-warning {{expression result unused}}
+ void(a), ++a; // expected-warning {{expression result unused}}
if (int(a)+1) {}
for (int(a)+1;;) {}
a = sizeof(int()+1);
// Declarations.
int fd(T(a)); // expected-warning {{parentheses were disambiguated as a function declarator}}
- T(*d)(int(p)); // expected-warning {{parentheses were disambiguated as a function declarator}} expected-warning {{statement was disambiguated as declaration}} expected-note {{previous definition is here}}
- T(d)[5]; // expected-warning {{statement was disambiguated as declaration}} expected-error {{redefinition of 'd'}}
- typeof(int[])(f) = { 1, 2 }; // expected-warning {{statement was disambiguated as declaration}}
+ T(*d)(int(p)); // expected-warning {{parentheses were disambiguated as a function declarator}} expected-note {{previous definition is here}}
+ T(d)[5]; // expected-error {{redefinition of 'd'}}
+ typeof(int[])(f) = { 1, 2 };
void(b)(int);
- int(d2) __attribute__(()); // expected-warning {{statement was disambiguated as declaration}}
+ int(d2) __attribute__(());
if (int(a)=1) {}
- int(d3(int())); // expected-warning {{statement was disambiguated as declaration}}
+ int(d3(int()));
}
class C { };
void f() {
int x(1);
- int (x2)(1); // expected-warning {{statement was disambiguated as declaration}}
+ int (x2)(1);
for (int x(1);;) {}
}
r = 1;
int *p = &r;
int &rr = r;
- int (&rg)(int) = g; // expected-warning{{statement was disambiguated as declaration}}
+ int (&rg)(int) = g;
rg(i);
int a[3];
- int (&ra)[3] = a; // expected-warning{{statement was disambiguated as declaration}}
+ int (&ra)[3] = a;
ra[1] = i;
int *Q;
int *& P = Q;
int c[3];
- int (&rc)[3] = c; // expected-warning{{statement was disambiguated as declaration}}
+ int (&rc)[3] = c;
}
// C++ [dcl.init.ref]p5b1