diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 10 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 28 |
5 files changed, 26 insertions, 22 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 1480b3ea57..d1cc73c3f8 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -4452,7 +4452,7 @@ bool Sema::CheckVariableDeclaration(VarDecl *NewVD, if (NewVD->isConstexpr() && !T->isDependentType() && RequireLiteralType(NewVD->getLocation(), T, - PDiag(diag::err_constexpr_var_non_literal))) { + diag::err_constexpr_var_non_literal)) { NewVD->setInvalidDecl(); return false; } diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 5e466adc5f..c35b8af85f 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -667,9 +667,9 @@ static bool CheckConstexprParameterTypes(Sema &SemaRef, SourceLocation ParamLoc = PD->getLocation(); if (!(*i)->isDependentType() && SemaRef.RequireLiteralType(ParamLoc, *i, - SemaRef.PDiag(diag::err_constexpr_non_literal_param) - << ArgIndex+1 << PD->getSourceRange() - << isa<CXXConstructorDecl>(FD))) + diag::err_constexpr_non_literal_param, + ArgIndex+1, PD->getSourceRange(), + isa<CXXConstructorDecl>(FD))) return false; } return true; @@ -725,7 +725,7 @@ bool Sema::CheckConstexprFunctionDecl(const FunctionDecl *NewFD) { QualType RT = NewFD->getResultType(); if (!RT->isDependentType() && RequireLiteralType(NewFD->getLocation(), RT, - PDiag(diag::err_constexpr_non_literal_return))) + diag::err_constexpr_non_literal_return)) return false; } @@ -3762,7 +3762,7 @@ void Sema::CheckCompletedCXXClass(CXXRecordDecl *Record) { case TSK_Undeclared: case TSK_ExplicitSpecialization: RequireLiteralType(M->getLocation(), Context.getRecordType(Record), - PDiag(diag::err_constexpr_method_non_literal)); + diag::err_constexpr_method_non_literal); break; } diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index ce4bffa1cb..3af9ab42c3 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -10663,7 +10663,7 @@ bool Sema::CheckCallReturnType(QualType ReturnType, SourceLocation Loc, return false; } - class CallReturnIncompleteDiagnoser : public IncompleteTypeDiagnoser { + class CallReturnIncompleteDiagnoser : public TypeDiagnoser { FunctionDecl *FD; CallExpr *CE; diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index a3a963f356..fb8ab47df6 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -5061,11 +5061,11 @@ Sema::ConvertToIntegralOrEnumerationType(SourceLocation Loc, Expr *From, } // We must have a complete class type. - struct IncompleteTypeDiagnoserPartialDiag : IncompleteTypeDiagnoser { + struct TypeDiagnoserPartialDiag : TypeDiagnoser { const PartialDiagnostic &PD; - IncompleteTypeDiagnoserPartialDiag(const PartialDiagnostic &PD) - : IncompleteTypeDiagnoser(PD.getDiagID() == 0), PD(PD) {} + TypeDiagnoserPartialDiag(const PartialDiagnostic &PD) + : TypeDiagnoser(PD.getDiagID() == 0), PD(PD) {} virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) { S.Diag(Loc, PD) << T; diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index c81ace1287..09e4ec8375 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -4048,7 +4048,7 @@ static void processTypeAttrs(TypeProcessingState &state, QualType &type, /// /// \returns \c true if the type of \p E is incomplete and diagnosed, \c false /// otherwise. -bool Sema::RequireCompleteExprType(Expr *E, IncompleteTypeDiagnoser &Diagnoser){ +bool Sema::RequireCompleteExprType(Expr *E, TypeDiagnoser &Diagnoser){ QualType T = E->getType(); // Fast path the case where the type is already complete. @@ -4109,11 +4109,11 @@ bool Sema::RequireCompleteExprType(Expr *E, IncompleteTypeDiagnoser &Diagnoser){ } namespace { - struct IncompleteTypeDiagnoserDiag : Sema::IncompleteTypeDiagnoser { + struct TypeDiagnoserDiag : Sema::TypeDiagnoser { unsigned DiagID; - IncompleteTypeDiagnoserDiag(unsigned DiagID) - : Sema::IncompleteTypeDiagnoser(DiagID == 0), DiagID(DiagID) {} + TypeDiagnoserDiag(unsigned DiagID) + : Sema::TypeDiagnoser(DiagID == 0), DiagID(DiagID) {} virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) { if (Suppressed) return; @@ -4123,7 +4123,7 @@ namespace { } bool Sema::RequireCompleteExprType(Expr *E, unsigned DiagID) { - IncompleteTypeDiagnoserDiag Diagnoser(DiagID); + TypeDiagnoserDiag Diagnoser(DiagID); return RequireCompleteExprType(E, Diagnoser); } @@ -4148,7 +4148,7 @@ bool Sema::RequireCompleteExprType(Expr *E, unsigned DiagID) { /// @returns @c true if @p T is incomplete and a diagnostic was emitted, /// @c false otherwise. bool Sema::RequireCompleteType(SourceLocation Loc, QualType T, - IncompleteTypeDiagnoser &Diagnoser) { + TypeDiagnoser &Diagnoser) { // FIXME: Add this assertion to make sure we always get instantiation points. // assert(!Loc.isInvalid() && "Invalid location in RequireCompleteType"); // FIXME: Add this assertion to help us flush out problems with @@ -4257,7 +4257,7 @@ bool Sema::RequireCompleteType(SourceLocation Loc, QualType T, bool Sema::RequireCompleteType(SourceLocation Loc, QualType T, unsigned DiagID) { - IncompleteTypeDiagnoserDiag Diagnoser(DiagID); + TypeDiagnoserDiag Diagnoser(DiagID); return RequireCompleteType(Loc, T, Diagnoser); } @@ -4275,13 +4275,12 @@ bool Sema::RequireCompleteType(SourceLocation Loc, QualType T, /// /// @param T The type that this routine is examining for literalness. /// -/// @param PD The partial diagnostic that will be printed out if T is not a -/// literal type. +/// @param Diagnoser Emits a diagnostic if T is not a literal type. /// /// @returns @c true if @p T is not a literal type and a diagnostic was emitted, /// @c false otherwise. bool Sema::RequireLiteralType(SourceLocation Loc, QualType T, - const PartialDiagnostic &PD) { + TypeDiagnoser &Diagnoser) { assert(!T->isDependentType() && "type should not be dependent"); QualType ElemType = Context.getBaseElementType(T); @@ -4290,10 +4289,10 @@ bool Sema::RequireLiteralType(SourceLocation Loc, QualType T, if (T->isLiteralType()) return false; - if (PD.getDiagID() == 0) + if (Diagnoser.Suppressed) return true; - Diag(Loc, PD) << T; + Diagnoser.diagnose(*this, Loc, T); if (T->isVariableArrayType()) return true; @@ -4362,6 +4361,11 @@ bool Sema::RequireLiteralType(SourceLocation Loc, QualType T, return true; } +bool Sema::RequireLiteralType(SourceLocation Loc, QualType T, unsigned DiagID) { + TypeDiagnoserDiag Diagnoser(DiagID); + return RequireLiteralType(Loc, T, Diagnoser); +} + /// \brief Retrieve a version of the type 'T' that is elaborated by Keyword /// and qualified by the nested-name-specifier contained in SS. QualType Sema::getElaboratedType(ElaboratedTypeKeyword Keyword, |