Refactor our handling of expression evaluation contexts, so that Sema
maintains a stack of evaluation contexts rather than having the parser
do it. This change made it simpler to track in which contexts
temporaries were created, so that we could...

"Forget" about temporaries created within unevaluated contexts, so
that we don't build a CXXExprWithTemporaries and, therefore, destroy
the integral-constness of our expressions. Fixes PR5609.

llvm-svn: 89908
diff --git a/clang/test/SemaTemplate/instantiate-static-var.cpp b/clang/test/SemaTemplate/instantiate-static-var.cpp
index 96fa34c..452fccf 100644
--- a/clang/test/SemaTemplate/instantiate-static-var.cpp
+++ b/clang/test/SemaTemplate/instantiate-static-var.cpp
@@ -1,5 +1,4 @@
 // RUN: clang-cc -fsyntax-only -verify %s
-
 template<typename T, T Divisor>
 class X {
 public:
@@ -38,3 +37,38 @@
   DefCon &DC = Z<DefCon>::value;
   NoDefCon &NDC = Z<NoDefCon>::value; // expected-note{{instantiation}}
 }
+
+// PR5609
+struct X1 {
+  ~X1();  // The errors won't be triggered without this dtor.
+};
+
+template <typename T>
+struct Y1 {
+  static char Helper(T);
+  static const int value = sizeof(Helper(T()));
+};
+
+struct X2 {
+  virtual ~X2();
+};
+
+namespace std {
+  class type_info { };
+}
+
+template <typename T>
+struct Y2 {
+  static T &Helper();
+  static const int value = sizeof(typeid(Helper()));
+};
+
+template <int>
+struct Z1 {};
+
+void Test() {
+  Z1<Y1<X1>::value> x;
+  int y[Y1<X1>::value];
+  Z1<Y2<X2>::value> x2;
+  int y2[Y2<X2>::value];
+}