Fix parsing of trailing-return-type. Types are syntactically prohibited from
being defined here: [] () -> struct S {} does not define struct S.

In passing, implement DR1318 (syntactic disambiguation of 'final').


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152551 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Parser/cxx0x-ambig.cpp b/test/Parser/cxx0x-ambig.cpp
index c955dc1..b77bae5 100644
--- a/test/Parser/cxx0x-ambig.cpp
+++ b/test/Parser/cxx0x-ambig.cpp
@@ -5,15 +5,24 @@
 // final 'context sensitive' mess.
 namespace final {
   struct S { int n; };
+  struct T { int n; };
   namespace N {
     int n;
+    // These declare variables named final..
+    extern struct S final;
+    extern struct S final [[]];
+    extern struct S final, foo;
+    struct S final = S();
+
     // This defines a class, not a variable, even though it would successfully
     // parse as a variable but not as a class. DR1318's wording suggests that
     // this disambiguation is only performed on an ambiguity, but that was not
     // the intent.
-    struct S final {
+    struct S final { // expected-note {{here}}
       int(n) // expected-error {{expected ';'}}
     };
+    // This too.
+    struct T final : S {}; // expected-error {{base 'S' is marked 'final'}}
   }
 }