diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-18 21:39:00 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-18 21:39:00 +0000 |
commit | 6b13022faef260c8f49d04310f4a2c0a57f9103b (patch) | |
tree | cc35ab7ebea5a8d08d890d96494bfa1fa1918da5 /lib | |
parent | 097f6b008254dc7b7f89ec3daafc163bf2a0e307 (diff) | |
download | clang-6b13022faef260c8f49d04310f4a2c0a57f9103b.tar.gz |
-Wc++98-compat and -Wc++98-compat-pedantic warnings for Sema, part 2.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142426 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaCXXScopeSpec.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 67 | ||||
-rw-r--r-- | lib/Sema/SemaInit.cpp | 13 |
3 files changed, 45 insertions, 37 deletions
diff --git a/lib/Sema/SemaCXXScopeSpec.cpp b/lib/Sema/SemaCXXScopeSpec.cpp index 360a0404b8..a9b6536e7d 100644 --- a/lib/Sema/SemaCXXScopeSpec.cpp +++ b/lib/Sema/SemaCXXScopeSpec.cpp @@ -268,7 +268,7 @@ bool Sema::isAcceptableNestedNameSpecifier(NamedDecl *SD) { if (!isa<TypeDecl>(SD)) return false; - // Determine whether we have a class (or, in C++0x, an enum) or + // Determine whether we have a class (or, in C++11, an enum) or // a typedef thereof. If so, build the nested-name-specifier. QualType T = Context.getTypeDeclType(cast<TypeDecl>(SD)); if (T->isDependentType()) diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 528c4ddbc3..951ea9ccfd 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -9652,39 +9652,46 @@ FriendDecl *Sema::CheckFriendTypeDecl(SourceLocation FriendLoc, QualType T = TSInfo->getType(); SourceRange TypeRange = TSInfo->getTypeLoc().getLocalSourceRange(); - if (!getLangOptions().CPlusPlus0x) { - // C++03 [class.friend]p2: - // An elaborated-type-specifier shall be used in a friend declaration - // for a class.* - // - // * The class-key of the elaborated-type-specifier is required. - if (!ActiveTemplateInstantiations.empty()) { - // Do not complain about the form of friend template types during - // template instantiation; we will already have complained when the - // template was declared. - } else if (!T->isElaboratedTypeSpecifier()) { - // If we evaluated the type to a record type, suggest putting - // a tag in front. - if (const RecordType *RT = T->getAs<RecordType>()) { - RecordDecl *RD = RT->getDecl(); - - std::string InsertionText = std::string(" ") + RD->getKindName(); - - Diag(TypeRange.getBegin(), diag::ext_unelaborated_friend_type) - << (unsigned) RD->getTagKind() - << T - << FixItHint::CreateInsertion(PP.getLocForEndOfToken(FriendLoc), - InsertionText); - } else { - Diag(FriendLoc, diag::ext_nonclass_type_friend) - << T - << SourceRange(FriendLoc, TypeRange.getEnd()); - } - } else if (T->getAs<EnumType>()) { - Diag(FriendLoc, diag::ext_enum_friend) + // C++03 [class.friend]p2: + // An elaborated-type-specifier shall be used in a friend declaration + // for a class.* + // + // * The class-key of the elaborated-type-specifier is required. + if (!ActiveTemplateInstantiations.empty()) { + // Do not complain about the form of friend template types during + // template instantiation; we will already have complained when the + // template was declared. + } else if (!T->isElaboratedTypeSpecifier()) { + // If we evaluated the type to a record type, suggest putting + // a tag in front. + if (const RecordType *RT = T->getAs<RecordType>()) { + RecordDecl *RD = RT->getDecl(); + + std::string InsertionText = std::string(" ") + RD->getKindName(); + + Diag(TypeRange.getBegin(), + getLangOptions().CPlusPlus0x ? + diag::warn_cxx98_compat_unelaborated_friend_type : + diag::ext_unelaborated_friend_type) + << (unsigned) RD->getTagKind() + << T + << FixItHint::CreateInsertion(PP.getLocForEndOfToken(FriendLoc), + InsertionText); + } else { + Diag(FriendLoc, + getLangOptions().CPlusPlus0x ? + diag::warn_cxx98_compat_nonclass_type_friend : + diag::ext_nonclass_type_friend) << T << SourceRange(FriendLoc, TypeRange.getEnd()); } + } else if (T->getAs<EnumType>()) { + Diag(FriendLoc, + getLangOptions().CPlusPlus0x ? + diag::warn_cxx98_compat_enum_friend : + diag::ext_enum_friend) + << T + << SourceRange(FriendLoc, TypeRange.getEnd()); } // C++0x [class.friend]p3: diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index f449c7d70d..b96d168a97 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -902,12 +902,13 @@ void InitListChecker::CheckScalarType(const InitializedEntity &Entity, InitListExpr *StructuredList, unsigned &StructuredIndex) { if (Index >= IList->getNumInits()) { - if (!SemaRef.getLangOptions().CPlusPlus0x) { - if (!VerifyOnly) - SemaRef.Diag(IList->getLocStart(), diag::err_empty_scalar_initializer) - << IList->getSourceRange(); - hadError = true; - } + if (!VerifyOnly) + SemaRef.Diag(IList->getLocStart(), + SemaRef.getLangOptions().CPlusPlus0x ? + diag::warn_cxx98_compat_empty_scalar_initializer : + diag::err_empty_scalar_initializer) + << IList->getSourceRange(); + hadError = !SemaRef.getLangOptions().CPlusPlus0x; ++Index; ++StructuredIndex; return; |