]> granicus.if.org Git - clang/commitdiff
Don't try to compute the value of a value-dependent expression when
authorDouglas Gregor <dgregor@apple.com>
Tue, 21 Dec 2010 07:22:56 +0000 (07:22 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 21 Dec 2010 07:22:56 +0000 (07:22 +0000)
checking trivial comparisons. Fixes PR8795.

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

lib/Sema/SemaChecking.cpp
test/SemaTemplate/dependent-expr.cpp

index c75b27c3eccb2db64e3d464e21fa71276b6a9922..75b30fcb769950da2912744a63245ee0e3b8e550 100644 (file)
@@ -2527,6 +2527,9 @@ static bool HasEnumType(Expr *E) {
 
 void CheckTrivialUnsignedComparison(Sema &S, BinaryOperator *E) {
   BinaryOperatorKind op = E->getOpcode();
+  if (E->isValueDependent())
+    return;
+
   if (op == BO_LT && IsZero(S, E->getRHS())) {
     S.Diag(E->getOperatorLoc(), diag::warn_lunsigned_always_true_comparison)
       << "< 0" << "false" << HasEnumType(E->getLHS())
index f26c85b1eccf4efc28038cbdbceb5b72ce4f430a..a1ddd249f7fe0e9f1fa1a60a3326c94a76d5b7ba 100644 (file)
@@ -61,3 +61,13 @@ namespace test5 {
     }
   };
 }
+
+namespace PR8795 {
+  template <class _CharT> int test(_CharT t)
+  {
+    int data [] = {
+      sizeof(_CharT) > sizeof(char)
+    };
+    return data[0];
+  }
+}