Implement template instantiation for the prefix unary operators. As
always, refactored the existing logic to tease apart the parser action
and the semantic analysis shared by the parser and template
instantiation.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66987 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaTemplate/instantiate-expr-1.cpp b/test/SemaTemplate/instantiate-expr-1.cpp
index 869d558..2ea0641 100644
--- a/test/SemaTemplate/instantiate-expr-1.cpp
+++ b/test/SemaTemplate/instantiate-expr-1.cpp
@@ -53,3 +53,19 @@
   (void)sizeof(BitfieldDep<int, 1, 5>);
 }
 
+template<int I>
+struct BitfieldNeg {
+  int bitfield : (-I); // expected-error{{bit-field 'bitfield' has negative width (-5)}}
+};
+
+template<typename T, T I>
+struct BitfieldNeg2 {
+  int bitfield : (-I); // expected-error{{bit-field 'bitfield' has negative width (-5)}}
+};
+
+void test_BitfieldNeg() {
+  (void)sizeof(BitfieldNeg<-5>); // okay
+  (void)sizeof(BitfieldNeg<5>); // expected-note{{in instantiation of template class 'struct BitfieldNeg<5>' requested here}}
+  (void)sizeof(BitfieldNeg2<int, -5>); // okay
+  (void)sizeof(BitfieldNeg2<int, 5>); // expected-note{{in instantiation of template class 'struct BitfieldNeg2<int, 5>' requested here}}
+}
diff --git a/test/SemaTemplate/instantiate-expr-2.cpp b/test/SemaTemplate/instantiate-expr-2.cpp
index 81af573..d90cef5 100644
--- a/test/SemaTemplate/instantiate-expr-2.cpp
+++ b/test/SemaTemplate/instantiate-expr-2.cpp
@@ -50,3 +50,18 @@
   ZZ *zz = a8;
 }
 
+namespace N3 {
+  eight_bytes operator-(::N3::Z);
+}
+
+namespace N4 {
+  template<typename T>
+  struct UnaryOpOverload {
+    typedef A<sizeof(-T())> type;
+  };
+}
+
+void test_unary_op_overload(A<8> *a8) {
+  typedef N4::UnaryOpOverload<N3::Z>::type UZ;
+  UZ *uz = a8;
+}