]> granicus.if.org Git - clang/commitdiff
Don't try to evaluate an expression that is type- or value-dependent while building...
authorDouglas Gregor <dgregor@apple.com>
Mon, 24 Aug 2009 21:39:56 +0000 (21:39 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 24 Aug 2009 21:39:56 +0000 (21:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79941 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CFG.cpp
test/SemaTemplate/fun-template-def.cpp

index 08a13c4d8ed3f4cdc420e64ef6a2f719f23a5d64..3677f7ee0d59838b822062461611ed93de04428a 100644 (file)
@@ -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();
index 8833ef4ddc1d1f0703dd74aaa5d32caae8a1f456..dee4250078985664d27cd27d7f829b5aaf4e69c2 100644 (file)
@@ -10,8 +10,13 @@ namespace std { class type_info {}; }
 
 struct dummy {};
 
+template<typename T>
+int f0(T x) {
+  return (sizeof(x) == sizeof(int))? 0 : (sizeof(x) == sizeof(double))? 1 : 2;
+}
+
 template <typename T, typename U>
-T f(T t1, U u1, int i1)
+T f1(T t1, U u1, int i1)
 {
   T t2 = i1;
   t2 = i1 + u1;