if (!TInfo)
TInfo = Context.getTrivialTypeSourceInfo(Ty, SourceLocation());
- return BuildCXXTypeConstructExpr(TInfo, LParenLoc, exprs, RParenLoc);
+ auto Result = BuildCXXTypeConstructExpr(TInfo, LParenLoc, exprs, RParenLoc);
+ // Avoid creating a non-type-dependent expression that contains typos.
+ // Non-type-dependent expressions are liable to be discarded without
+ // checking for embedded typos.
+ if (!Result.isInvalid() && Result.get()->isInstantiationDependent() &&
+ !Result.get()->isTypeDependent())
+ Result = CorrectDelayedTyposInExpr(Result.get());
+ return Result;
}
/// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
if (T(f()), g, h; f()) {} // expected-error {{not yet supported}}
if (T f(); f()) {} // expected-error {{not yet supported}}
if (T f(), g, h; f()) {} // expected-error {{not yet supported}}
+ if (T(n) = 0; n) {} // expected-error {{not yet supported}}
// init-statement expressions
if (T{f()}; f()) {} // expected-error {{not yet supported}}
if (T(n){g}) {}
if (T f()) {} // expected-error {{function type}}
if (T f(), g, h) {} // expected-error {{function type}}
+ if (T(n) = 0) {}
// condition expressions
if (T(f())) {}
if (T(f()), g, h) {} // expected-warning 2{{unused}}
if (T{f()}, g, h) {} // expected-warning 2{{unused}}
- // none of the above
- // FIXME: This causes a typo-correction crash, as does "void f() { +T(n)(g); }"
- //if (T(n)(g)) {} // expected-err-FIXME {{not a function}}
+ // none of the above, disambiguated as expression (can't be a declaration)
+ if (T(n)(g)) {} // expected-error {{undeclared identifier 'n'}}
+ if (T(n)(int())) {} // expected-error {{undeclared identifier 'n'}}
// Likewise for 'switch'
switch (int n; n) {} // expected-error {{not yet supported}}
// CXXUnresolvedConstructExpr, and the missing ')' gives it an invalid source
// location for its rparen. Check that emitting a diag on the range of the
// expr doesn't assert.
- return int(undeclared, 4; // expected-error {{expected ')'}} expected-note{{to match this '('}} expected-error {{void function 'cxx_unresolved_expr' should not return a value}} expected-error {{use of undeclared identifier 'undeclared'}}
+ return int(undeclared, 4; // expected-error {{expected ')'}} expected-note{{to match this '('}} expected-error {{use of undeclared identifier 'undeclared'}}
}