]> granicus.if.org Git - clang/commitdiff
Don't analyze comparisons in type- or value-dependent
authorDouglas Gregor <dgregor@apple.com>
Mon, 10 Oct 2011 17:38:18 +0000 (17:38 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 10 Oct 2011 17:38:18 +0000 (17:38 +0000)
subexpressions. Fixes PR10291.

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

lib/Sema/SemaChecking.cpp
test/SemaCXX/warn-unused-comparison.cpp

index 71a7ebcd1cf582418650b77c44a732996fe69dc2..181d40ba0148c41924fc71988a1843364483f841 100644 (file)
@@ -3472,6 +3472,9 @@ void AnalyzeImplicitConversions(Sema &S, Expr *OrigE, SourceLocation CC) {
   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)) {
index c193462e15c83c0a91b3e58f81a6d4fc1fa594fd..0153f213ba1fccb50770a6603ad8371eb0f94b7f 100644 (file)
@@ -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 @@ void test() {
   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;
+}