]> granicus.if.org Git - clang/commitdiff
Remove more dead code for emitting diagnostics. The callers of these
authorChandler Carruth <chandlerc@gmail.com>
Sun, 1 May 2011 08:41:10 +0000 (08:41 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sun, 1 May 2011 08:41:10 +0000 (08:41 +0000)
functions already precluded dependent types from reaching them.

Also change one of the callers to not error when a trait is applied to
a dependent type. This is a perfectly reasonable pattern, and both Unary
and Binary type traits already support dependent types (by populating
the AST with a nonce value).

Remove the actual diagnostic, since these aren't errors.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130651 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaExprCXX.cpp

index b05e13313e28a19099c87b08022f61f5e6428b91..0a0c91ac9144da33b57ade799bf6860c11aeb205 100644 (file)
@@ -3339,8 +3339,6 @@ def warn_unused_call : Warning<
 
 def err_incomplete_type_used_in_type_trait_expr : Error<
   "incomplete type %0 used in type trait expression">;
-def err_dependent_type_used_in_type_trait_expr : Error<
-  "dependent type %0 used in type trait expression">;
 def err_dimension_expr_not_constant_integer : Error<
   "dimension expression does not evaluate to a constant unsigned int">;
 def err_expected_ident_or_lparen : Error<"expected identifier or '('">;
index 7a7aabeafe44f912ff4d0abfa031015021835cdf..9f1329717f0989047c277cb9ed2b25e6efb60bba 100644 (file)
@@ -2457,8 +2457,7 @@ static bool CheckUnaryTypeTraitTypeCompleteness(Sema &S,
 
 static bool EvaluateUnaryTypeTrait(Sema &Self, UnaryTypeTrait UTT,
                                    SourceLocation KeyLoc, QualType T) {
-  assert(!T->isDependentType() &&
-         "Cannot evaluate type trait on dependent type");
+  assert(!T->isDependentType() && "Cannot evaluate traits of dependent type");
 
   ASTContext &C = Self.Context;
   switch(UTT) {
@@ -2788,14 +2787,8 @@ ExprResult Sema::ActOnBinaryTypeTrait(BinaryTypeTrait BTT,
 static bool EvaluateBinaryTypeTrait(Sema &Self, BinaryTypeTrait BTT,
                                     QualType LhsT, QualType RhsT,
                                     SourceLocation KeyLoc) {
-  if (LhsT->isDependentType()) {
-    Self.Diag(KeyLoc, diag::err_dependent_type_used_in_type_trait_expr) << LhsT;
-    return false;
-  }
-  else if (RhsT->isDependentType()) {
-    Self.Diag(KeyLoc, diag::err_dependent_type_used_in_type_trait_expr) << RhsT;
-    return false;
-  }
+  assert(!LhsT->isDependentType() && !RhsT->isDependentType() &&
+         "Cannot evaluate traits of dependent types");
 
   switch(BTT) {
   case BTT_IsBaseOf: {
@@ -2934,10 +2927,7 @@ ExprResult Sema::ActOnArrayTypeTrait(ArrayTypeTrait ATT,
 static uint64_t EvaluateArrayTypeTrait(Sema &Self, ArrayTypeTrait ATT,
                                            QualType T, Expr *DimExpr,
                                            SourceLocation KeyLoc) {
-  if (T->isDependentType()) {
-    Self.Diag(KeyLoc, diag::err_dependent_type_used_in_type_trait_expr) << T;
-    return false;
-  }
+  assert(!T->isDependentType() && "Cannot evaluate traits of dependent type");
 
   switch(ATT) {
   case ATT_ArrayRank:
@@ -2996,10 +2986,11 @@ ExprResult Sema::BuildArrayTypeTrait(ArrayTypeTrait ATT,
                                      Expr* DimExpr,
                                      SourceLocation RParen) {
   QualType T = TSInfo->getType();
-  if (T->isDependentType())
-    return ExprError();
 
-  uint64_t Value = EvaluateArrayTypeTrait(*this, ATT, T, DimExpr, KWLoc);
+  uint64_t Value = 0;
+  if (!T->isDependentType())
+    Value = EvaluateArrayTypeTrait(*this, ATT, T, DimExpr, KWLoc);
+
   return Owned(new (Context) ArrayTypeTraitExpr(KWLoc, ATT, TSInfo, Value,
                                                 DimExpr, RParen,
                                                 Context.IntTy));