From f8b6e1591b5c5085cf4dec8df657e32a68053b12 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 10 Oct 2011 17:38:18 +0000 Subject: [PATCH] Don't analyze comparisons in type- or value-dependent subexpressions. Fixes PR10291. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141552 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaChecking.cpp | 3 +++ test/SemaCXX/warn-unused-comparison.cpp | 24 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 71a7ebcd1c..181d40ba01 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -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(E)) { diff --git a/test/SemaCXX/warn-unused-comparison.cpp b/test/SemaCXX/warn-unused-comparison.cpp index c193462e15..0153f213ba 100644 --- a/test/SemaCXX/warn-unused-comparison.cpp +++ b/test/SemaCXX/warn-unused-comparison.cpp @@ -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 + class X + { + public: + + X() : i(0) { } + + void foo() + { + throw + i == 0u ? + 5 : 6; + } + + private: + int i; + }; + + X x; +} -- 2.40.0