when a typedef name is parsed as part of declspecs, remember the decl for the
typedef.

llvm-svn: 39188
diff --git a/clang/Parse/DeclSpec.cpp b/clang/Parse/DeclSpec.cpp
index 48e9a11..0fc8d70 100644
--- a/clang/Parse/DeclSpec.cpp
+++ b/clang/Parse/DeclSpec.cpp
@@ -152,10 +152,11 @@
   return false;
 }
 
-bool DeclSpec::SetTypeSpecType(TST T, const char *&PrevSpec) {
+bool DeclSpec::SetTypeSpecType(TST T, const char *&PrevSpec, void *TypeRep) {
   if (TypeSpecType != TST_unspecified)
     return BadSpecifier(TypeSpecType, PrevSpec);
   TypeSpecType = T;
+  TypenameRep = TypeRep;
   return false;
 }
 
diff --git a/clang/Parse/MinimalAction.cpp b/clang/Parse/MinimalAction.cpp
index 115a31f..30eea7b 100644
--- a/clang/Parse/MinimalAction.cpp
+++ b/clang/Parse/MinimalAction.cpp
@@ -32,9 +32,12 @@
 /// isTypeName - This looks at the IdentifierInfo::FETokenInfo field to
 /// determine whether the name is a type name (objc class name or typedef) or
 /// not in this scope.
-bool MinimalAction::isTypeName(const IdentifierInfo &II, Scope *S) const {
-  TypeNameInfo *TI = II.getFETokenInfo<TypeNameInfo>();
-  return TI != 0 && TI->isTypeName;
+Action::DeclTy *
+MinimalAction::isTypeName(const IdentifierInfo &II, Scope *S) const {
+  if (TypeNameInfo *TI = II.getFETokenInfo<TypeNameInfo>())
+    if (TI->isTypeName)
+      return TI;
+  return 0;
 }
 
 /// ParseDeclarator - If this is a typedef declarator, we modify the
diff --git a/clang/Parse/ParseDecl.cpp b/clang/Parse/ParseDecl.cpp
index 458f67b..bc0a342 100644
--- a/clang/Parse/ParseDecl.cpp
+++ b/clang/Parse/ParseDecl.cpp
@@ -256,10 +256,13 @@
       if (DS.TypeSpecType  == DeclSpec::TST_unspecified &&
           DS.TypeSpecWidth == DeclSpec::TSW_unspecified &&
           DS.TypeSpecComplex == DeclSpec::TSC_unspecified &&
-          DS.TypeSpecSign == DeclSpec::TSS_unspecified &&
-          // It has to be available as a typedef too!
-          Actions.isTypeName(*Tok.getIdentifierInfo(), CurScope)) {
-        isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typedef, PrevSpec);
+          DS.TypeSpecSign == DeclSpec::TSS_unspecified) {
+        // It has to be available as a typedef too!
+        if (void *TypeRep = Actions.isTypeName(*Tok.getIdentifierInfo(),
+                                               CurScope)) {
+          isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typedef, PrevSpec,
+                                         TypeRep);
+        }
         break;
       }
       // FALL THROUGH.
@@ -641,7 +644,7 @@
     
     // typedef-name
   case tok::identifier:
-    return Actions.isTypeName(*Tok.getIdentifierInfo(), CurScope);
+    return Actions.isTypeName(*Tok.getIdentifierInfo(), CurScope) != 0;
     
     // TODO: Attributes.
   }
@@ -694,7 +697,7 @@
     
     // typedef-name
   case tok::identifier:
-    return Actions.isTypeName(*Tok.getIdentifierInfo(), CurScope);
+    return Actions.isTypeName(*Tok.getIdentifierInfo(), CurScope) != 0;
     // TODO: Attributes.
   }
 }