forked from OSchip/llvm-project
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:
parent
03e6476693
commit
42118a9524
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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'}}
|
||||
|
|
|
@ -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'{{$}}}}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue