diff --git a/clang/lib/AST/ByteCode/Source.cpp b/clang/lib/AST/ByteCode/Source.cpp index 55296ddd8c558..d4ce7537f3d24 100644 --- a/clang/lib/AST/ByteCode/Source.cpp +++ b/clang/lib/AST/ByteCode/Source.cpp @@ -33,7 +33,7 @@ SourceRange SourceInfo::getRange() const { } const Expr *SourceInfo::asExpr() const { - if (const auto *S = dyn_cast(Source)) + if (const auto *S = dyn_cast_if_present(Source)) return dyn_cast(S); return nullptr; } diff --git a/clang/lib/AST/ByteCode/Source.h b/clang/lib/AST/ByteCode/Source.h index 3b025535d00b1..c74cda919347c 100644 --- a/clang/lib/AST/ByteCode/Source.h +++ b/clang/lib/AST/ByteCode/Source.h @@ -83,8 +83,12 @@ class SourceInfo final { SourceLocation getLoc() const; SourceRange getRange() const; - const Stmt *asStmt() const { return dyn_cast(Source); } - const Decl *asDecl() const { return dyn_cast(Source); } + const Stmt *asStmt() const { + return dyn_cast_if_present(Source); + } + const Decl *asDecl() const { + return dyn_cast_if_present(Source); + } const Expr *asExpr() const; operator bool() const { return !Source.isNull(); } diff --git a/clang/test/SemaCXX/lambda-expressions.cpp b/clang/test/SemaCXX/lambda-expressions.cpp index acf8d014a9896..f3deb6ee3f424 100644 --- a/clang/test/SemaCXX/lambda-expressions.cpp +++ b/clang/test/SemaCXX/lambda-expressions.cpp @@ -3,6 +3,11 @@ // RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify=expected,not-cxx03,expected-cxx14 -fblocks %s // RUN: %clang_cc1 -std=c++17 -Wno-unused-value -verify=expected,not-cxx03 -ast-dump -fblocks %s | FileCheck %s +// RUN: %clang_cc1 -std=c++11 -Wno-unused-value -fsyntax-only -verify=expected,not-cxx03,cxx03-cxx11,cxx11,expected-cxx14 -fblocks %s -fexperimental-new-constant-interpreter +// RUN: %clang_cc1 -std=c++03 -Wno-unused-value -fsyntax-only -verify=expected,cxx03,cxx03-cxx11,expected-cxx14 -fblocks %s -Ddecltype=__decltype -Dstatic_assert=_Static_assert -Wno-c++11-extensions -fexperimental-new-constant-interpreter +// RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify=expected,not-cxx03,expected-cxx14 -fblocks %s -fexperimental-new-constant-interpreter +// RUN: %clang_cc1 -std=c++17 -Wno-unused-value -verify=expected,not-cxx03 -ast-dump -fblocks %s -fexperimental-new-constant-interpreter| FileCheck %s + namespace std { class type_info; }; namespace ExplicitCapture {