diff options
author | Ilya Biryukov <ibiryukov@google.com> | 2019-07-18 11:55:33 +0000 |
---|---|---|
committer | Ilya Biryukov <ibiryukov@google.com> | 2019-07-18 11:55:33 +0000 |
commit | 10837c359218716121413d25701edecde5266b29 (patch) | |
tree | 7837144159736f95b0f4192ddb3c7eb1ede89889 /lib/Sema/SemaDeclCXX.cpp | |
parent | b3906884072df69838ffece1d7d85012ddca3501 (diff) | |
download | clang-10837c359218716121413d25701edecde5266b29.tar.gz |
Revert r366422: [OpenCL] Improve destructor support in C++ for OpenCL
Reason: this commit causes crashes in the clang compiler when building
LLVM Support with libc++, see https://bugs.llvm.org/show_bug.cgi?id=42665
for details.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@366429 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclCXX.cpp')
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 9a6385f283..dd77fc5572 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -8190,27 +8190,6 @@ void Sema::ActOnFinishDelayedCXXMethodDeclaration(Scope *S, Decl *MethodD) { CheckCXXDefaultArguments(Method); } -// Emit the given diagnostic for each non-address-space qualifier. -// Common part of CheckConstructorDeclarator and CheckDestructorDeclarator. -static void checkMethodTypeQualifiers(Sema &S, Declarator &D, unsigned DiagID) { - const DeclaratorChunk::FunctionTypeInfo &FTI = D.getFunctionTypeInfo(); - if (FTI.hasMethodTypeQualifiers() && !D.isInvalidType()) { - bool DiagOccured = false; - FTI.MethodQualifiers->forEachQualifier( - [DiagID, &S, &DiagOccured](DeclSpec::TQ, StringRef QualName, - SourceLocation SL) { - // This diagnostic should be emitted on any qualifier except an addr - // space qualifier. However, forEachQualifier currently doesn't visit - // addr space qualifiers, so there's no way to write this condition - // right now; we just diagnose on everything. - S.Diag(SL, DiagID) << QualName << SourceRange(SL); - DiagOccured = true; - }); - if (DiagOccured) - D.setInvalidType(); - } -} - /// CheckConstructorDeclarator - Called by ActOnDeclarator to check /// the well-formedness of the constructor declarator @p D with type @p /// R. If there are any errors in the declarator, this routine will @@ -8251,11 +8230,25 @@ QualType Sema::CheckConstructorDeclarator(Declarator &D, QualType R, D.setInvalidType(); } - checkMethodTypeQualifiers(*this, D, diag::err_invalid_qualified_constructor); + DeclaratorChunk::FunctionTypeInfo &FTI = D.getFunctionTypeInfo(); + if (FTI.hasMethodTypeQualifiers()) { + bool DiagOccured = false; + FTI.MethodQualifiers->forEachQualifier( + [&](DeclSpec::TQ TypeQual, StringRef QualName, SourceLocation SL) { + // This diagnostic should be emitted on any qualifier except an addr + // space qualifier. However, forEachQualifier currently doesn't visit + // addr space qualifiers, so there's no way to write this condition + // right now; we just diagnose on everything. + Diag(SL, diag::err_invalid_qualified_constructor) + << QualName << SourceRange(SL); + DiagOccured = true; + }); + if (DiagOccured) + D.setInvalidType(); + } // C++0x [class.ctor]p4: // A constructor shall not be declared with a ref-qualifier. - DeclaratorChunk::FunctionTypeInfo &FTI = D.getFunctionTypeInfo(); if (FTI.hasRefQualifier()) { Diag(FTI.getRefQualifierLoc(), diag::err_ref_qualifier_constructor) << FTI.RefQualifierIsLValueRef @@ -8430,11 +8423,18 @@ QualType Sema::CheckDestructorDeclarator(Declarator &D, QualType R, } } - checkMethodTypeQualifiers(*this, D, diag::err_invalid_qualified_destructor); + DeclaratorChunk::FunctionTypeInfo &FTI = D.getFunctionTypeInfo(); + if (FTI.hasMethodTypeQualifiers() && !D.isInvalidType()) { + FTI.MethodQualifiers->forEachQualifier( + [&](DeclSpec::TQ TypeQual, StringRef QualName, SourceLocation SL) { + Diag(SL, diag::err_invalid_qualified_destructor) + << QualName << SourceRange(SL); + }); + D.setInvalidType(); + } // C++0x [class.dtor]p2: // A destructor shall not be declared with a ref-qualifier. - DeclaratorChunk::FunctionTypeInfo &FTI = D.getFunctionTypeInfo(); if (FTI.hasRefQualifier()) { Diag(FTI.getRefQualifierLoc(), diag::err_ref_qualifier_destructor) << FTI.RefQualifierIsLValueRef |