Handle OpaqueValueExprs more intelligently in the TransformTypos tree

transform.

Also diagnose typos in the initializer of an invalid C++ declaration.
Both issues were hit using the same line of test code, depending on
whether the code was treated as C or C++.

Fixes PR22092.

llvm-svn: 225389
This commit is contained in:
Kaelyn Takata 2015-01-07 21:16:39 +00:00
parent 03e6476693
commit 42118a9524
4 changed files with 17 additions and 1 deletions

View File

@ -8574,8 +8574,10 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init,
bool DirectInit, bool TypeMayContainAuto) {
// If there is no declaration, there was an error parsing it. Just ignore
// the initializer.
if (!RealDecl || RealDecl->isInvalidDecl())
if (!RealDecl || RealDecl->isInvalidDecl()) {
CorrectDelayedTyposInExpr(Init);
return;
}
if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(RealDecl)) {
// With declarators parsed the way they are, the parser cannot

View File

@ -6141,6 +6141,12 @@ public:
ExprResult TransformLambdaExpr(LambdaExpr *E) { return Owned(E); }
ExprResult TransformOpaqueValueExpr(OpaqueValueExpr *E) {
if (Expr *SE = E->getSourceExpr())
return TransformExpr(SE);
return BaseTransform::TransformOpaqueValueExpr(E);
}
ExprResult Transform(Expr *E) {
ExprResult Res;
while (true) {

View File

@ -9,3 +9,6 @@ void PR21656() {
float x;
x = (float)arst; // expected-error-re {{use of undeclared identifier 'arst'{{$}}}}
}
a = b ? : 0; // expected-warning {{type specifier missing, defaults to 'int'}} \
// expected-error {{use of undeclared identifier 'b'}}

View File

@ -152,3 +152,8 @@ namespace PR21947 {
int blue; // expected-note {{'blue' declared here}}
__typeof blur y; // expected-error {{use of undeclared identifier 'blur'; did you mean 'blue'?}}
}
namespace PR22092 {
a = b ? : 0; // expected-error {{C++ requires a type specifier for all declarations}} \
// expected-error-re {{use of undeclared identifier 'b'{{$}}}}
}