[cfe-commits] r156856 - in /cfe/trunk: lib/Parse/ParseDecl.cpp test/SemaCXX/unknown-type-name.cpp

Richard Smith richard-llvm at metafoo.co.uk
Tue May 15 14:29:55 PDT 2012


Author: rsmith
Date: Tue May 15 16:29:55 2012
New Revision: 156856

URL: http://llvm.org/viewvc/llvm-project?rev=156856&view=rev
Log:
If we see a declaration which is either missing a type or has a malformed type,
and the thing we have has a scope specifier, and we're in a context that doesn't
allow declaring a qualified name, then the error is a malformed type, not a
missing type.

Modified:
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/test/SemaCXX/unknown-type-name.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=156856&r1=156855&r2=156856&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue May 15 16:29:55 2012
@@ -1707,7 +1707,10 @@
     }
   }
 
-  if (DSC != DSC_type_specifier && DSC != DSC_trailing) {
+  // Determine whether this identifier could plausibly be the name of something
+  // being declared (with a missign type).
+  if (DSC != DSC_type_specifier && DSC != DSC_trailing &&
+      (!SS || DSC == DSC_top_level || DSC == DSC_class)) {
     // Look ahead to the next token to try to figure out what this declaration
     // was supposed to be.
     switch (NextToken().getKind()) {

Modified: cfe/trunk/test/SemaCXX/unknown-type-name.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/unknown-type-name.cpp?rev=156856&r1=156855&r2=156856&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/unknown-type-name.cpp (original)
+++ cfe/trunk/test/SemaCXX/unknown-type-name.cpp Tue May 15 16:29:55 2012
@@ -20,6 +20,8 @@
   typedef T type;
   
   type f();
+
+  type g();
 };
 
 template<typename T>
@@ -27,3 +29,14 @@
 
 template<typename T>
 A<T>::type A<T>::f() { return type(); } // expected-error{{missing 'typename'}}
+
+template<typename T>
+void f(int, T::type) { } // expected-error{{missing 'typename'}}
+
+template<typename T>
+void f(int, T::type, int) { } // expected-error{{missing 'typename'}}
+
+// FIXME: We know which type specifier should have been specified here. Provide
+//        a fix-it to add 'typename A<T>::type'
+template<typename T>
+A<T>::g() { } // expected-error{{requires a type specifier}}





More information about the cfe-commits mailing list