diff --git a/qtcreator.pro b/qtcreator.pro
index cc3a6a713686cbae5cc296b5101f118629011ef7..c5800e9d493fd89e81e35028f157202c110b2e6a 100644
--- a/qtcreator.pro
+++ b/qtcreator.pro
@@ -1,6 +1,6 @@
 #version check qt
 contains(QT_VERSION, ^4\.[0-5]\..*) {
-    message("Cannot build Qt Creator with Qt version $$QT_VERSION.")
+    message("Cannot build Qt Creator with Qt version $${QT_VERSION}.")
     error("Use at least Qt 4.6.")
 }
 
diff --git a/src/libs/cplusplus/MatchingText.cpp b/src/libs/cplusplus/MatchingText.cpp
index e2b76221815f49e6fe25260003c59fa02d3b998d..6e4c791511fb163683a8124825a57d5e5b12fbd4 100644
--- a/src/libs/cplusplus/MatchingText.cpp
+++ b/src/libs/cplusplus/MatchingText.cpp
@@ -238,7 +238,7 @@ QString MatchingText::insertParagraphSeparator(const QTextCursor &tc) const
             if (current.is(T_EOF_SYMBOL))
                 break;
 
-            else if (current.is(T_CLASS) || current.is(T_STRUCT) || current.is(T_UNION)) {
+            else if (current.is(T_CLASS) || current.is(T_STRUCT) || current.is(T_UNION) || current.is(T_ENUM)) {
                 // found a class key.
                 QString str = QLatin1String("};");
 
diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp
index 5614355ab43993e87e786aced4ebb2d841c17a3a..7bcbfdc34d2a2fb5af5f3269abd4512722f9676c 100644
--- a/src/shared/cplusplus/Parser.cpp
+++ b/src/shared/cplusplus/Parser.cpp
@@ -442,6 +442,8 @@ bool Parser::parseTranslationUnit(TranslationUnitAST *&node)
             rewind(start_declaration + 1);
             skipUntilDeclaration();
         }
+
+        _templateArgumentList.clear();
     }
 
     node = ast;
@@ -569,6 +571,8 @@ bool Parser::parseLinkageBody(DeclarationAST *&node)
                 rewind(start_declaration + 1);
                 skipUntilDeclaration();
             }
+
+            _templateArgumentList.clear();
         }
         match(T_RBRACE, &ast->rbrace_token);
         node = ast;
@@ -693,11 +697,9 @@ bool Parser::parseOperatorFunctionId(NameAST *&node)
 
 Parser::TemplateArgumentListEntry *Parser::templateArgumentListEntry(unsigned tokenIndex)
 {
-    for (unsigned i = 0; i < _templateArgumentList.size(); ++i) {
-        TemplateArgumentListEntry *entry = &_templateArgumentList[i];
-        if (entry->index == tokenIndex)
-            return entry;
-    }
+    std::map<unsigned, TemplateArgumentListEntry>::iterator it =_templateArgumentList.find(tokenIndex);
+    if (it != _templateArgumentList.end())
+        return &it->second;
 
     return 0;
 }
@@ -729,11 +731,11 @@ bool Parser::parseTemplateArgumentList(TemplateArgumentListAST *&node)
             }
         }
 
-        _templateArgumentList.push_back(TemplateArgumentListEntry(start, cursor(), node));
+        _templateArgumentList.insert(std::make_pair(cursor(), TemplateArgumentListEntry(start, cursor(), node)));
         return true;
     }
 
-    _templateArgumentList.push_back(TemplateArgumentListEntry(start, cursor(), 0));
+    _templateArgumentList.insert(std::make_pair(cursor(), TemplateArgumentListEntry(start, cursor(), 0)));
 
     return false;
 }
diff --git a/src/shared/cplusplus/Parser.h b/src/shared/cplusplus/Parser.h
index ba0785e7eab88ba16f5a292d585c36b8f1fc4e92..3cbf45b0bdeaed8156454e7a857b6797b911d710 100644
--- a/src/shared/cplusplus/Parser.h
+++ b/src/shared/cplusplus/Parser.h
@@ -53,6 +53,7 @@
 #include "ASTfwd.h"
 #include "Token.h"
 #include "TranslationUnit.h"
+#include <map>
 
 namespace CPlusPlus {
 
@@ -308,7 +309,7 @@ private:
     bool _inFunctionBody: 1;
     bool _inObjCImplementationContext: 1;
 
-    Array<TemplateArgumentListEntry> _templateArgumentList;
+    std::map<unsigned, TemplateArgumentListEntry> _templateArgumentList;
 
     class Rewind;
     friend class Rewind;