diff options
-rw-r--r-- | clang/lib/AST/TypePrinter.cpp | 29 | ||||
-rw-r--r-- | clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp | 6 |
2 files changed, 27 insertions, 8 deletions
diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp index 111fee9d882..84adad7b137 100644 --- a/clang/lib/AST/TypePrinter.cpp +++ b/clang/lib/AST/TypePrinter.cpp @@ -449,12 +449,12 @@ void TypePrinter::printVariableArrayAfter(const VariableArrayType *T, AppendTypeQualList(OS, T->getIndexTypeCVRQualifiers()); OS << ' '; } - + if (T->getSizeModifier() == VariableArrayType::Static) OS << "static"; else if (T->getSizeModifier() == VariableArrayType::Star) OS << '*'; - + if (T->getSizeExpr()) T->getSizeExpr()->printPretty(OS, 0, Policy); OS << ']'; @@ -1248,6 +1248,7 @@ TemplateSpecializationType::PrintTemplateArgumentList( if (!SkipBrackets) OS << '<'; + bool needSpace = false; for (unsigned Arg = 0; Arg < NumArgs; ++Arg) { if (Arg > 0) OS << ", "; @@ -1270,10 +1271,18 @@ TemplateSpecializationType::PrintTemplateArgumentList( // to avoid printing the diagraph '<:'. if (!Arg && !ArgString.empty() && ArgString[0] == ':') OS << ' '; - + OS << ArgString; + + needSpace = (!ArgString.empty() && ArgString.back() == '>'); } + // If the last character of our string is '>', add another space to + // keep the two '>''s separate tokens. We don't *have* to do this in + // C++0x, but it's still good hygiene. + if (needSpace) + OS << ' '; + if (!SkipBrackets) OS << '>'; } @@ -1284,6 +1293,8 @@ PrintTemplateArgumentList(raw_ostream &OS, const TemplateArgumentLoc *Args, unsigned NumArgs, const PrintingPolicy &Policy) { OS << '<'; + + bool needSpace = false; for (unsigned Arg = 0; Arg < NumArgs; ++Arg) { if (Arg > 0) OS << ", "; @@ -1306,10 +1317,18 @@ PrintTemplateArgumentList(raw_ostream &OS, // to avoid printing the diagraph '<:'. if (!Arg && !ArgString.empty() && ArgString[0] == ':') OS << ' '; - + OS << ArgString; + + needSpace = (!ArgString.empty() && ArgString.back() == '>'); } + // If the last character of our string is '>', add another space to + // keep the two '>''s separate tokens. We don't *have* to do this in + // C++0x, but it's still good hygiene. + if (needSpace) + OS << ' '; + OS << '>'; } @@ -1532,7 +1551,7 @@ void Qualifiers::print(raw_ostream &OS, const PrintingPolicy& Policy, OS << ' '; addSpace = true; } - + switch (lifetime) { case Qualifiers::OCL_None: llvm_unreachable("none but true"); case Qualifiers::OCL_ExplicitNone: OS << "__unsafe_unretained"; break; diff --git a/clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp b/clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp index 0c555b53f95..1c13bffa212 100644 --- a/clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp +++ b/clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp @@ -13,9 +13,9 @@ template <class T1, class T2, int N = 17> struct E; eval<A<int>> eA; eval<B<int, float>> eB; -eval<C<17>> eC; // expected-error{{implicit instantiation of undefined template 'eval<C<17>>'}} -eval<D<int, 17>> eD; // expected-error{{implicit instantiation of undefined template 'eval<D<int, 17>>'}} -eval<E<int, float>> eE; // expected-error{{implicit instantiation of undefined template 'eval<E<int, float, 17>>}} +eval<C<17>> eC; // expected-error{{implicit instantiation of undefined template 'eval<C<17> >'}} +eval<D<int, 17>> eD; // expected-error{{implicit instantiation of undefined template 'eval<D<int, 17> >'}} +eval<E<int, float>> eE; // expected-error{{implicit instantiation of undefined template 'eval<E<int, float, 17> >}} template<template <int ...N> class TT> struct X0 { }; // expected-note{{previous non-type template parameter with type 'int' is here}} template<int I, int J, int ...Rest> struct X0a; |