diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 6 | ||||
-rw-r--r-- | clang/test/Sema/typo-correction.c | 3 | ||||
-rw-r--r-- | clang/test/SemaCXX/typo-correction-delayed.cpp | 5 |
4 files changed, 17 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 7264d82774c..3af60cf2992 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -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 diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 1e692ebe253..6351b7d115f 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -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) { diff --git a/clang/test/Sema/typo-correction.c b/clang/test/Sema/typo-correction.c index 04cf0775f1d..e4d14654cc9 100644 --- a/clang/test/Sema/typo-correction.c +++ b/clang/test/Sema/typo-correction.c @@ -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'}} diff --git a/clang/test/SemaCXX/typo-correction-delayed.cpp b/clang/test/SemaCXX/typo-correction-delayed.cpp index 49bb14fe8ce..e028faad251 100644 --- a/clang/test/SemaCXX/typo-correction-delayed.cpp +++ b/clang/test/SemaCXX/typo-correction-delayed.cpp @@ -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'{{$}}}} +} |