From 4c95288f649dc553809a4b490477e9a7dda8015f Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 24 Aug 2009 21:39:56 +0000 Subject: [PATCH] Don't try to evaluate an expression that is type- or value-dependent while building the CFG llvm-svn: 79941 --- clang/lib/Analysis/CFG.cpp | 3 ++- clang/test/SemaTemplate/fun-template-def.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index 08a13c4d8ed3..3677f7ee0d59 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -158,7 +158,8 @@ private: /// if we can evaluate to a known value, otherwise return -1. TryResult TryEvaluateBool(Expr *S) { Expr::EvalResult Result; - if (S->Evaluate(Result, *Context) && Result.Val.isInt()) + if (!S->isTypeDependent() && !S->isValueDependent() && + S->Evaluate(Result, *Context) && Result.Val.isInt()) return Result.Val.getInt().getBoolValue(); return TryResult(); diff --git a/clang/test/SemaTemplate/fun-template-def.cpp b/clang/test/SemaTemplate/fun-template-def.cpp index 8833ef4ddc1d..dee425007898 100644 --- a/clang/test/SemaTemplate/fun-template-def.cpp +++ b/clang/test/SemaTemplate/fun-template-def.cpp @@ -10,8 +10,13 @@ namespace std { class type_info {}; } struct dummy {}; +template +int f0(T x) { + return (sizeof(x) == sizeof(int))? 0 : (sizeof(x) == sizeof(double))? 1 : 2; +} + template -T f(T t1, U u1, int i1) +T f1(T t1, U u1, int i1) { T t2 = i1; t2 = i1 + u1;