reapply my patch for PR4451, which improves diagnostics for :: vs : confusion.
This time with a fix to bail out when in a dependent context.

llvm-svn: 90730
diff --git a/clang/test/Parser/cxx-decl.cpp b/clang/test/Parser/cxx-decl.cpp
index 3fa2842..308700e 100644
--- a/clang/test/Parser/cxx-decl.cpp
+++ b/clang/test/Parser/cxx-decl.cpp
@@ -1,3 +1,33 @@
 // RUN: clang-cc -verify -fsyntax-only %s
 
 int x(*g); // expected-error {{use of undeclared identifier 'g'}}
+
+
+// PR4451 - We should recover well from the typo of '::' as ':' in a2.
+namespace y {
+  struct a { };  
+}
+
+y::a a1;
+y:a a2;  // expected-error {{unexpected ':' in nested name specifier}}
+y::a a3 = a2;
+
+// Some valid colons:
+void foo() {
+y:  // label
+  y::a s;
+  
+  int a = 4;
+  a = a ? a : a+1;
+}
+
+struct b : y::a {};
+
+template <typename T>
+class someclass {
+  
+  int bar() {
+    T *P;
+    return 1 ? P->x : P->y;
+  }
+};
diff --git a/clang/test/SemaCXX/nested-name-spec.cpp b/clang/test/SemaCXX/nested-name-spec.cpp
index 83c7241..6a51261 100644
--- a/clang/test/SemaCXX/nested-name-spec.cpp
+++ b/clang/test/SemaCXX/nested-name-spec.cpp
@@ -186,12 +186,10 @@
 };
 
 
-// PR4452
-// FIXME: This error recovery sucks.
-foo<somens:a> a2;  // expected-error {{unexpected namespace name 'somens': expected expression}} \
-expected-error {{C++ requires a type specifier for all declarations}}
+// PR4452 / PR4451
+foo<somens:a> a2;  // expected-error {{unexpected ':' in nested name specifier}}
 
-somens::a a3 = a2;
+somens::a a3 = a2; // expected-error {{cannot initialize 'a3' with an lvalue of type 'foo<somens::a>'}}