[cfe-commits] r141552 - in /cfe/trunk: lib/Sema/SemaChecking.cpp test/SemaCXX/warn-unused-comparison.cpp

Douglas Gregor dgregor at apple.com
Mon Oct 10 10:38:19 PDT 2011


Author: dgregor
Date: Mon Oct 10 12:38:18 2011
New Revision: 141552

URL: http://llvm.org/viewvc/llvm-project?rev=141552&view=rev
Log:
Don't analyze comparisons in type- or value-dependent
subexpressions. Fixes PR10291.

Modified:
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/test/SemaCXX/warn-unused-comparison.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=141552&r1=141551&r2=141552&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Oct 10 12:38:18 2011
@@ -3472,6 +3472,9 @@
   QualType T = OrigE->getType();
   Expr *E = OrigE->IgnoreParenImpCasts();
 
+  if (E->isTypeDependent() || E->isValueDependent())
+    return;
+
   // For conditional operators, we analyze the arguments as if they
   // were being fed directly into the output.
   if (isa<ConditionalOperator>(E)) {

Modified: cfe/trunk/test/SemaCXX/warn-unused-comparison.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-comparison.cpp?rev=141552&r1=141551&r2=141552&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-unused-comparison.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-comparison.cpp Mon Oct 10 12:38:18 2011
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused -Wunused-comparison %s
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify -Wno-unused -Wunused-comparison %s
 
 struct A {
   bool operator==(const A&);
@@ -70,3 +70,25 @@
   EQ(x, 5);
 #undef EQ
 }
+
+namespace PR10291 {
+  template<typename T>
+  class X
+  {
+  public:
+
+    X() : i(0) { } 
+
+    void foo()
+    {   
+      throw 
+        i == 0u ?
+        5 : 6;
+    }   
+
+  private:
+    int i;
+  };
+
+  X<int> x;
+}





More information about the cfe-commits mailing list