This revision was automatically updated to reflect the committed changes. Closed by commit rL286439: Make output of -ast-print a valid C++ code. (authored by sepavloff).
Changed prior to commit: https://reviews.llvm.org/D26452?vs=77354&id=77452#toc Repository: rL LLVM https://reviews.llvm.org/D26452 Files: cfe/trunk/lib/AST/DeclPrinter.cpp cfe/trunk/test/Analysis/cfg.cpp cfe/trunk/test/Coverage/ast-print-func.cpp cfe/trunk/test/Coverage/ast-print-temp-class.cpp cfe/trunk/test/Coverage/ast-print-temp-func.cpp cfe/trunk/test/Coverage/ast-printing.cpp cfe/trunk/test/Index/comment-cplus-decls.cpp cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp cfe/trunk/test/Misc/ast-dump-templates.cpp cfe/trunk/test/OpenMP/atomic_ast_print.cpp cfe/trunk/test/OpenMP/barrier_ast_print.cpp cfe/trunk/test/OpenMP/critical_ast_print.cpp cfe/trunk/test/OpenMP/declare_reduction_ast_print.cpp cfe/trunk/test/OpenMP/declare_simd_ast_print.cpp cfe/trunk/test/OpenMP/declare_target_ast_print.cpp cfe/trunk/test/OpenMP/distribute_ast_print.cpp cfe/trunk/test/OpenMP/distribute_dist_schedule_ast_print.cpp cfe/trunk/test/OpenMP/distribute_parallel_for_ast_print.cpp cfe/trunk/test/OpenMP/distribute_parallel_for_simd_ast_print.cpp cfe/trunk/test/OpenMP/distribute_simd_ast_print.cpp cfe/trunk/test/OpenMP/flush_ast_print.cpp cfe/trunk/test/OpenMP/for_ast_print.cpp cfe/trunk/test/OpenMP/for_simd_ast_print.cpp cfe/trunk/test/OpenMP/ordered_ast_print.cpp cfe/trunk/test/OpenMP/parallel_ast_print.cpp cfe/trunk/test/OpenMP/parallel_for_ast_print.cpp cfe/trunk/test/OpenMP/parallel_for_simd_ast_print.cpp cfe/trunk/test/OpenMP/parallel_sections_ast_print.cpp cfe/trunk/test/OpenMP/sections_ast_print.cpp cfe/trunk/test/OpenMP/simd_ast_print.cpp cfe/trunk/test/OpenMP/single_ast_print.cpp cfe/trunk/test/OpenMP/target_ast_print.cpp cfe/trunk/test/OpenMP/target_data_ast_print.cpp cfe/trunk/test/OpenMP/target_data_use_device_ptr_ast_print.cpp cfe/trunk/test/OpenMP/target_enter_data_ast_print.cpp cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp cfe/trunk/test/OpenMP/target_is_device_ptr_ast_print.cpp cfe/trunk/test/OpenMP/target_parallel_ast_print.cpp cfe/trunk/test/OpenMP/target_parallel_for_ast_print.cpp cfe/trunk/test/OpenMP/target_parallel_for_simd_ast_print.cpp cfe/trunk/test/OpenMP/target_simd_ast_print.cpp cfe/trunk/test/OpenMP/target_update_ast_print.cpp cfe/trunk/test/OpenMP/task_ast_print.cpp cfe/trunk/test/OpenMP/taskloop_ast_print.cpp cfe/trunk/test/OpenMP/taskloop_simd_ast_print.cpp cfe/trunk/test/OpenMP/taskwait_ast_print.cpp cfe/trunk/test/OpenMP/taskyield_ast_print.cpp cfe/trunk/test/OpenMP/teams_ast_print.cpp cfe/trunk/test/OpenMP/teams_distribute_ast_print.cpp cfe/trunk/test/OpenMP/teams_distribute_simd_ast_print.cpp cfe/trunk/test/OpenMP/threadprivate_ast_print.cpp cfe/trunk/test/SemaTemplate/temp_arg_enum_printing.cpp cfe/trunk/unittests/AST/ASTTypeTraitsTest.cpp cfe/trunk/unittests/AST/DeclPrinterTest.cpp
Index: cfe/trunk/lib/AST/DeclPrinter.cpp =================================================================== --- cfe/trunk/lib/AST/DeclPrinter.cpp +++ cfe/trunk/lib/AST/DeclPrinter.cpp @@ -78,6 +78,10 @@ void VisitTemplateDecl(const TemplateDecl *D); void VisitFunctionTemplateDecl(FunctionTemplateDecl *D); void VisitClassTemplateDecl(ClassTemplateDecl *D); + void VisitClassTemplateSpecializationDecl( + ClassTemplateSpecializationDecl *D); + void VisitClassTemplatePartialSpecializationDecl( + ClassTemplatePartialSpecializationDecl *D); void VisitObjCMethodDecl(ObjCMethodDecl *D); void VisitObjCImplementationDecl(ObjCImplementationDecl *D); void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D); @@ -95,8 +99,9 @@ void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D); void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D); - void PrintTemplateParameters(const TemplateParameterList *Params, - const TemplateArgumentList *Args = nullptr); + void printTemplateParameters(const TemplateParameterList *Params); + void printTemplateArguments(const TemplateArgumentList &Args, + const TemplateParameterList *Params = nullptr); void prettyPrintAttributes(Decl *D); void prettyPrintPragmas(Decl *D); void printDeclType(QualType T, StringRef DeclName, bool Pack = false); @@ -290,6 +295,13 @@ if (D->isImplicit()) continue; + // Don't print implicit specializations, as they are printed when visiting + // corresponding templates. + if (auto FD = dyn_cast<FunctionDecl>(*D)) + if (FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation && + !isa<ClassTemplateSpecializationDecl>(DC)) + continue; + // The next bits of code handles stuff like "struct {int x;} a,b"; we're // forced to merge the declarations because there's no other way to // refer to the struct in question. This limited merging is safe without @@ -337,11 +349,19 @@ const char *Terminator = nullptr; if (isa<OMPThreadPrivateDecl>(*D) || isa<OMPDeclareReductionDecl>(*D)) Terminator = nullptr; - else if (isa<FunctionDecl>(*D) && cast<FunctionDecl>(*D)->hasBody()) - Terminator = nullptr; else if (isa<ObjCMethodDecl>(*D) && cast<ObjCMethodDecl>(*D)->hasBody()) Terminator = nullptr; - else if (isa<NamespaceDecl>(*D) || isa<LinkageSpecDecl>(*D) || + else if (auto FD = dyn_cast<FunctionDecl>(*D)) { + if (FD->isThisDeclarationADefinition()) + Terminator = nullptr; + else + Terminator = ";"; + } else if (auto TD = dyn_cast<FunctionTemplateDecl>(*D)) { + if (TD->getTemplatedDecl()->isThisDeclarationADefinition()) + Terminator = nullptr; + else + Terminator = ";"; + } else if (isa<NamespaceDecl>(*D) || isa<LinkageSpecDecl>(*D) || isa<ObjCImplementationDecl>(*D) || isa<ObjCInterfaceDecl>(*D) || isa<ObjCProtocolDecl>(*D) || @@ -358,7 +378,14 @@ if (Terminator) Out << Terminator; - Out << "\n"; + if (!Policy.TerseOutput && + ((isa<FunctionDecl>(*D) && + cast<FunctionDecl>(*D)->doesThisDeclarationHaveABody()) || + (isa<FunctionTemplateDecl>(*D) && + cast<FunctionTemplateDecl>(*D)->getTemplatedDecl()->doesThisDeclarationHaveABody()))) + ; // StmtPrinter already added '\n' after CompoundStmt. + else + Out << "\n"; // Declare target attribute is special one, natural spelling for the pragma // assumes "ending" construct so print it here. @@ -448,6 +475,9 @@ !D->isFunctionTemplateSpecialization()) prettyPrintPragmas(D); + if (D->isFunctionTemplateSpecialization()) + Out << "template<> "; + CXXConstructorDecl *CDecl = dyn_cast<CXXConstructorDecl>(D); CXXConversionDecl *ConversionDecl = dyn_cast<CXXConversionDecl>(D); if (!Policy.SuppressSpecifiers) { @@ -472,6 +502,11 @@ PrintingPolicy SubPolicy(Policy); SubPolicy.SuppressSpecifiers = false; std::string Proto = D->getNameInfo().getAsString(); + if (const TemplateArgumentList *TArgs = D->getTemplateSpecializationArgs()) { + llvm::raw_string_ostream POut(Proto); + DeclPrinter TArgPrinter(POut, SubPolicy, Indentation); + TArgPrinter.printTemplateArguments(*TArgs); + } QualType Ty = D->getType(); while (const ParenType *PT = dyn_cast<ParenType>(Ty)) { @@ -635,33 +670,37 @@ Out << " = delete"; else if (D->isExplicitlyDefaulted()) Out << " = default"; - else if (D->doesThisDeclarationHaveABody() && !Policy.TerseOutput) { - if (!D->hasPrototype() && D->getNumParams()) { - // This is a K&R function definition, so we need to print the - // parameters. - Out << '\n'; - DeclPrinter ParamPrinter(Out, SubPolicy, Indentation); - Indentation += Policy.Indentation; - for (unsigned i = 0, e = D->getNumParams(); i != e; ++i) { - Indent(); - ParamPrinter.VisitParmVarDecl(D->getParamDecl(i)); - Out << ";\n"; - } - Indentation -= Policy.Indentation; - } else - Out << ' '; + else if (D->doesThisDeclarationHaveABody()) { + if (!Policy.TerseOutput) { + if (!D->hasPrototype() && D->getNumParams()) { + // This is a K&R function definition, so we need to print the + // parameters. + Out << '\n'; + DeclPrinter ParamPrinter(Out, SubPolicy, Indentation); + Indentation += Policy.Indentation; + for (unsigned i = 0, e = D->getNumParams(); i != e; ++i) { + Indent(); + ParamPrinter.VisitParmVarDecl(D->getParamDecl(i)); + Out << ";\n"; + } + Indentation -= Policy.Indentation; + } else + Out << ' '; - if (D->getBody()) - D->getBody()->printPretty(Out, nullptr, SubPolicy, Indentation); - Out << '\n'; + if (D->getBody()) + D->getBody()->printPretty(Out, nullptr, SubPolicy, Indentation); + } else { + if (isa<CXXConstructorDecl>(*D)) + Out << " {}"; + } } } void DeclPrinter::VisitFriendDecl(FriendDecl *D) { if (TypeSourceInfo *TSI = D->getFriendType()) { unsigned NumTPLists = D->getFriendTypeNumTemplateParameterLists(); for (unsigned i = 0; i < NumTPLists; ++i) - PrintTemplateParameters(D->getFriendTypeTemplateParameterList(i)); + printTemplateParameters(D->getFriendTypeTemplateParameterList(i)); Out << "friend "; Out << " " << TSI->getType().getAsString(Policy); } @@ -838,9 +877,15 @@ prettyPrintAttributes(D); - if (D->getIdentifier()) + if (D->getIdentifier()) { Out << ' ' << *D; + if (auto S = dyn_cast<ClassTemplatePartialSpecializationDecl>(D)) + printTemplateArguments(S->getTemplateArgs(), S->getTemplateParameters()); + else if (auto S = dyn_cast<ClassTemplateSpecializationDecl>(D)) + printTemplateArguments(S->getTemplateArgs()); + } + if (D->isCompleteDefinition()) { // Print the base classes if (D->getNumBases()) { @@ -867,9 +912,13 @@ // Print the class definition // FIXME: Doesn't print access specifiers, e.g., "public:" - Out << " {\n"; - VisitDeclContext(D); - Indent() << "}"; + if (Policy.TerseOutput) { + Out << " {}"; + } else { + Out << " {\n"; + VisitDeclContext(D); + Indent() << "}"; + } } } @@ -892,20 +941,17 @@ Visit(*D->decls_begin()); } -void DeclPrinter::PrintTemplateParameters(const TemplateParameterList *Params, - const TemplateArgumentList *Args) { +void DeclPrinter::printTemplateParameters(const TemplateParameterList *Params) { assert(Params); - assert(!Args || Params->size() == Args->size()); Out << "template <"; for (unsigned i = 0, e = Params->size(); i != e; ++i) { if (i != 0) Out << ", "; const Decl *Param = Params->getParam(i); - if (const TemplateTypeParmDecl *TTP = - dyn_cast<TemplateTypeParmDecl>(Param)) { + if (auto TTP = dyn_cast<TemplateTypeParmDecl>(Param)) { if (TTP->wasDeclaredWithTypename()) Out << "typename "; @@ -917,40 +963,70 @@ Out << *TTP; - if (Args) { - Out << " = "; - Args->get(i).print(Policy, Out); - } else if (TTP->hasDefaultArgument()) { + if (TTP->hasDefaultArgument()) { Out << " = "; Out << TTP->getDefaultArgument().getAsString(Policy); }; - } else if (const NonTypeTemplateParmDecl *NTTP = - dyn_cast<NonTypeTemplateParmDecl>(Param)) { + } else if (auto NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) { StringRef Name; if (IdentifierInfo *II = NTTP->getIdentifier()) Name = II->getName(); printDeclType(NTTP->getType(), Name, NTTP->isParameterPack()); - if (Args) { - Out << " = "; - Args->get(i).print(Policy, Out); - } else if (NTTP->hasDefaultArgument()) { + if (NTTP->hasDefaultArgument()) { Out << " = "; NTTP->getDefaultArgument()->printPretty(Out, nullptr, Policy, Indentation); } - } else if (const TemplateTemplateParmDecl *TTPD = - dyn_cast<TemplateTemplateParmDecl>(Param)) { + } else if (auto TTPD = dyn_cast<TemplateTemplateParmDecl>(Param)) { VisitTemplateDecl(TTPD); // FIXME: print the default argument, if present. } } Out << "> "; } +void DeclPrinter::printTemplateArguments(const TemplateArgumentList &Args, + const TemplateParameterList *Params) { + Out << "<"; + for (size_t I = 0, E = Args.size(); I < E; ++I) { + const TemplateArgument &A = Args[I]; + if (I) + Out << ", "; + if (Params) { + if (A.getKind() == TemplateArgument::Type) + if (auto T = A.getAsType()->getAs<TemplateTypeParmType>()) { + auto P = cast<TemplateTypeParmDecl>(Params->getParam(T->getIndex())); + Out << *P; + continue; + } + if (A.getKind() == TemplateArgument::Template) { + if (auto T = A.getAsTemplate().getAsTemplateDecl()) + if (auto TD = dyn_cast<TemplateTemplateParmDecl>(T)) { + auto P = cast<TemplateTemplateParmDecl>( + Params->getParam(TD->getIndex())); + Out << *P; + continue; + } + } + if (A.getKind() == TemplateArgument::Expression) { + if (auto E = dyn_cast<DeclRefExpr>(A.getAsExpr())) + if (auto N = dyn_cast<NonTypeTemplateParmDecl>(E->getDecl())) { + auto P = cast<NonTypeTemplateParmDecl>( + Params->getParam(N->getIndex())); + Out << *P; + continue; + } + } + } + A.print(Policy, Out); + } + Out << ">"; +} + void DeclPrinter::VisitTemplateDecl(const TemplateDecl *D) { - PrintTemplateParameters(D->getTemplateParameters()); + printTemplateParameters(D->getTemplateParameters()); if (const TemplateTemplateParmDecl *TTP = dyn_cast<TemplateTemplateParmDecl>(D)) { @@ -964,30 +1040,49 @@ } void DeclPrinter::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { + prettyPrintPragmas(D->getTemplatedDecl()); + VisitRedeclarableTemplateDecl(D); + if (PrintInstantiation) { - TemplateParameterList *Params = D->getTemplateParameters(); - for (auto *I : D->specializations()) { - prettyPrintPragmas(I); - PrintTemplateParameters(Params, I->getTemplateSpecializationArgs()); - Visit(I); - } + FunctionDecl *PrevDecl = D->getTemplatedDecl(); + const FunctionDecl *Def; + if (PrevDecl->isDefined(Def) && Def != PrevDecl) + return; + for (auto *I : D->specializations()) + if (I->getTemplateSpecializationKind() == TSK_ImplicitInstantiation) { + if (!PrevDecl->isThisDeclarationADefinition()) + Out << ";\n"; + Indent(); + prettyPrintPragmas(I); + Visit(I); + } } - - prettyPrintPragmas(D->getTemplatedDecl()); - return VisitRedeclarableTemplateDecl(D); } void DeclPrinter::VisitClassTemplateDecl(ClassTemplateDecl *D) { + VisitRedeclarableTemplateDecl(D); + if (PrintInstantiation) { - TemplateParameterList *Params = D->getTemplateParameters(); - for (auto *I : D->specializations()) { - PrintTemplateParameters(Params, &I->getTemplateArgs()); - Visit(I); - Out << ";\n"; - } + for (auto *I : D->specializations()) + if (I->getSpecializationKind() == TSK_ImplicitInstantiation) { + if (D->isThisDeclarationADefinition()) + Out << ";"; + Out << "\n"; + Visit(I); + } } +} + +void DeclPrinter::VisitClassTemplateSpecializationDecl( + ClassTemplateSpecializationDecl *D) { + Out << "template<> "; + VisitCXXRecordDecl(D); +} - return VisitRedeclarableTemplateDecl(D); +void DeclPrinter::VisitClassTemplatePartialSpecializationDecl( + ClassTemplatePartialSpecializationDecl *D) { + printTemplateParameters(D->getTemplateParameters()); + VisitCXXRecordDecl(D); } //---------------------------------------------------------------------------- Index: cfe/trunk/unittests/AST/DeclPrinterTest.cpp =================================================================== --- cfe/trunk/unittests/AST/DeclPrinterTest.cpp +++ cfe/trunk/unittests/AST/DeclPrinterTest.cpp @@ -254,178 +254,157 @@ ASSERT_TRUE(PrintedDeclCXX98Matches( "class A { int a; };", "A", - "class A {\n}")); - // Should be: with semicolon, with { ... } + "class A {}")); } TEST(DeclPrinter, TestCXXRecordDecl2) { ASSERT_TRUE(PrintedDeclCXX98Matches( "struct A { int a; };", "A", - "struct A {\n}")); - // Should be: with semicolon, with { ... } + "struct A {}")); } TEST(DeclPrinter, TestCXXRecordDecl3) { ASSERT_TRUE(PrintedDeclCXX98Matches( "union A { int a; };", "A", - "union A {\n}")); - // Should be: with semicolon, with { ... } + "union A {}")); } TEST(DeclPrinter, TestCXXRecordDecl4) { ASSERT_TRUE(PrintedDeclCXX98Matches( "class Z { int a; };" "class A : Z { int b; };", "A", - "class A : Z {\n}")); - // Should be: with semicolon, with { ... } + "class A : Z {}")); } TEST(DeclPrinter, TestCXXRecordDecl5) { ASSERT_TRUE(PrintedDeclCXX98Matches( "struct Z { int a; };" "struct A : Z { int b; };", "A", - "struct A : Z {\n}")); - // Should be: with semicolon, with { ... } + "struct A : Z {}")); } TEST(DeclPrinter, TestCXXRecordDecl6) { ASSERT_TRUE(PrintedDeclCXX98Matches( "class Z { int a; };" "class A : public Z { int b; };", "A", - "class A : public Z {\n}")); - // Should be: with semicolon, with { ... } + "class A : public Z {}")); } TEST(DeclPrinter, TestCXXRecordDecl7) { ASSERT_TRUE(PrintedDeclCXX98Matches( "class Z { int a; };" "class A : protected Z { int b; };", "A", - "class A : protected Z {\n}")); - // Should be: with semicolon, with { ... } + "class A : protected Z {}")); } TEST(DeclPrinter, TestCXXRecordDecl8) { ASSERT_TRUE(PrintedDeclCXX98Matches( "class Z { int a; };" "class A : private Z { int b; };", "A", - "class A : private Z {\n}")); - // Should be: with semicolon, with { ... } + "class A : private Z {}")); } TEST(DeclPrinter, TestCXXRecordDecl9) { ASSERT_TRUE(PrintedDeclCXX98Matches( "class Z { int a; };" "class A : virtual Z { int b; };", "A", - "class A : virtual Z {\n}")); - // Should be: with semicolon, with { ... } + "class A : virtual Z {}")); } TEST(DeclPrinter, TestCXXRecordDecl10) { ASSERT_TRUE(PrintedDeclCXX98Matches( "class Z { int a; };" "class A : virtual public Z { int b; };", "A", - "class A : virtual public Z {\n}")); - // Should be: with semicolon, with { ... } + "class A : virtual public Z {}")); } TEST(DeclPrinter, TestCXXRecordDecl11) { ASSERT_TRUE(PrintedDeclCXX98Matches( "class Z { int a; };" "class Y : virtual public Z { int b; };" "class A : virtual public Z, private Y { int c; };", "A", - "class A : virtual public Z, private Y {\n}")); - // Should be: with semicolon, with { ... } + "class A : virtual public Z, private Y {}")); } TEST(DeclPrinter, TestFunctionDecl1) { ASSERT_TRUE(PrintedDeclCXX98Matches( "void A();", "A", "void A()")); - // Should be: with semicolon } TEST(DeclPrinter, TestFunctionDecl2) { ASSERT_TRUE(PrintedDeclCXX98Matches( "void A() {}", "A", "void A()")); - // Should be: with semicolon } TEST(DeclPrinter, TestFunctionDecl3) { ASSERT_TRUE(PrintedDeclCXX98Matches( "void Z();" "void A() { Z(); }", "A", "void A()")); - // Should be: with semicolon } TEST(DeclPrinter, TestFunctionDecl4) { ASSERT_TRUE(PrintedDeclCXX98Matches( "extern void A();", "A", "extern void A()")); - // Should be: with semicolon } TEST(DeclPrinter, TestFunctionDecl5) { ASSERT_TRUE(PrintedDeclCXX98Matches( "static void A();", "A", "static void A()")); - // Should be: with semicolon } TEST(DeclPrinter, TestFunctionDecl6) { ASSERT_TRUE(PrintedDeclCXX98Matches( "inline void A();", "A", "inline void A()")); - // Should be: with semicolon } TEST(DeclPrinter, TestFunctionDecl7) { ASSERT_TRUE(PrintedDeclCXX11Matches( "constexpr int A(int a);", "A", "constexpr int A(int a)")); - // Should be: with semicolon } TEST(DeclPrinter, TestFunctionDecl8) { ASSERT_TRUE(PrintedDeclCXX98Matches( "void A(int a);", "A", "void A(int a)")); - // Should be: with semicolon } TEST(DeclPrinter, TestFunctionDecl9) { ASSERT_TRUE(PrintedDeclCXX98Matches( "void A(...);", "A", "void A(...)")); - // Should be: with semicolon } TEST(DeclPrinter, TestFunctionDecl10) { ASSERT_TRUE(PrintedDeclCXX98Matches( "void A(int a, ...);", "A", "void A(int a, ...)")); - // Should be: with semicolon } TEST(DeclPrinter, TestFunctionDecl11) { @@ -435,23 +414,21 @@ "void A(int a, pInt b, ssize_t c);", "A", "void A(int a, pInt b, ssize_t c)")); - // Should be: with semicolon } TEST(DeclPrinter, TestFunctionDecl12) { ASSERT_TRUE(PrintedDeclCXX98Matches( "void A(int a, int b = 0);", "A", "void A(int a, int b = 0)")); - // Should be: with semicolon } TEST(DeclPrinter, TestFunctionDecl13) { ASSERT_TRUE(PrintedDeclCXX98Matches( "void (*A(int a))(int b);", "A", "void (*A(int a))(int)")); - // Should be: with semicolon, with parameter name (?) + // Should be: with parameter name (?) } TEST(DeclPrinter, TestFunctionDecl14) { @@ -461,8 +438,7 @@ "template<>" "void A(int N) { }", functionDecl(hasName("A"), isExplicitTemplateSpecialization()).bind("id"), - "void A(int N)")); - // WRONG; Should be: "template <> void A(int N);")); + "template<> void A<int>(int N)")); } @@ -555,7 +531,6 @@ "};", cxxConstructorDecl(ofClass(hasName("A"))).bind("id"), "A<T...>(const A<T...> &a)")); - // WRONG; Should be: "A(const A<T...> &a);" } TEST(DeclPrinter, TestCXXConstructorDecl11) { @@ -565,8 +540,7 @@ " A(T&&... ts) : T(ts)... {}" "};", cxxConstructorDecl(ofClass(hasName("A"))).bind("id"), - "A<T...>(T &&...ts) : T(ts)...")); - // WRONG; Should be: "A(T &&...ts) : T(ts)... {}" + "A<T...>(T &&...ts) : T(ts)... {}")); } TEST(DeclPrinter, TestCXXDestructorDecl1) { @@ -623,7 +597,6 @@ "};", cxxMethodDecl(ofClass(hasName("Z"))).bind("id"), "void *operator new(std::size_t)")); - // Should be: with semicolon } TEST(DeclPrinter, TestCXXMethodDecl_AllocationFunction2) { @@ -634,7 +607,6 @@ "};", cxxMethodDecl(ofClass(hasName("Z"))).bind("id"), "void *operator new[](std::size_t)")); - // Should be: with semicolon } TEST(DeclPrinter, TestCXXMethodDecl_AllocationFunction3) { @@ -644,7 +616,7 @@ "};", cxxMethodDecl(ofClass(hasName("Z"))).bind("id"), "void operator delete(void *) noexcept")); - // Should be: with semicolon, without noexcept? + // Should be: without noexcept? } TEST(DeclPrinter, TestCXXMethodDecl_AllocationFunction4) { @@ -654,7 +626,6 @@ "};", cxxMethodDecl(ofClass(hasName("Z"))).bind("id"), "void operator delete(void *)")); - // Should be: with semicolon } TEST(DeclPrinter, TestCXXMethodDecl_AllocationFunction5) { @@ -664,7 +635,7 @@ "};", cxxMethodDecl(ofClass(hasName("Z"))).bind("id"), "void operator delete[](void *) noexcept")); - // Should be: with semicolon, without noexcept? + // Should be: without noexcept? } TEST(DeclPrinter, TestCXXMethodDecl_Operator1) { @@ -686,7 +657,6 @@ Expected.append("void operator"); Expected.append(OperatorNames[i]); Expected.append("(Z z)"); - // Should be: with semicolon ASSERT_TRUE(PrintedDeclCXX98Matches( Code, @@ -710,7 +680,6 @@ Expected.append("void operator"); Expected.append(OperatorNames[i]); Expected.append("()"); - // Should be: with semicolon ASSERT_TRUE(PrintedDeclCXX98Matches( Code, @@ -726,7 +695,6 @@ "};", "A", "void A(int a)")); - // Should be: with semicolon } TEST(DeclPrinter, TestCXXMethodDecl2) { @@ -736,7 +704,6 @@ "};", "A", "virtual void A(int a)")); - // Should be: with semicolon } TEST(DeclPrinter, TestCXXMethodDecl3) { @@ -749,7 +716,6 @@ "};", "ZZ::A", "void A(int a)")); - // Should be: with semicolon // TODO: should we print "virtual"? } @@ -760,7 +726,6 @@ "};", "A", "inline void A(int a)")); - // Should be: with semicolon } TEST(DeclPrinter, TestCXXMethodDecl5) { @@ -770,7 +735,6 @@ "};", "A", "virtual void A(int a) = 0")); - // Should be: with semicolon } TEST(DeclPrinter, TestCXXMethodDecl_CVQualifier1) { @@ -780,7 +744,6 @@ "};", "A", "void A(int a) const")); - // Should be: with semicolon } TEST(DeclPrinter, TestCXXMethodDecl_CVQualifier2) { @@ -790,7 +753,6 @@ "};", "A", "void A(int a) volatile")); - // Should be: with semicolon } TEST(DeclPrinter, TestCXXMethodDecl_CVQualifier3) { @@ -800,7 +762,6 @@ "};", "A", "void A(int a) const volatile")); - // Should be: with semicolon } TEST(DeclPrinter, TestCXXMethodDecl_RefQualifier1) { @@ -810,7 +771,6 @@ "};", "A", "void A(int a) &")); - // Should be: with semicolon } TEST(DeclPrinter, TestCXXMethodDecl_RefQualifier2) { @@ -820,7 +780,6 @@ "};", "A", "void A(int a) &&")); - // Should be: with semicolon } TEST(DeclPrinter, TestFunctionDecl_ExceptionSpecification1) { @@ -830,7 +789,6 @@ "};", "A", "void A(int a) throw()")); - // Should be: with semicolon } TEST(DeclPrinter, TestFunctionDecl_ExceptionSpecification2) { @@ -840,7 +798,6 @@ "};", "A", "void A(int a) throw(int)")); - // Should be: with semicolon } TEST(DeclPrinter, TestFunctionDecl_ExceptionSpecification3) { @@ -851,7 +808,6 @@ "};", "A", "void A(int a) throw(ZZ, int)")); - // Should be: with semicolon } TEST(DeclPrinter, TestFunctionDecl_ExceptionSpecification4) { @@ -861,7 +817,6 @@ "};", "A", "void A(int a) noexcept")); - // Should be: with semicolon } TEST(DeclPrinter, TestFunctionDecl_ExceptionSpecification5) { @@ -942,98 +897,87 @@ "template<typename T>" "struct A { T a; };", classTemplateDecl(hasName("A")).bind("id"), - "template <typename T> struct A {\n}")); - // Should be: with semicolon, with { ... } + "template <typename T> struct A {}")); } TEST(DeclPrinter, TestClassTemplateDecl2) { ASSERT_TRUE(PrintedDeclCXX98Matches( "template<typename T = int>" "struct A { T a; };", classTemplateDecl(hasName("A")).bind("id"), - "template <typename T = int> struct A {\n}")); - // Should be: with semicolon, with { ... } + "template <typename T = int> struct A {}")); } TEST(DeclPrinter, TestClassTemplateDecl3) { ASSERT_TRUE(PrintedDeclCXX98Matches( "template<class T>" "struct A { T a; };", classTemplateDecl(hasName("A")).bind("id"), - "template <class T> struct A {\n}")); - // Should be: with semicolon, with { ... } + "template <class T> struct A {}")); } TEST(DeclPrinter, TestClassTemplateDecl4) { ASSERT_TRUE(PrintedDeclCXX98Matches( "template<typename T, typename U>" "struct A { T a; U b; };", classTemplateDecl(hasName("A")).bind("id"), - "template <typename T, typename U> struct A {\n}")); - // Should be: with semicolon, with { ... } + "template <typename T, typename U> struct A {}")); } TEST(DeclPrinter, TestClassTemplateDecl5) { ASSERT_TRUE(PrintedDeclCXX98Matches( "template<int N>" "struct A { int a[N]; };", classTemplateDecl(hasName("A")).bind("id"), - "template <int N> struct A {\n}")); - // Should be: with semicolon, with { ... } + "template <int N> struct A {}")); } TEST(DeclPrinter, TestClassTemplateDecl6) { ASSERT_TRUE(PrintedDeclCXX98Matches( "template<int N = 42>" "struct A { int a[N]; };", classTemplateDecl(hasName("A")).bind("id"), - "template <int N = 42> struct A {\n}")); - // Should be: with semicolon, with { ... } + "template <int N = 42> struct A {}")); } TEST(DeclPrinter, TestClassTemplateDecl7) { ASSERT_TRUE(PrintedDeclCXX98Matches( "typedef int MyInt;" "template<MyInt N>" "struct A { int a[N]; };", classTemplateDecl(hasName("A")).bind("id"), - "template <MyInt N> struct A {\n}")); - // Should be: with semicolon, with { ... } + "template <MyInt N> struct A {}")); } TEST(DeclPrinter, TestClassTemplateDecl8) { ASSERT_TRUE(PrintedDeclCXX98Matches( "template<template<typename U> class T> struct A { };", classTemplateDecl(hasName("A")).bind("id"), - "template <template <typename U> class T> struct A {\n}")); - // Should be: with semicolon, with { ... } + "template <template <typename U> class T> struct A {}")); } TEST(DeclPrinter, TestClassTemplateDecl9) { ASSERT_TRUE(PrintedDeclCXX98Matches( "template<typename T> struct Z { };" "template<template<typename U> class T = Z> struct A { };", classTemplateDecl(hasName("A")).bind("id"), - "template <template <typename U> class T> struct A {\n}")); - // Should be: with semicolon, with { ... } + "template <template <typename U> class T> struct A {}")); } TEST(DeclPrinter, TestClassTemplateDecl10) { ASSERT_TRUE(PrintedDeclCXX11Matches( "template<typename... T>" "struct A { int a; };", classTemplateDecl(hasName("A")).bind("id"), - "template <typename ...T> struct A {\n}")); - // Should be: with semicolon, with { ... } + "template <typename ...T> struct A {}")); } TEST(DeclPrinter, TestClassTemplateDecl11) { ASSERT_TRUE(PrintedDeclCXX11Matches( "template<typename... T>" "struct A : public T... { int a; };", classTemplateDecl(hasName("A")).bind("id"), - "template <typename ...T> struct A : public T... {\n}")); - // Should be: with semicolon, with { ... } + "template <typename ...T> struct A : public T... {}")); } TEST(DeclPrinter, TestClassTemplatePartialSpecializationDecl1) { @@ -1043,8 +987,7 @@ "template<typename T>" "struct A<T, int> { T a; };", classTemplateSpecializationDecl().bind("id"), - "struct A {\n}")); - // WRONG; Should be: "template<typename T> struct A<T, int> { ... }" + "template <typename T> struct A<T, int> {}")); } TEST(DeclPrinter, TestClassTemplatePartialSpecializationDecl2) { @@ -1054,7 +997,7 @@ "template<typename T>" "struct A<T *> { T a; };", classTemplateSpecializationDecl().bind("id"), - "struct A {\n}")); + "template <typename T> struct A<type-parameter-0-0 *> {}")); // WRONG; Should be: "template<typename T> struct A<T *> { ... }" } @@ -1065,51 +1008,45 @@ "template<>" "struct A<int> { int a; };", classTemplateSpecializationDecl().bind("id"), - "struct A {\n}")); - // WRONG; Should be: "template<> struct A<int> { ... }" + "template<> struct A<int> {}")); } TEST(DeclPrinter, TestFunctionTemplateDecl1) { ASSERT_TRUE(PrintedDeclCXX98Matches( "template<typename T>" "void A(T &t);", functionTemplateDecl(hasName("A")).bind("id"), "template <typename T> void A(T &t)")); - // Should be: with semicolon } TEST(DeclPrinter, TestFunctionTemplateDecl2) { ASSERT_TRUE(PrintedDeclCXX98Matches( "template<typename T>" "void A(T &t) { }", functionTemplateDecl(hasName("A")).bind("id"), "template <typename T> void A(T &t)")); - // Should be: with semicolon } TEST(DeclPrinter, TestFunctionTemplateDecl3) { ASSERT_TRUE(PrintedDeclCXX11Matches( "template<typename... T>" "void A(T... a);", functionTemplateDecl(hasName("A")).bind("id"), "template <typename ...T> void A(T ...a)")); - // Should be: with semicolon. } TEST(DeclPrinter, TestFunctionTemplateDecl4) { ASSERT_TRUE(PrintedDeclCXX98Matches( "struct Z { template<typename T> void A(T t); };", functionTemplateDecl(hasName("A")).bind("id"), "template <typename T> void A(T t)")); - // Should be: with semicolon } TEST(DeclPrinter, TestFunctionTemplateDecl5) { ASSERT_TRUE(PrintedDeclCXX98Matches( "struct Z { template<typename T> void A(T t) {} };", functionTemplateDecl(hasName("A")).bind("id"), "template <typename T> void A(T t)")); - // Should be: with semicolon } TEST(DeclPrinter, TestFunctionTemplateDecl6) { @@ -1119,7 +1056,6 @@ "};", functionTemplateDecl(hasName("A")).bind("id"), "template <typename U> void A(U t)")); - // Should be: with semicolon } TEST(DeclPrinter, TestTemplateArgumentList1) { Index: cfe/trunk/unittests/AST/ASTTypeTraitsTest.cpp =================================================================== --- cfe/trunk/unittests/AST/ASTTypeTraitsTest.cpp +++ cfe/trunk/unittests/AST/ASTTypeTraitsTest.cpp @@ -163,7 +163,7 @@ TEST(DynTypedNode, DeclPrint) { PrintVerifier Verifier; - Verifier.expectString("void f() {\n}\n\n"); + Verifier.expectString("void f() {\n}\n"); EXPECT_TRUE(Verifier.match("void f() {}", functionDecl())); } Index: cfe/trunk/test/SemaTemplate/temp_arg_enum_printing.cpp =================================================================== --- cfe/trunk/test/SemaTemplate/temp_arg_enum_printing.cpp +++ cfe/trunk/test/SemaTemplate/temp_arg_enum_printing.cpp @@ -13,11 +13,11 @@ void foo(); void test() { - // CHECK: template <NamedEnumNS::NamedEnum E = NamedEnumNS::NamedEnum::Val0> + // CHECK: template<> void foo<NamedEnumNS::NamedEnum::Val0>() NamedEnumNS::foo<Val0>(); - // CHECK: template <NamedEnumNS::NamedEnum E = NamedEnumNS::NamedEnum::Val1> + // CHECK: template<> void foo<NamedEnumNS::NamedEnum::Val1>() NamedEnumNS::foo<(NamedEnum)1>(); - // CHECK: template <NamedEnumNS::NamedEnum E = 2> + // CHECK: template<> void foo<2>() NamedEnumNS::foo<(NamedEnum)2>(); } Index: cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp =================================================================== --- cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp +++ cfe/trunk/test/Index/comment-to-html-xml-conversion.cpp @@ -813,7 +813,7 @@ template<> void comment_to_xml_conversion_10(int aaa, int bbb); -// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:6: FunctionDecl=comment_to_xml_conversion_10:{{.*}} FullCommentAsXML=[<Function templateKind="specialization" file="{{[^"]+}}comment-to-html-xml-conversion.cpp" line="[[@LINE-2]]" column="6"><Name>comment_to_xml_conversion_10</Name><USR>c:@F@comment_to_xml_conversion_10<#I#I>#I#I#</USR><Declaration>void comment_to_xml_conversion_10(int aaa, int bbb)</Declaration><Abstract><Para> Aaa.</Para></Abstract></Function>] +// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:6: FunctionDecl=comment_to_xml_conversion_10:{{.*}} FullCommentAsXML=[<Function templateKind="specialization" file="{{[^"]+}}comment-to-html-xml-conversion.cpp" line="[[@LINE-2]]" column="6"><Name>comment_to_xml_conversion_10</Name><USR>c:@F@comment_to_xml_conversion_10<#I#I>#I#I#</USR><Declaration>template <> void comment_to_xml_conversion_10<int, int>(int aaa, int bbb)</Declaration><Abstract><Para> Aaa.</Para></Abstract></Function>] /// Aaa. template<typename T, typename U> @@ -825,13 +825,13 @@ template<typename T> class comment_to_xml_conversion_11<T, int> { }; -// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:7: ClassTemplatePartialSpecialization=comment_to_xml_conversion_11:{{.*}} FullCommentAsXML=[<Class templateKind="partialSpecialization" file="{{[^"]+}}comment-to-html-xml-conversion.cpp" line="[[@LINE-2]]" column="7"><Name>comment_to_xml_conversion_11</Name><USR>c:@SP>1#T@comment_to_xml_conversion_11>#t0.0#I</USR><Declaration>class comment_to_xml_conversion_11 {}</Declaration><Abstract><Para> Aaa.</Para></Abstract></Class>] +// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:7: ClassTemplatePartialSpecialization=comment_to_xml_conversion_11:{{.*}} FullCommentAsXML=[<Class templateKind="partialSpecialization" file="{{[^"]+}}comment-to-html-xml-conversion.cpp" line="[[@LINE-2]]" column="7"><Name>comment_to_xml_conversion_11</Name><USR>c:@SP>1#T@comment_to_xml_conversion_11>#t0.0#I</USR><Declaration>template <typename T> class comment_to_xml_conversion_11<T, int> {}</Declaration><Abstract><Para> Aaa.</Para></Abstract></Class>] /// Aaa. template<> class comment_to_xml_conversion_11<int, int> { }; -// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:7: ClassDecl=comment_to_xml_conversion_11:{{.*}} FullCommentAsXML=[<Class templateKind="specialization" file="{{[^"]+}}comment-to-html-xml-conversion.cpp" line="[[@LINE-2]]" column="7"><Name>comment_to_xml_conversion_11</Name><USR>c:@S@comment_to_xml_conversion_11>#I#I</USR><Declaration>class comment_to_xml_conversion_11 {}</Declaration><Abstract><Para> Aaa.</Para></Abstract></Class>] +// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:7: ClassDecl=comment_to_xml_conversion_11:{{.*}} FullCommentAsXML=[<Class templateKind="specialization" file="{{[^"]+}}comment-to-html-xml-conversion.cpp" line="[[@LINE-2]]" column="7"><Name>comment_to_xml_conversion_11</Name><USR>c:@S@comment_to_xml_conversion_11>#I#I</USR><Declaration>template <> class comment_to_xml_conversion_11<int, int> {}</Declaration><Abstract><Para> Aaa.</Para></Abstract></Class>] /// Aaa. int comment_to_xml_conversion_12; Index: cfe/trunk/test/Index/comment-cplus-decls.cpp =================================================================== --- cfe/trunk/test/Index/comment-cplus-decls.cpp +++ cfe/trunk/test/Index/comment-cplus-decls.cpp @@ -40,7 +40,7 @@ data* reserved; }; // CHECK: <Declaration>class Test {}</Declaration> -// CHECK: <Declaration>Test() : reserved(new Test::data())</Declaration> +// CHECK: <Declaration>Test() : reserved(new Test::data()) {}</Declaration> // CHECK: <Declaration>unsigned int getID() const</Declaration> // CHECK: <Declaration>~Test()</Declaration> // CHECK: <Declaration>Test::data *reserved</Declaration> Index: cfe/trunk/test/OpenMP/for_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/for_ast_print.cpp +++ cfe/trunk/test/OpenMP/for_ast_print.cpp @@ -50,15 +50,15 @@ } }; -// CHECK: #pragma omp for private(this->a) private(this->a) private(this->S::a) -// CHECK: #pragma omp for lastprivate(this->a) lastprivate(this->a) lastprivate(this->S::a) -// CHECK: #pragma omp for linear(val(this->c)) // CHECK: #pragma omp for private(this->a) private(this->a) private(T::a) // CHECK: #pragma omp for lastprivate(this->a) lastprivate(this->a) lastprivate(T::a) // CHECK: #pragma omp for linear(val(this->c)) // CHECK: #pragma omp for private(this->a) private(this->a) // CHECK: #pragma omp for lastprivate(this->a) lastprivate(this->a) // CHECK: #pragma omp for linear(uval(this->b)) +// CHECK: #pragma omp for private(this->a) private(this->a) private(this->S::a) +// CHECK: #pragma omp for lastprivate(this->a) lastprivate(this->a) lastprivate(this->S::a) +// CHECK: #pragma omp for linear(val(this->c)) class S8 : public S7<S> { S8() {} @@ -137,6 +137,7 @@ } int main(int argc, char **argv) { +// CHECK: int main(int argc, char **argv) { int b = argc, c, d, e, f, g; static int a; // CHECK: static int a; Index: cfe/trunk/test/OpenMP/declare_target_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/declare_target_ast_print.cpp +++ cfe/trunk/test/OpenMP/declare_target_ast_print.cpp @@ -34,7 +34,12 @@ #pragma omp declare target template <class T> struct C { -// CHECK: template <class T = int> struct C +// CHECK: template <class T> struct C { +// CHECK: #pragma omp declare target +// CHECK-NEXT: static T ts; +// CHECK-NEXT: #pragma omp end declare target + +// CHECK: template<> struct C<int> T t; // CHECK-NEXT: int t; static T ts; @@ -59,11 +64,6 @@ // CHECK: #pragma omp end declare target }; -// CHECK: template <class T> struct C { -// CHECK: #pragma omp declare target -// CHECK-NEXT: static T ts; -// CHECK-NEXT: #pragma omp end declare target - template<class T> T C<T>::ts = 1; // CHECK: #pragma omp declare target Index: cfe/trunk/test/OpenMP/target_update_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_update_ast_print.cpp +++ cfe/trunk/test/OpenMP/target_update_ast_print.cpp @@ -18,18 +18,18 @@ #pragma omp target update from(b) if(l<5) device(l-1) nowait depend(inout:l) return a + targ + (T)b; } -// CHECK: static int a; -// CHECK-NEXT: float b; +// CHECK: static T a; +// CHECK-NEXT: U b; // CHECK-NEXT: int l; // CHECK-NEXT: #pragma omp target update to(a) if(l > 5) device(l) nowait depend(inout : l) // CHECK-NEXT: #pragma omp target update from(b) if(l < 5) device(l - 1) nowait depend(inout : l) -// CHECK: static char a; +// CHECK: static int a; // CHECK-NEXT: float b; // CHECK-NEXT: int l; // CHECK-NEXT: #pragma omp target update to(a) if(l > 5) device(l) nowait depend(inout : l) // CHECK-NEXT: #pragma omp target update from(b) if(l < 5) device(l - 1) nowait depend(inout : l) -// CHECK: static T a; -// CHECK-NEXT: U b; +// CHECK: static char a; +// CHECK-NEXT: float b; // CHECK-NEXT: int l; // CHECK-NEXT: #pragma omp target update to(a) if(l > 5) device(l) nowait depend(inout : l) // CHECK-NEXT: #pragma omp target update from(b) if(l < 5) device(l - 1) nowait depend(inout : l) Index: cfe/trunk/test/OpenMP/distribute_parallel_for_simd_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/distribute_parallel_for_simd_ast_print.cpp +++ cfe/trunk/test/OpenMP/distribute_parallel_for_simd_ast_print.cpp @@ -37,9 +37,9 @@ } }; -// CHECK: #pragma omp distribute parallel for simd private(this->a) private(this->a) private(this->S::a) // CHECK: #pragma omp distribute parallel for simd private(this->a) private(this->a) private(T::a) // CHECK: #pragma omp distribute parallel for simd private(this->a) private(this->a) +// CHECK: #pragma omp distribute parallel for simd private(this->a) private(this->a) private(this->S::a) class S8 : public S7<S> { S8() {} Index: cfe/trunk/test/OpenMP/teams_distribute_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/teams_distribute_ast_print.cpp +++ cfe/trunk/test/OpenMP/teams_distribute_ast_print.cpp @@ -45,13 +45,13 @@ } }; // CHECK: #pragma omp target -// CHECK-NEXT: #pragma omp teams distribute private(this->a) private(this->a) private(this->S::a) -// CHECK: #pragma omp target // CHECK-NEXT: #pragma omp teams distribute private(this->a) private(this->a) private(T::a) // CHECK: #pragma omp target // CHECK-NEXT: #pragma omp teams distribute private(this->a) private(this->a) // CHECK: #pragma omp target // CHECK-NEXT: #pragma omp teams distribute default(none) private(b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d) +// CHECK: #pragma omp target +// CHECK-NEXT: #pragma omp teams distribute private(this->a) private(this->a) private(this->S::a) class S8 : public S7<S> { S8() {} Index: cfe/trunk/test/OpenMP/ordered_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/ordered_ast_print.cpp +++ cfe/trunk/test/OpenMP/ordered_ast_print.cpp @@ -51,7 +51,7 @@ return (0); } -// CHECK: static int a; +// CHECK: static T a; // CHECK-NEXT: #pragma omp for ordered // CHECK-NEXT: for (int i = 0; i < argc; ++i) // CHECK-NEXT: #pragma omp ordered @@ -85,10 +85,10 @@ // CHECK-NEXT: #pragma omp parallel for ordered(1) // CHECK-NEXT: for (int i = 0; i < argc; ++i) { // CHECK-NEXT: #pragma omp ordered depend(source) -// CHECK-NEXT: #pragma omp ordered depend(sink : i + 3) +// CHECK-NEXT: #pragma omp ordered depend(sink : i + N) // CHECK-NEXT: a = 2; // CHECK-NEXT: } -// CHECK: static T a; +// CHECK: static int a; // CHECK-NEXT: #pragma omp for ordered // CHECK-NEXT: for (int i = 0; i < argc; ++i) // CHECK-NEXT: #pragma omp ordered @@ -122,7 +122,7 @@ // CHECK-NEXT: #pragma omp parallel for ordered(1) // CHECK-NEXT: for (int i = 0; i < argc; ++i) { // CHECK-NEXT: #pragma omp ordered depend(source) -// CHECK-NEXT: #pragma omp ordered depend(sink : i + N) +// CHECK-NEXT: #pragma omp ordered depend(sink : i + 3) // CHECK-NEXT: a = 2; // CHECK-NEXT: } Index: cfe/trunk/test/OpenMP/teams_distribute_simd_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/teams_distribute_simd_ast_print.cpp +++ cfe/trunk/test/OpenMP/teams_distribute_simd_ast_print.cpp @@ -54,15 +54,15 @@ } }; // CHECK: #pragma omp target -// CHECK-NEXT: #pragma omp teams distribute simd private(this->a) private(this->a) private(this->S::a) -// CHECK: #pragma omp target // CHECK-NEXT: #pragma omp teams distribute simd private(this->a) private(this->a) private(T::a) // CHECK: #pragma omp target // CHECK-NEXT: #pragma omp teams distribute simd private(this->a) private(this->a) // CHECK: #pragma omp target // CHECK-NEXT: #pragma omp teams distribute simd default(none) private(b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(f) thread_limit(d) // CHECK: #pragma omp target // CHECK-NEXT: #pragma omp teams distribute simd simdlen(slen1) safelen(slen2) aligned(arr: alen) +// CHECK: #pragma omp target +// CHECK-NEXT: #pragma omp teams distribute simd private(this->a) private(this->a) private(this->S::a) class S8 : public S7<S> { S8() {} Index: cfe/trunk/test/OpenMP/target_data_use_device_ptr_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_data_use_device_ptr_ast_print.cpp +++ cfe/trunk/test/OpenMP/target_data_use_device_ptr_ast_print.cpp @@ -110,7 +110,7 @@ return 0; } -// CHECK: template <typename T = int> int tmain(int argc) { +// CHECK: template<> int tmain<int>(int argc) { // CHECK-NEXT: int i; // CHECK-NEXT: int &j = i; // CHECK-NEXT: int *k = &j; @@ -120,7 +120,7 @@ // CHECK-NEXT: } // CHECK-NEXT: #pragma omp target data map(tofrom: i) use_device_ptr(z) -// CHECK: template <typename T = int *> int *tmain(int *argc) { +// CHECK: template<> int *tmain<int *>(int *argc) { // CHECK-NEXT: int *i; // CHECK-NEXT: int *&j = i; // CHECK-NEXT: int **k = &j; Index: cfe/trunk/test/OpenMP/target_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_ast_print.cpp +++ cfe/trunk/test/OpenMP/target_ast_print.cpp @@ -34,13 +34,13 @@ return 0; } -// CHECK: template <typename T = int, int C = 5> int tmain(int argc, int *argv) { -// CHECK-NEXT: int i, j, a[20] +// CHECK: template <typename T, int C> T tmain(T argc, T *argv) { +// CHECK-NEXT: T i, j, a[20] // CHECK-NEXT: #pragma omp target // CHECK-NEXT: foo(); // CHECK-NEXT: #pragma omp target if(target: argc > 0) // CHECK-NEXT: foo() -// CHECK-NEXT: #pragma omp target if(5) +// CHECK-NEXT: #pragma omp target if(C) // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp target map(tofrom: i) // CHECK-NEXT: foo() @@ -56,13 +56,13 @@ // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp target defaultmap(tofrom: scalar) // CHECK-NEXT: foo() -// CHECK: template <typename T = char, int C = 1> char tmain(char argc, char *argv) { -// CHECK-NEXT: char i, j, a[20] +// CHECK: template<> int tmain<int, 5>(int argc, int *argv) { +// CHECK-NEXT: int i, j, a[20] // CHECK-NEXT: #pragma omp target // CHECK-NEXT: foo(); // CHECK-NEXT: #pragma omp target if(target: argc > 0) // CHECK-NEXT: foo() -// CHECK-NEXT: #pragma omp target if(1) +// CHECK-NEXT: #pragma omp target if(5) // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp target map(tofrom: i) // CHECK-NEXT: foo() @@ -78,13 +78,13 @@ // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp target defaultmap(tofrom: scalar) // CHECK-NEXT: foo() -// CHECK: template <typename T, int C> T tmain(T argc, T *argv) { -// CHECK-NEXT: T i, j, a[20] +// CHECK: template<> char tmain<char, 1>(char argc, char *argv) { +// CHECK-NEXT: char i, j, a[20] // CHECK-NEXT: #pragma omp target // CHECK-NEXT: foo(); // CHECK-NEXT: #pragma omp target if(target: argc > 0) // CHECK-NEXT: foo() -// CHECK-NEXT: #pragma omp target if(C) +// CHECK-NEXT: #pragma omp target if(1) // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp target map(tofrom: i) // CHECK-NEXT: foo() Index: cfe/trunk/test/OpenMP/single_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/single_ast_print.cpp +++ cfe/trunk/test/OpenMP/single_ast_print.cpp @@ -57,6 +57,7 @@ } int main(int argc, char **argv) { +// CHECK: int main(int argc, char **argv) { int b = argc, c, d, e, f, g; static int a; SS ss(a); Index: cfe/trunk/test/OpenMP/flush_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/flush_ast_print.cpp +++ cfe/trunk/test/OpenMP/flush_ast_print.cpp @@ -15,13 +15,13 @@ #pragma omp flush(a) return a + argc; } -// CHECK: static int a; +// CHECK: static T a; // CHECK-NEXT: #pragma omp flush // CHECK-NEXT: #pragma omp flush (a) -// CHECK: static char a; +// CHECK: static int a; // CHECK-NEXT: #pragma omp flush // CHECK-NEXT: #pragma omp flush (a) -// CHECK: static T a; +// CHECK: static char a; // CHECK-NEXT: #pragma omp flush // CHECK-NEXT: #pragma omp flush (a) Index: cfe/trunk/test/OpenMP/taskwait_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/taskwait_ast_print.cpp +++ cfe/trunk/test/OpenMP/taskwait_ast_print.cpp @@ -14,12 +14,12 @@ #pragma omp taskwait return a + argc; } +// CHECK: static T a; +// CHECK-NEXT: #pragma omp taskwait // CHECK: static int a; // CHECK-NEXT: #pragma omp taskwait // CHECK: static char a; // CHECK-NEXT: #pragma omp taskwait -// CHECK: static T a; -// CHECK-NEXT: #pragma omp taskwait int main(int argc, char **argv) { static int a; Index: cfe/trunk/test/OpenMP/target_enter_data_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_enter_data_ast_print.cpp +++ cfe/trunk/test/OpenMP/target_enter_data_ast_print.cpp @@ -62,8 +62,8 @@ return 0; } -// CHECK: template <typename T = int, int C = 5> int tmain(int argc, int *argv) { -// CHECK-NEXT: int i, j, b, c, d, e, x[20]; +// CHECK: template <typename T, int C> T tmain(T argc, T *argv) { +// CHECK-NEXT: T i, j, b, c, d, e, x[20]; // CHECK-NEXT: i = argc; // CHECK-NEXT: #pragma omp target enter data map(to: i) // CHECK-NEXT: #pragma omp target enter data map(to: i) if(target enter data: j > 0) @@ -89,8 +89,8 @@ // CHECK-NEXT: #pragma omp target enter data nowait map(alloc: x[0:10],c) depend(in : argc,argv[i:argc],x[:]) // CHECK-NEXT: #pragma omp target enter data nowait depend(in : argc,argv[i:argc],x[:]) map(to: c) map(alloc: d) // CHECK-NEXT: #pragma omp target enter data nowait map(always,alloc: e) depend(in : argc,argv[i:argc],x[:]) -// CHECK: template <typename T = char, int C = 1> char tmain(char argc, char *argv) { -// CHECK-NEXT: char i, j, b, c, d, e, x[20]; +// CHECK: template<> int tmain<int, 5>(int argc, int *argv) { +// CHECK-NEXT: int i, j, b, c, d, e, x[20]; // CHECK-NEXT: i = argc; // CHECK-NEXT: #pragma omp target enter data map(to: i) // CHECK-NEXT: #pragma omp target enter data map(to: i) if(target enter data: j > 0) @@ -116,8 +116,8 @@ // CHECK-NEXT: #pragma omp target enter data nowait map(alloc: x[0:10],c) depend(in : argc,argv[i:argc],x[:]) // CHECK-NEXT: #pragma omp target enter data nowait depend(in : argc,argv[i:argc],x[:]) map(to: c) map(alloc: d) // CHECK-NEXT: #pragma omp target enter data nowait map(always,alloc: e) depend(in : argc,argv[i:argc],x[:]) -// CHECK: template <typename T, int C> T tmain(T argc, T *argv) { -// CHECK-NEXT: T i, j, b, c, d, e, x[20]; +// CHECK: template<> char tmain<char, 1>(char argc, char *argv) { +// CHECK-NEXT: char i, j, b, c, d, e, x[20]; // CHECK-NEXT: i = argc; // CHECK-NEXT: #pragma omp target enter data map(to: i) // CHECK-NEXT: #pragma omp target enter data map(to: i) if(target enter data: j > 0) Index: cfe/trunk/test/OpenMP/taskloop_simd_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/taskloop_simd_ast_print.cpp +++ cfe/trunk/test/OpenMP/taskloop_simd_ast_print.cpp @@ -49,6 +49,7 @@ return T(); } +// CHECK-LABEL: int main(int argc, char **argv) { int main(int argc, char **argv) { int b = argc, c, d, e, f, g; static int a; Index: cfe/trunk/test/OpenMP/target_parallel_for_simd_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_parallel_for_simd_ast_print.cpp +++ cfe/trunk/test/OpenMP/target_parallel_for_simd_ast_print.cpp @@ -35,9 +35,9 @@ } }; -// CHECK: #pragma omp target parallel for simd private(this->a) private(this->a) private(this->S::a) // CHECK: #pragma omp target parallel for simd private(this->a) private(this->a) private(T::a) // CHECK: #pragma omp target parallel for simd private(this->a) private(this->a) +// CHECK: #pragma omp target parallel for simd private(this->a) private(this->a) private(this->S::a) class S8 : public S7<S> { S8() {} Index: cfe/trunk/test/OpenMP/for_simd_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/for_simd_ast_print.cpp +++ cfe/trunk/test/OpenMP/for_simd_ast_print.cpp @@ -33,9 +33,9 @@ } }; -// CHECK: #pragma omp for simd private(this->a) private(this->a) private(this->S1::a) // CHECK: #pragma omp for simd private(this->a) private(this->a) private(T::a) // CHECK: #pragma omp for simd private(this->a) private(this->a) +// CHECK: #pragma omp for simd private(this->a) private(this->a) private(this->S1::a) class S8 : public S7<S1> { S8() {} @@ -125,7 +125,7 @@ }; // S2<4>::func is called below in main. -// CHECK: template <int LEN = 4> struct S2 { +// CHECK: template<> struct S2<4> { // CHECK-NEXT: static void func(int n, float *a, float *b, float *c) { // CHECK-NEXT: int k1 = 0, k2 = 0; // CHECK-NEXT: #pragma omp for simd safelen(4) linear(k1,k2: 4) aligned(a: 4) simdlen(4) Index: cfe/trunk/test/OpenMP/distribute_dist_schedule_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/distribute_dist_schedule_ast_print.cpp +++ cfe/trunk/test/OpenMP/distribute_dist_schedule_ast_print.cpp @@ -57,6 +57,7 @@ } int main (int argc, char **argv) { +// CHECK: int main(int argc, char **argv) { int b = argc, c, d, e, f, g; static int a; // CHECK: static int a; Index: cfe/trunk/test/OpenMP/parallel_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/parallel_ast_print.cpp +++ cfe/trunk/test/OpenMP/parallel_ast_print.cpp @@ -58,18 +58,18 @@ } }; -// CHECK: #pragma omp parallel private(this->a) private(this->a) private(this->S1::a) -// CHECK: #pragma omp parallel firstprivate(this->a) firstprivate(this->a) firstprivate(this->S1::a) -// CHECK: #pragma omp parallel shared(this->a) shared(this->a) shared(this->S1::a) -// CHECK: #pragma omp parallel reduction(+: this->a) reduction(*: this->b[:]) // CHECK: #pragma omp parallel private(this->a) private(this->a) private(T::a) // CHECK: #pragma omp parallel firstprivate(this->a) firstprivate(this->a) firstprivate(T::a) // CHECK: #pragma omp parallel shared(this->a) shared(this->a) shared(T::a) // CHECK: #pragma omp parallel reduction(+: this->a) reduction(*: this->b[:]) // CHECK: #pragma omp parallel private(this->a) private(this->a) // CHECK: #pragma omp parallel firstprivate(this->a) firstprivate(this->a) // CHECK: #pragma omp parallel shared(this->a) shared(this->a) // CHECK: #pragma omp parallel reduction(&&: this->a) reduction(^: this->b[s.a.a]) +// CHECK: #pragma omp parallel private(this->a) private(this->a) private(this->S1::a) +// CHECK: #pragma omp parallel firstprivate(this->a) firstprivate(this->a) firstprivate(this->S1::a) +// CHECK: #pragma omp parallel shared(this->a) shared(this->a) shared(this->S1::a) +// CHECK: #pragma omp parallel reduction(+: this->a) reduction(*: this->b[:]) class S8 : public S7<S1> { S8() {} @@ -122,18 +122,18 @@ #pragma omp threadprivate(TS) }; -// CHECK: template <class T = int> struct S { +// CHECK: template <class T> struct S { +// CHECK: static T TS; +// CHECK-NEXT: #pragma omp threadprivate(S::TS) +// CHECK: }; +// CHECK: template<> struct S<int> { // CHECK: static int TS; // CHECK-NEXT: #pragma omp threadprivate(S<int>::TS) // CHECK-NEXT: } -// CHECK: template <class T = long> struct S { +// CHECK: template<> struct S<long> { // CHECK: static long TS; // CHECK-NEXT: #pragma omp threadprivate(S<long>::TS) // CHECK-NEXT: } -// CHECK: template <class T> struct S { -// CHECK: static T TS; -// CHECK-NEXT: #pragma omp threadprivate(S::TS) -// CHECK: }; template <typename T, int C> T tmain(T argc, T *argv) { @@ -150,7 +150,18 @@ return 0; } -// CHECK: template <typename T = int, int C = 5> int tmain(int argc, int *argv) { +// CHECK: template <typename T, int C> T tmain(T argc, T *argv) { +// CHECK-NEXT: T b = argc, c, d, e, f, g; +// CHECK-NEXT: static T a; +// CHECK-NEXT: S<T> s; +// CHECK-NEXT: T arr[C][10], arr1[C]; +// CHECK-NEXT: #pragma omp parallel +// CHECK-NEXT: a = 2; +// CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(C) copyin(S<T>::TS) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:C][0:10]) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp parallel if(C) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:C][:argc]) reduction(&&: g) +// CHECK-NEXT: foo() +// CHECK: template<> int tmain<int, 5>(int argc, int *argv) { // CHECK-NEXT: int b = argc, c, d, e, f, g; // CHECK-NEXT: static int a; // CHECK-NEXT: S<int> s; @@ -161,7 +172,7 @@ // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp parallel if(5) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:5][:argc]) reduction(&&: g) // CHECK-NEXT: foo() -// CHECK: template <typename T = long, int C = 1> long tmain(long argc, long *argv) { +// CHECK: template<> long tmain<long, 1>(long argc, long *argv) { // CHECK-NEXT: long b = argc, c, d, e, f, g; // CHECK-NEXT: static long a; // CHECK-NEXT: S<long> s; @@ -172,17 +183,6 @@ // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp parallel if(1) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:1][:argc]) reduction(&&: g) // CHECK-NEXT: foo() -// CHECK: template <typename T, int C> T tmain(T argc, T *argv) { -// CHECK-NEXT: T b = argc, c, d, e, f, g; -// CHECK-NEXT: static T a; -// CHECK-NEXT: S<T> s; -// CHECK-NEXT: T arr[C][10], arr1[C]; -// CHECK-NEXT: #pragma omp parallel -// CHECK-NEXT: a = 2; -// CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(C) copyin(S<T>::TS) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:C][0:10]) -// CHECK-NEXT: foo() -// CHECK-NEXT: #pragma omp parallel if(C) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:C][:argc]) reduction(&&: g) -// CHECK-NEXT: foo() enum Enum { }; Index: cfe/trunk/test/OpenMP/parallel_for_simd_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/parallel_for_simd_ast_print.cpp +++ cfe/trunk/test/OpenMP/parallel_for_simd_ast_print.cpp @@ -35,9 +35,9 @@ } }; -// CHECK: #pragma omp parallel for simd private(this->a) private(this->a) private(this->S1::a) // CHECK: #pragma omp parallel for simd private(this->a) private(this->a) private(T::a) // CHECK: #pragma omp parallel for simd private(this->a) private(this->a) +// CHECK: #pragma omp parallel for simd private(this->a) private(this->a) private(this->S1::a) class S8 : public S7<S1> { S8() {} @@ -126,7 +126,7 @@ }; // S2<4>::func is called below in main. -// CHECK: template <int LEN = 4> struct S2 { +// CHECK: template<> struct S2<4> { // CHECK-NEXT: static void func(int n, float *a, float *b, float *c) { // CHECK-NEXT: int k1 = 0, k2 = 0; // CHECK-NEXT: #pragma omp parallel for simd safelen(4) linear(k1,k2: 4) aligned(a: 4) simdlen(4) Index: cfe/trunk/test/OpenMP/critical_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/critical_ast_print.cpp +++ cfe/trunk/test/OpenMP/critical_ast_print.cpp @@ -9,6 +9,14 @@ void foo() {} // CHECK: template <typename T, int N> int tmain(T argc, char **argv) +// CHECK: static int a; +// CHECK-NEXT: #pragma omp critical +// CHECK-NEXT: a = 2; +// CHECK-NEXT: ++a; +// CHECK-NEXT: #pragma omp critical (the_name) hint(N) +// CHECK-NEXT: foo(); +// CHECK-NEXT: return N; +// CHECK: template<> int tmain<int, 4>(int argc, char **argv) template <typename T, int N> int tmain (T argc, char **argv) { T b = argc, c, d, e, f, g; @@ -22,9 +30,9 @@ ++a; #pragma omp critical (the_name) hint(N) foo(); -// CHECK-NEXT: #pragma omp critical (the_name) hint(N) +// CHECK-NEXT: #pragma omp critical (the_name) hint(4) // CHECK-NEXT: foo(); -// CHECK-NEXT: return N; +// CHECK-NEXT: return 4; return N; } Index: cfe/trunk/test/OpenMP/sections_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/sections_ast_print.cpp +++ cfe/trunk/test/OpenMP/sections_ast_print.cpp @@ -27,6 +27,7 @@ } int main(int argc, char **argv) { +// CHECK: int main(int argc, char **argv) { int b = argc, c, d, e, f, g; static int a; // CHECK: static int a; Index: cfe/trunk/test/OpenMP/declare_simd_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/declare_simd_ast_print.cpp +++ cfe/trunk/test/OpenMP/declare_simd_ast_print.cpp @@ -22,18 +22,16 @@ } // CHECK: #pragma omp declare simd aligned(hp) aligned(hp2) -// CHECK-NEXT: template <class C = int> void h(int *hp, int *hp2, int *hq, int *lin) { -// CHECK-NEXT: h((float *)hp, (float *)hp2, (float *)hq, (float *)lin); +// CHECK-NEXT: template <class C> void h(C *hp, C *hp2, C *hq, C *lin) { // CHECK-NEXT: } -// CHECK: #pragma omp declare simd aligned(hp) aligned(hp2) -// CHECK-NEXT: template <class C = float> void h(float *hp, float *hp2, float *hq, float *lin) { +// CHECK: #pragma omp declare simd aligned(hp) aligned(hp2) +// CHECK-NEXT: template<> void h<float>(float *hp, float *hp2, float *hq, float *lin) { // CHECK-NEXT: } -// CHECK: #pragma omp declare simd aligned(hp) aligned(hp2) -// CHECK: template <class C> void h(C *hp, C *hp2, C *hq, C *lin) { +// CHECK-NEXT: template<> void h<int>(int *hp, int *hp2, int *hq, int *lin) { +// CHECK-NEXT: h((float *)hp, (float *)hp2, (float *)hq, (float *)lin); // CHECK-NEXT: } -// // Explicit specialization with <C=int>. // Pragmas need to be same, otherwise standard says that's undefined behavior. @@ -75,11 +73,11 @@ int x[10]; }; -// CHECK: template <int X = 16, typename T = float> class TVV { -// CHECK: #pragma omp declare simd -// CHECK-NEXT: int tadd(int a, int b); -// CHECK: #pragma omp declare simd aligned(a: 16 * 2) aligned(b) linear(ref(b): 16) -// CHECK-NEXT: float taddpf(float *a, float *&b) { +// CHECK: template <int X, typename T> class TVV { +// CHECK: #pragma omp declare simd simdlen(X) +// CHECK-NEXT: int tadd(int a, int b) { +// CHECK: #pragma omp declare simd aligned(a: X * 2) aligned(b) linear(ref(b): X) +// CHECK-NEXT: float taddpf(float *a, T *&b) { // CHECK-NEXT: return *a + *b; // CHECK-NEXT: } // CHECK: #pragma omp declare simd @@ -91,20 +89,18 @@ template <int X, typename T> class TVV { public: -// CHECK: template <int X, typename T> class TVV { +// CHECK: template<> class TVV<16, float> { #pragma omp declare simd simdlen(X) int tadd(int a, int b) { return a + b; } -// CHECK: #pragma omp declare simd simdlen(X) -// CHECK-NEXT: int tadd(int a, int b) { -// CHECK-NEXT: return a + b; -// CHECK-NEXT: } +// CHECK: #pragma omp declare simd simdlen(16) +// CHECK-NEXT: int tadd(int a, int b); #pragma omp declare simd aligned(a : X * 2) aligned(b) linear(ref(b): X) float taddpf(float *a, T *&b) { return *a + *b; } -// CHECK: #pragma omp declare simd aligned(a: X * 2) aligned(b) -// CHECK-NEXT: float taddpf(float *a, T *&b) { +// CHECK: #pragma omp declare simd aligned(a: 16 * 2) aligned(b) linear(ref(b): 16) +// CHECK-NEXT: float taddpf(float *a, float *&b) { // CHECK-NEXT: return *a + *b; // CHECK-NEXT: } @@ -123,10 +119,10 @@ }; // CHECK: }; -// CHECK: #pragma omp declare simd simdlen(64) aligned(b: 64 * 2) linear(uval(c): 64) -// CHECK: template <int N = 64> void foo(int (&b)[64], float *&c) // CHECK: #pragma omp declare simd simdlen(N) aligned(b: N * 2) linear(uval(c): N) // CHECK: template <int N> void foo(int (&b)[N], float *&c) +// CHECK: #pragma omp declare simd simdlen(64) aligned(b: 64 * 2) linear(uval(c): 64) +// CHECK: template<> void foo<64>(int (&b)[64], float *&c) #pragma omp declare simd simdlen(N) aligned(b : N * 2) linear(uval(c): N) template <int N> void foo(int (&b)[N], float *&c); Index: cfe/trunk/test/OpenMP/threadprivate_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/threadprivate_ast_print.cpp +++ cfe/trunk/test/OpenMP/threadprivate_ast_print.cpp @@ -43,12 +43,12 @@ v = ST<T>::m; return v; } -//CHECK: template <class T = int> int foo() { -//CHECK-NEXT: static int v; -//CHECK-NEXT: #pragma omp threadprivate(v) //CHECK: template <class T> T foo() { //CHECK-NEXT: static T v; //CHECK-NEXT: #pragma omp threadprivate(v) +//CHECK: template<> int foo<int>() { +//CHECK-NEXT: static int v; +//CHECK-NEXT: #pragma omp threadprivate(v) namespace ns{ int a; Index: cfe/trunk/test/OpenMP/target_simd_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_simd_ast_print.cpp +++ cfe/trunk/test/OpenMP/target_simd_ast_print.cpp @@ -35,9 +35,9 @@ } }; -// CHECK: #pragma omp target simd private(this->a) private(this->a) private(this->S::a) // CHECK: #pragma omp target simd private(this->a) private(this->a) private(T::a) // CHECK: #pragma omp target simd private(this->a) private(this->a) +// CHECK: #pragma omp target simd private(this->a) private(this->a) private(this->S::a) class S8 : public S7<S> { S8() {} Index: cfe/trunk/test/OpenMP/target_is_device_ptr_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_is_device_ptr_ast_print.cpp +++ cfe/trunk/test/OpenMP/target_is_device_ptr_ast_print.cpp @@ -172,7 +172,7 @@ return 0; } -// CHECK: template <typename T = int> int tmain(int argc) { +// CHECK: template<> int tmain<int>(int argc) { // CHECK-NEXT: const int da[5] = {0}; // CHECK-NEXT: S6 h[10]; // CHECK-NEXT: auto &rh = h; @@ -202,7 +202,7 @@ // CHECK-NEXT: } // CHECK-NEXT: #pragma omp target is_device_ptr(da) -// CHECK: template <typename T = int *> int *tmain(int *argc) { +// CHECK: template<> int *tmain<int *>(int *argc) { // CHECK-NEXT: int *const da[5] = {0}; // CHECK-NEXT: S6 h[10]; // CHECK-NEXT: auto &rh = h; Index: cfe/trunk/test/OpenMP/target_data_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_data_ast_print.cpp +++ cfe/trunk/test/OpenMP/target_data_ast_print.cpp @@ -46,8 +46,8 @@ return 0; } -// CHECK: template <typename T = int, int C = 5> int tmain(int argc, int *argv) { -// CHECK-NEXT: int i, j, b, c, d, e, x[20]; +// CHECK: template <typename T, int C> T tmain(T argc, T *argv) { +// CHECK-NEXT: T i, j, b, c, d, e, x[20]; // CHECK-NEXT: #pragma omp target data map(to: c) // CHECK-NEXT: i = argc; // CHECK-NEXT: #pragma omp target data map(to: c) if(target data: j > 0) @@ -68,8 +68,8 @@ // CHECK-NEXT: { // CHECK-NEXT: #pragma omp target map(always,alloc: e) // CHECK-NEXT: foo(); -// CHECK: template <typename T = char, int C = 1> char tmain(char argc, char *argv) { -// CHECK-NEXT: char i, j, b, c, d, e, x[20]; +// CHECK: template<> int tmain<int, 5>(int argc, int *argv) { +// CHECK-NEXT: int i, j, b, c, d, e, x[20]; // CHECK-NEXT: #pragma omp target data map(to: c) // CHECK-NEXT: i = argc; // CHECK-NEXT: #pragma omp target data map(to: c) if(target data: j > 0) @@ -90,8 +90,8 @@ // CHECK-NEXT: { // CHECK-NEXT: #pragma omp target map(always,alloc: e) // CHECK-NEXT: foo(); -// CHECK: template <typename T, int C> T tmain(T argc, T *argv) { -// CHECK-NEXT: T i, j, b, c, d, e, x[20]; +// CHECK: template<> char tmain<char, 1>(char argc, char *argv) { +// CHECK-NEXT: char i, j, b, c, d, e, x[20]; // CHECK-NEXT: #pragma omp target data map(to: c) // CHECK-NEXT: i = argc; // CHECK-NEXT: #pragma omp target data map(to: c) if(target data: j > 0) Index: cfe/trunk/test/OpenMP/target_parallel_for_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_parallel_for_ast_print.cpp +++ cfe/trunk/test/OpenMP/target_parallel_for_ast_print.cpp @@ -35,9 +35,9 @@ } }; -// CHECK: #pragma omp target parallel for private(this->a) private(this->a) private(this->S::a) // CHECK: #pragma omp target parallel for private(this->a) private(this->a) private(T::a) // CHECK: #pragma omp target parallel for private(this->a) private(this->a) +// CHECK: #pragma omp target parallel for private(this->a) private(this->a) private(this->S::a) class S8 : public S7<S> { S8() {} Index: cfe/trunk/test/OpenMP/parallel_sections_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/parallel_sections_ast_print.cpp +++ cfe/trunk/test/OpenMP/parallel_sections_ast_print.cpp @@ -15,18 +15,18 @@ #pragma omp threadprivate(TS) }; -// CHECK: template <class T = int> struct S { +// CHECK: template <class T> struct S { +// CHECK: static T TS; +// CHECK-NEXT: #pragma omp threadprivate(S::TS) +// CHECK: }; +// CHECK: template<> struct S<int> { // CHECK: static int TS; // CHECK-NEXT: #pragma omp threadprivate(S<int>::TS) // CHECK-NEXT: } -// CHECK: template <class T = long> struct S { +// CHECK: template<> struct S<long> { // CHECK: static long TS; // CHECK-NEXT: #pragma omp threadprivate(S<long>::TS) // CHECK-NEXT: } -// CHECK: template <class T> struct S { -// CHECK: static T TS; -// CHECK-NEXT: #pragma omp threadprivate(S::TS) -// CHECK: }; template <typename T, int C> T tmain(T argc, T *argv) { @@ -50,55 +50,55 @@ return 0; } -// CHECK: template <typename T = int, int C = 5> int tmain(int argc, int *argv) { -// CHECK-NEXT: int b = argc, c, d, e, f, g; -// CHECK-NEXT: static int a; -// CHECK-NEXT: S<int> s; +// CHECK: template <typename T, int C> T tmain(T argc, T *argv) { +// CHECK-NEXT: T b = argc, c, d, e, f, g; +// CHECK-NEXT: static T a; +// CHECK-NEXT: S<T> s; // CHECK-NEXT: #pragma omp parallel sections // CHECK-NEXT: { // CHECK-NEXT: a = 2; // CHECK-NEXT: } -// CHECK-NEXT: #pragma omp parallel sections default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(5) copyin(S<int>::TS) proc_bind(master) reduction(+: c) reduction(max: e) +// CHECK-NEXT: #pragma omp parallel sections default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(C) copyin(S<T>::TS) proc_bind(master) reduction(+: c) reduction(max: e) // CHECK-NEXT: { // CHECK-NEXT: foo(); // CHECK-NEXT: } -// CHECK-NEXT: #pragma omp parallel sections if(5) num_threads(s) proc_bind(close) reduction(^: e,f) reduction(&&: g) lastprivate(b,c) +// CHECK-NEXT: #pragma omp parallel sections if(C) num_threads(s) proc_bind(close) reduction(^: e,f) reduction(&&: g) lastprivate(b,c) // CHECK-NEXT: { // CHECK-NEXT: foo(); // CHECK-NEXT: #pragma omp section // CHECK-NEXT: foo(); // CHECK-NEXT: } -// CHECK: template <typename T = long, int C = 1> long tmain(long argc, long *argv) { -// CHECK-NEXT: long b = argc, c, d, e, f, g; -// CHECK-NEXT: static long a; -// CHECK-NEXT: S<long> s; +// CHECK: template<> int tmain<int, 5>(int argc, int *argv) { +// CHECK-NEXT: int b = argc, c, d, e, f, g; +// CHECK-NEXT: static int a; +// CHECK-NEXT: S<int> s; // CHECK-NEXT: #pragma omp parallel sections // CHECK-NEXT: { // CHECK-NEXT: a = 2; // CHECK-NEXT: } -// CHECK-NEXT: #pragma omp parallel sections default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(1) copyin(S<long>::TS) proc_bind(master) reduction(+: c) reduction(max: e) +// CHECK-NEXT: #pragma omp parallel sections default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(5) copyin(S<int>::TS) proc_bind(master) reduction(+: c) reduction(max: e) // CHECK-NEXT: { // CHECK-NEXT: foo(); // CHECK-NEXT: } -// CHECK-NEXT: #pragma omp parallel sections if(1) num_threads(s) proc_bind(close) reduction(^: e,f) reduction(&&: g) lastprivate(b,c) +// CHECK-NEXT: #pragma omp parallel sections if(5) num_threads(s) proc_bind(close) reduction(^: e,f) reduction(&&: g) lastprivate(b,c) // CHECK-NEXT: { // CHECK-NEXT: foo(); // CHECK-NEXT: #pragma omp section // CHECK-NEXT: foo(); // CHECK-NEXT: } -// CHECK: template <typename T, int C> T tmain(T argc, T *argv) { -// CHECK-NEXT: T b = argc, c, d, e, f, g; -// CHECK-NEXT: static T a; -// CHECK-NEXT: S<T> s; +// CHECK: template<> long tmain<long, 1>(long argc, long *argv) { +// CHECK-NEXT: long b = argc, c, d, e, f, g; +// CHECK-NEXT: static long a; +// CHECK-NEXT: S<long> s; // CHECK-NEXT: #pragma omp parallel sections // CHECK-NEXT: { // CHECK-NEXT: a = 2; // CHECK-NEXT: } -// CHECK-NEXT: #pragma omp parallel sections default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(C) copyin(S<T>::TS) proc_bind(master) reduction(+: c) reduction(max: e) +// CHECK-NEXT: #pragma omp parallel sections default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(1) copyin(S<long>::TS) proc_bind(master) reduction(+: c) reduction(max: e) // CHECK-NEXT: { // CHECK-NEXT: foo(); // CHECK-NEXT: } -// CHECK-NEXT: #pragma omp parallel sections if(C) num_threads(s) proc_bind(close) reduction(^: e,f) reduction(&&: g) lastprivate(b,c) +// CHECK-NEXT: #pragma omp parallel sections if(1) num_threads(s) proc_bind(close) reduction(^: e,f) reduction(&&: g) lastprivate(b,c) // CHECK-NEXT: { // CHECK-NEXT: foo(); // CHECK-NEXT: #pragma omp section Index: cfe/trunk/test/OpenMP/target_parallel_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_parallel_ast_print.cpp +++ cfe/trunk/test/OpenMP/target_parallel_ast_print.cpp @@ -15,18 +15,18 @@ #pragma omp threadprivate(TS) }; -// CHECK: template <class T = int> struct S { +// CHECK: template <class T> struct S { +// CHECK: static T TS; +// CHECK-NEXT: #pragma omp threadprivate(S::TS) +// CHECK: }; +// CHECK: template<> struct S<int> { // CHECK: static int TS; // CHECK-NEXT: #pragma omp threadprivate(S<int>::TS) // CHECK-NEXT: } -// CHECK: template <class T = char> struct S { +// CHECK: template<> struct S<char> { // CHECK: static char TS; // CHECK-NEXT: #pragma omp threadprivate(S<char>::TS) // CHECK-NEXT: } -// CHECK: template <class T> struct S { -// CHECK: static T TS; -// CHECK-NEXT: #pragma omp threadprivate(S::TS) -// CHECK: }; template <typename T, int C> T tmain(T argc, T *argv) { @@ -64,23 +64,23 @@ return 0; } -// CHECK: template <typename T = int, int C = 5> int tmain(int argc, int *argv) { -// CHECK-NEXT: int b = argc, c, d, e, f, g; -// CHECK-NEXT: static int h; -// CHECK-NEXT: S<int> s; -// CHECK-NEXT: int arr[5][10], arr1[5]; -// CHECK-NEXT: int i, j, a[20] +// CHECK: template <typename T, int C> T tmain(T argc, T *argv) { +// CHECK-NEXT: T b = argc, c, d, e, f, g; +// CHECK-NEXT: static T h; +// CHECK-NEXT: S<T> s; +// CHECK-NEXT: T arr[C][10], arr1[C]; +// CHECK-NEXT: T i, j, a[20] // CHECK-NEXT: #pragma omp target parallel // CHECK-NEXT: h = 2; -// CHECK-NEXT: #pragma omp target parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(5) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:5][0:10]) +// CHECK-NEXT: #pragma omp target parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(C) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:C][0:10]) // CHECK-NEXT: foo() -// CHECK-NEXT: #pragma omp target parallel if(5) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:5][:argc]) reduction(&&: g) +// CHECK-NEXT: #pragma omp target parallel if(C) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:C][:argc]) reduction(&&: g) // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp target parallel if(target: argc > 0) // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp target parallel if(parallel: argc > 0) // CHECK-NEXT: foo() -// CHECK-NEXT: #pragma omp target parallel if(5) +// CHECK-NEXT: #pragma omp target parallel if(C) // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp target parallel map(tofrom: i) // CHECK-NEXT: foo() @@ -96,23 +96,23 @@ // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp target parallel defaultmap(tofrom: scalar) // CHECK-NEXT: foo() -// CHECK: template <typename T = char, int C = 1> char tmain(char argc, char *argv) { -// CHECK-NEXT: char b = argc, c, d, e, f, g; -// CHECK-NEXT: static char h; -// CHECK-NEXT: S<char> s; -// CHECK-NEXT: char arr[1][10], arr1[1]; -// CHECK-NEXT: char i, j, a[20] +// CHECK: template<> int tmain<int, 5>(int argc, int *argv) { +// CHECK-NEXT: int b = argc, c, d, e, f, g; +// CHECK-NEXT: static int h; +// CHECK-NEXT: S<int> s; +// CHECK-NEXT: int arr[5][10], arr1[5]; +// CHECK-NEXT: int i, j, a[20] // CHECK-NEXT: #pragma omp target parallel // CHECK-NEXT: h = 2; -// CHECK-NEXT: #pragma omp target parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(1) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:1][0:10]) +// CHECK-NEXT: #pragma omp target parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(5) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:5][0:10]) // CHECK-NEXT: foo() -// CHECK-NEXT: #pragma omp target parallel if(1) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:1][:argc]) reduction(&&: g) +// CHECK-NEXT: #pragma omp target parallel if(5) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:5][:argc]) reduction(&&: g) // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp target parallel if(target: argc > 0) // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp target parallel if(parallel: argc > 0) // CHECK-NEXT: foo() -// CHECK-NEXT: #pragma omp target parallel if(1) +// CHECK-NEXT: #pragma omp target parallel if(5) // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp target parallel map(tofrom: i) // CHECK-NEXT: foo() @@ -128,23 +128,23 @@ // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp target parallel defaultmap(tofrom: scalar) // CHECK-NEXT: foo() -// CHECK: template <typename T, int C> T tmain(T argc, T *argv) { -// CHECK-NEXT: T b = argc, c, d, e, f, g; -// CHECK-NEXT: static T h; -// CHECK-NEXT: S<T> s; -// CHECK-NEXT: T arr[C][10], arr1[C]; -// CHECK-NEXT: T i, j, a[20] +// CHECK: template<> char tmain<char, 1>(char argc, char *argv) { +// CHECK-NEXT: char b = argc, c, d, e, f, g; +// CHECK-NEXT: static char h; +// CHECK-NEXT: S<char> s; +// CHECK-NEXT: char arr[1][10], arr1[1]; +// CHECK-NEXT: char i, j, a[20] // CHECK-NEXT: #pragma omp target parallel // CHECK-NEXT: h = 2; -// CHECK-NEXT: #pragma omp target parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(C) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:C][0:10]) +// CHECK-NEXT: #pragma omp target parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(1) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:1][0:10]) // CHECK-NEXT: foo() -// CHECK-NEXT: #pragma omp target parallel if(C) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:C][:argc]) reduction(&&: g) +// CHECK-NEXT: #pragma omp target parallel if(1) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:1][:argc]) reduction(&&: g) // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp target parallel if(target: argc > 0) // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp target parallel if(parallel: argc > 0) // CHECK-NEXT: foo() -// CHECK-NEXT: #pragma omp target parallel if(C) +// CHECK-NEXT: #pragma omp target parallel if(1) // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp target parallel map(tofrom: i) // CHECK-NEXT: foo() Index: cfe/trunk/test/OpenMP/atomic_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/atomic_ast_print.cpp +++ cfe/trunk/test/OpenMP/atomic_ast_print.cpp @@ -43,7 +43,7 @@ return T(); } -// CHECK: int a = int(); +// CHECK: T a = T(); // CHECK-NEXT: #pragma omp atomic // CHECK-NEXT: a++; // CHECK-NEXT: #pragma omp atomic read @@ -74,7 +74,7 @@ // CHECK-NEXT: a = b; // CHECK-NEXT: b++; // CHECK-NEXT: } -// CHECK: T a = T(); +// CHECK: int a = int(); // CHECK-NEXT: #pragma omp atomic // CHECK-NEXT: a++; // CHECK-NEXT: #pragma omp atomic read Index: cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp +++ cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp @@ -66,8 +66,8 @@ return 0; } -// CHECK: template <typename T = int, int C = 5> int tmain(int argc, int *argv) { -// CHECK-NEXT: int i, j, b, c, d, e, x[20]; +// CHECK: template <typename T, int C> T tmain(T argc, T *argv) { +// CHECK-NEXT: T i, j, b, c, d, e, x[20]; // CHECK-NEXT: i = argc; // CHECK-NEXT: #pragma omp target exit data map(from: i) // CHECK-NEXT: #pragma omp target exit data map(from: i) if(target exit data: j > 0) @@ -95,8 +95,8 @@ // CHECK-NEXT: #pragma omp target exit data nowait map(release: x[0:10],c) depend(in : argc,argv[i:argc],x[:]) // CHECK-NEXT: #pragma omp target exit data nowait map(from: c) depend(in : argc,argv[i:argc],x[:]) map(release: d) // CHECK-NEXT: #pragma omp target exit data depend(in : argc,argv[i:argc],x[:]) nowait map(always,release: e) -// CHECK: template <typename T = char, int C = 1> char tmain(char argc, char *argv) { -// CHECK-NEXT: char i, j, b, c, d, e, x[20]; +// CHECK: template<> int tmain<int, 5>(int argc, int *argv) { +// CHECK-NEXT: int i, j, b, c, d, e, x[20]; // CHECK-NEXT: i = argc; // CHECK-NEXT: #pragma omp target exit data map(from: i) // CHECK-NEXT: #pragma omp target exit data map(from: i) if(target exit data: j > 0) @@ -124,8 +124,8 @@ // CHECK-NEXT: #pragma omp target exit data nowait map(release: x[0:10],c) depend(in : argc,argv[i:argc],x[:]) // CHECK-NEXT: #pragma omp target exit data nowait map(from: c) depend(in : argc,argv[i:argc],x[:]) map(release: d) // CHECK-NEXT: #pragma omp target exit data depend(in : argc,argv[i:argc],x[:]) nowait map(always,release: e) -// CHECK: template <typename T, int C> T tmain(T argc, T *argv) { -// CHECK-NEXT: T i, j, b, c, d, e, x[20]; +// CHECK: template<> char tmain<char, 1>(char argc, char *argv) { +// CHECK-NEXT: char i, j, b, c, d, e, x[20]; // CHECK-NEXT: i = argc; // CHECK-NEXT: #pragma omp target exit data map(from: i) // CHECK-NEXT: #pragma omp target exit data map(from: i) if(target exit data: j > 0) Index: cfe/trunk/test/OpenMP/barrier_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/barrier_ast_print.cpp +++ cfe/trunk/test/OpenMP/barrier_ast_print.cpp @@ -23,12 +23,12 @@ } return a + argc; } +// CHECK: static T a; +// CHECK-NEXT: #pragma omp barrier // CHECK: static int a; // CHECK-NEXT: #pragma omp barrier // CHECK: static char a; // CHECK-NEXT: #pragma omp barrier -// CHECK: static T a; -// CHECK-NEXT: #pragma omp barrier // CHECK-NEXT: switch (argc) { // CHECK-NEXT: case 0: // CHECK-NEXT: #pragma omp barrier Index: cfe/trunk/test/OpenMP/declare_reduction_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/declare_reduction_ast_print.cpp +++ cfe/trunk/test/OpenMP/declare_reduction_ast_print.cpp @@ -10,13 +10,12 @@ // CHECK: #pragma omp declare reduction (+ : int : omp_out *= omp_in) // CHECK-NEXT: #pragma omp declare reduction (+ : char : omp_out *= omp_in) -// CHECK: #pragma omp declare reduction (fun : int : omp_out += omp_in) initializer(omp_priv = omp_orig + 15) - template <class T> class SSS { public: #pragma omp declare reduction(fun : T : omp_out += omp_in) initializer(omp_priv = omp_orig + 15) // CHECK: #pragma omp declare reduction (fun : T : omp_out += omp_in) initializer(omp_priv = omp_orig + 15) + // CHECK: #pragma omp declare reduction (fun : int : omp_out += omp_in) initializer(omp_priv = omp_orig + 15) }; SSS<int> d; @@ -26,18 +25,18 @@ #pragma omp declare reduction(fun : SSS < int > : omp_out = omp_in) initializer(init(omp_priv, omp_orig)) // CHECK: #pragma omp declare reduction (fun : SSS<int> : omp_out = omp_in) initializer(init(omp_priv, omp_orig)) -// CHECK: template <typename T = int> int foo(int a) { -// CHECK: #pragma omp declare reduction (fun : int : omp_out += omp_in) initializer(omp_priv = omp_orig + 15); +// CHECK: template <typename T> T foo(T a) { +// CHECK: #pragma omp declare reduction (fun : T : omp_out += omp_in) initializer(omp_priv = omp_orig + 15); // CHECK: { -// CHECK: #pragma omp declare reduction (fun : int : omp_out += omp_in) initializer(omp_priv = omp_orig + 15); +// CHECK: #pragma omp declare reduction (fun : T : omp_out += omp_in) initializer(omp_priv = omp_orig + 15); // CHECK: } // CHECK: return a; // CHECK: } -// CHECK: template <typename T> T foo(T a) { -// CHECK: #pragma omp declare reduction (fun : T : omp_out += omp_in) initializer(omp_priv = omp_orig + 15); +// CHECK: template<> int foo<int>(int a) { +// CHECK: #pragma omp declare reduction (fun : int : omp_out += omp_in) initializer(omp_priv = omp_orig + 15); // CHECK: { -// CHECK: #pragma omp declare reduction (fun : T : omp_out += omp_in) initializer(omp_priv = omp_orig + 15); +// CHECK: #pragma omp declare reduction (fun : int : omp_out += omp_in) initializer(omp_priv = omp_orig + 15); // CHECK: } // CHECK: return a; // CHECK: } Index: cfe/trunk/test/OpenMP/taskloop_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/taskloop_ast_print.cpp +++ cfe/trunk/test/OpenMP/taskloop_ast_print.cpp @@ -48,6 +48,7 @@ return T(); } +// CHECK-LABEL: int main(int argc, char **argv) { int main(int argc, char **argv) { int b = argc, c, d, e, f, g; static int a; Index: cfe/trunk/test/OpenMP/simd_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/simd_ast_print.cpp +++ cfe/trunk/test/OpenMP/simd_ast_print.cpp @@ -35,8 +35,8 @@ }; // CHECK: #pragma omp simd aligned(this->a) -// CHECK: #pragma omp simd aligned(this->a) // CHECK: #pragma omp simd aligned(this->b: 8) +// CHECK: #pragma omp simd aligned(this->a) class S8 : public S7<SS> { S8() {} @@ -129,7 +129,7 @@ }; // S2<4>::func is called below in main. -// CHECK: template <int LEN = 4> struct S2 { +// CHECK: template<> struct S2<4> { // CHECK-NEXT: static void func(int n, float *a, float *b, float *c) { // CHECK-NEXT: int k1 = 0, k2 = 0; // CHECK-NEXT: #pragma omp simd safelen(4) linear(k1,k2: 4) aligned(a: 4) simdlen(4) Index: cfe/trunk/test/OpenMP/distribute_simd_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/distribute_simd_ast_print.cpp +++ cfe/trunk/test/OpenMP/distribute_simd_ast_print.cpp @@ -37,9 +37,9 @@ } }; -// CHECK: #pragma omp distribute simd private(this->a) private(this->a) private(this->S::a) // CHECK: #pragma omp distribute simd private(this->a) private(this->a) private(T::a) // CHECK: #pragma omp distribute simd private(this->a) private(this->a) +// CHECK: #pragma omp distribute simd private(this->a) private(this->a) private(this->S::a) class S8 : public S7<S> { S8() {} Index: cfe/trunk/test/OpenMP/parallel_for_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/parallel_for_ast_print.cpp +++ cfe/trunk/test/OpenMP/parallel_for_ast_print.cpp @@ -35,9 +35,9 @@ } }; -// CHECK: #pragma omp parallel for private(this->a) private(this->a) private(this->S::a) // CHECK: #pragma omp parallel for private(this->a) private(this->a) private(T::a) // CHECK: #pragma omp parallel for private(this->a) private(this->a) +// CHECK: #pragma omp parallel for private(this->a) private(this->a) private(this->S::a) class S8 : public S7<S> { S8() {} Index: cfe/trunk/test/OpenMP/distribute_parallel_for_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/distribute_parallel_for_ast_print.cpp +++ cfe/trunk/test/OpenMP/distribute_parallel_for_ast_print.cpp @@ -37,9 +37,9 @@ } }; -// CHECK: #pragma omp distribute parallel for private(this->a) private(this->a) private(this->S::a) // CHECK: #pragma omp distribute parallel for private(this->a) private(this->a) private(T::a) // CHECK: #pragma omp distribute parallel for private(this->a) private(this->a) +// CHECK: #pragma omp distribute parallel for private(this->a) private(this->a) private(this->S::a) class S8 : public S7<S> { S8() {} Index: cfe/trunk/test/OpenMP/taskyield_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/taskyield_ast_print.cpp +++ cfe/trunk/test/OpenMP/taskyield_ast_print.cpp @@ -14,12 +14,12 @@ #pragma omp taskyield return a + argc; } +// CHECK: static T a; +// CHECK-NEXT: #pragma omp taskyield // CHECK: static int a; // CHECK-NEXT: #pragma omp taskyield // CHECK: static char a; // CHECK-NEXT: #pragma omp taskyield -// CHECK: static T a; -// CHECK-NEXT: #pragma omp taskyield int main(int argc, char **argv) { static int a; Index: cfe/trunk/test/OpenMP/teams_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/teams_ast_print.cpp +++ cfe/trunk/test/OpenMP/teams_ast_print.cpp @@ -15,18 +15,18 @@ #pragma omp threadprivate(TS) }; -// CHECK: template <class T = int> struct S { +// CHECK: template <class T> struct S { +// CHECK: static T TS; +// CHECK-NEXT: #pragma omp threadprivate(S::TS) +// CHECK: }; +// CHECK: template<> struct S<int> { // CHECK: static int TS; // CHECK-NEXT: #pragma omp threadprivate(S<int>::TS) // CHECK-NEXT: } -// CHECK: template <class T = long> struct S { +// CHECK: template<> struct S<long> { // CHECK: static long TS; // CHECK-NEXT: #pragma omp threadprivate(S<long>::TS) // CHECK-NEXT: } -// CHECK: template <class T> struct S { -// CHECK: static T TS; -// CHECK-NEXT: #pragma omp threadprivate(S::TS) -// CHECK: }; template <typename T, int C> T tmain(T argc, T *argv) { @@ -45,41 +45,41 @@ return 0; } -// CHECK: template <typename T = int, int C = 5> int tmain(int argc, int *argv) { -// CHECK-NEXT: int b = argc, c, d, e, f, g; -// CHECK-NEXT: static int a; -// CHECK-NEXT: S<int> s; +// CHECK: template <typename T, int C> T tmain(T argc, T *argv) { +// CHECK-NEXT: T b = argc, c, d, e, f, g; +// CHECK-NEXT: static T a; +// CHECK-NEXT: S<T> s; // CHECK-NEXT: #pragma omp target // CHECK-NEXT: #pragma omp teams // CHECK-NEXT: a = 2; // CHECK-NEXT: #pragma omp target -// CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(5) thread_limit(d * 5) +// CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(C) thread_limit(d * C) // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp target // CHECK-NEXT: #pragma omp teams reduction(^: e,f) reduction(&&: g) // CHECK-NEXT: foo() -// CHECK: template <typename T = long, int C = 1> long tmain(long argc, long *argv) { -// CHECK-NEXT: long b = argc, c, d, e, f, g; -// CHECK-NEXT: static long a; -// CHECK-NEXT: S<long> s; +// CHECK: template<> int tmain<int, 5>(int argc, int *argv) { +// CHECK-NEXT: int b = argc, c, d, e, f, g; +// CHECK-NEXT: static int a; +// CHECK-NEXT: S<int> s; // CHECK-NEXT: #pragma omp target // CHECK-NEXT: #pragma omp teams // CHECK-NEXT: a = 2; // CHECK-NEXT: #pragma omp target -// CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(1) thread_limit(d * 1) +// CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(5) thread_limit(d * 5) // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp target // CHECK-NEXT: #pragma omp teams reduction(^: e,f) reduction(&&: g) // CHECK-NEXT: foo() -// CHECK: template <typename T, int C> T tmain(T argc, T *argv) { -// CHECK-NEXT: T b = argc, c, d, e, f, g; -// CHECK-NEXT: static T a; -// CHECK-NEXT: S<T> s; +// CHECK: template<> long tmain<long, 1>(long argc, long *argv) { +// CHECK-NEXT: long b = argc, c, d, e, f, g; +// CHECK-NEXT: static long a; +// CHECK-NEXT: S<long> s; // CHECK-NEXT: #pragma omp target // CHECK-NEXT: #pragma omp teams // CHECK-NEXT: a = 2; // CHECK-NEXT: #pragma omp target -// CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(C) thread_limit(d * C) +// CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(1) thread_limit(d * 1) // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp target // CHECK-NEXT: #pragma omp teams reduction(^: e,f) reduction(&&: g) Index: cfe/trunk/test/OpenMP/distribute_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/distribute_ast_print.cpp +++ cfe/trunk/test/OpenMP/distribute_ast_print.cpp @@ -41,13 +41,13 @@ // CHECK: #pragma omp target // CHECK-NEXT: #pragma omp teams -// CHECK-NEXT: #pragma omp distribute private(this->a) private(this->a) private(this->S::a) -// CHECK: #pragma omp target -// CHECK-NEXT: #pragma omp teams // CHECK-NEXT: #pragma omp distribute private(this->a) private(this->a) private(T::a) // CHECK: #pragma omp target // CHECK-NEXT: #pragma omp teams // CHECK-NEXT: #pragma omp distribute private(this->a) private(this->a) +// CHECK: #pragma omp target +// CHECK-NEXT: #pragma omp teams +// CHECK-NEXT: #pragma omp distribute private(this->a) private(this->a) private(this->S::a) class S8 : public S7<S> { S8() {} Index: cfe/trunk/test/OpenMP/task_ast_print.cpp =================================================================== --- cfe/trunk/test/OpenMP/task_ast_print.cpp +++ cfe/trunk/test/OpenMP/task_ast_print.cpp @@ -35,9 +35,9 @@ } }; -// CHECK: #pragma omp task private(this->a) private(this->a) private(this->S1::a) // CHECK: #pragma omp task private(this->a) private(this->a) private(T::a) // CHECK: #pragma omp task private(this->a) private(this->a) +// CHECK: #pragma omp task private(this->a) private(this->a) private(this->S1::a) class S8 : public S7<S1> { S8() {} @@ -66,18 +66,18 @@ #pragma omp threadprivate(TS) }; -// CHECK: template <class T = int> struct S { +// CHECK: template <class T> struct S { +// CHECK: static T TS; +// CHECK-NEXT: #pragma omp threadprivate(S::TS) +// CHECK: }; +// CHECK: template<> struct S<int> { // CHECK: static int TS; // CHECK-NEXT: #pragma omp threadprivate(S<int>::TS) // CHECK-NEXT: } -// CHECK: template <class T = long> struct S { +// CHECK: template<> struct S<long> { // CHECK: static long TS; // CHECK-NEXT: #pragma omp threadprivate(S<long>::TS) // CHECK-NEXT: } -// CHECK: template <class T> struct S { -// CHECK: static T TS; -// CHECK-NEXT: #pragma omp threadprivate(S::TS) -// CHECK: }; template <typename T, int C> T tmain(T argc, T *argv) { @@ -94,7 +94,18 @@ return 0; } -// CHECK: template <typename T = int, int C = 5> int tmain(int argc, int *argv) { +// CHECK: template <typename T, int C> T tmain(T argc, T *argv) { +// CHECK-NEXT: T b = argc, c, d, e, f, g; +// CHECK-NEXT: static T a; +// CHECK-NEXT: S<T> s; +// CHECK-NEXT: T arr[argc]; +// CHECK-NEXT: #pragma omp task untied depend(in : argc,argv[b:argc],arr[:]) if(task: argc > 0) +// CHECK-NEXT: a = 2; +// CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) final(S<T>::TS > 0) priority(argc) +// CHECK-NEXT: foo() +// CHECK-NEXT: #pragma omp task if(C) mergeable priority(C) +// CHECK-NEXT: foo() +// CHECK: template<> int tmain<int, 5>(int argc, int *argv) { // CHECK-NEXT: int b = argc, c, d, e, f, g; // CHECK-NEXT: static int a; // CHECK-NEXT: S<int> s; @@ -105,7 +116,7 @@ // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp task if(5) mergeable priority(5) // CHECK-NEXT: foo() -// CHECK: template <typename T = long, int C = 1> long tmain(long argc, long *argv) { +// CHECK: template<> long tmain<long, 1>(long argc, long *argv) { // CHECK-NEXT: long b = argc, c, d, e, f, g; // CHECK-NEXT: static long a; // CHECK-NEXT: S<long> s; @@ -116,17 +127,6 @@ // CHECK-NEXT: foo() // CHECK-NEXT: #pragma omp task if(1) mergeable priority(1) // CHECK-NEXT: foo() -// CHECK: template <typename T, int C> T tmain(T argc, T *argv) { -// CHECK-NEXT: T b = argc, c, d, e, f, g; -// CHECK-NEXT: static T a; -// CHECK-NEXT: S<T> s; -// CHECK-NEXT: T arr[argc]; -// CHECK-NEXT: #pragma omp task untied depend(in : argc,argv[b:argc],arr[:]) if(task: argc > 0) -// CHECK-NEXT: a = 2; -// CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) final(S<T>::TS > 0) priority(argc) -// CHECK-NEXT: foo() -// CHECK-NEXT: #pragma omp task if(C) mergeable priority(C) -// CHECK-NEXT: foo() enum Enum {}; Index: cfe/trunk/test/Misc/ast-dump-templates.cpp =================================================================== --- cfe/trunk/test/Misc/ast-dump-templates.cpp +++ cfe/trunk/test/Misc/ast-dump-templates.cpp @@ -21,24 +21,24 @@ double z = foo<2, double, 3>().getSum(); } -// Template instantiation - foo -// Since the order of instantiation may vary during runs, run FileCheck twice -// to make sure each instantiation is in the correct spot. -// CHECK1: template <int X = 5, typename Y = int, int Z = 5> struct foo { -// CHECK2: template <int X = 2, typename Y = double, int Z = 3> struct foo { - // Template definition - foo // CHECK1: template <int X, typename Y, int Z = 5> struct foo { // CHECK2: template <int X, typename Y, int Z = 5> struct foo { -// Template instantiation - bar -// CHECK1: template <int A = 5, typename B = int> int bar() -// CHECK2: template <int A = 5, typename B = int> int bar() +// Template instantiation - foo +// Since the order of instantiation may vary during runs, run FileCheck twice +// to make sure each instantiation is in the correct spot. +// CHECK1: template<> struct foo<5, int, 5> { +// CHECK2: template<> struct foo<2, double, 3> { // Template definition - bar // CHECK1: template <int A, typename B> B bar() // CHECK2: template <int A, typename B> B bar() +// Template instantiation - bar +// CHECK1: template<> int bar<5, int>() +// CHECK2: template<> int bar<5, int>() + // CHECK1-LABEL: template <typename ...T> struct A { // CHECK1-NEXT: template <T ...x[3]> struct B { template <typename ...T> struct A { Index: cfe/trunk/test/Analysis/cfg.cpp =================================================================== --- cfe/trunk/test/Analysis/cfg.cpp +++ cfe/trunk/test/Analysis/cfg.cpp @@ -432,7 +432,7 @@ } -// CHECK-LABEL: int *PR18472() +// CHECK-LABEL: template<> int *PR18472<int>() // CHECK: [B2 (ENTRY)] // CHECK-NEXT: Succs (1): B1 // CHECK: [B1] Index: cfe/trunk/test/Coverage/ast-print-func.cpp =================================================================== --- cfe/trunk/test/Coverage/ast-print-func.cpp +++ cfe/trunk/test/Coverage/ast-print-func.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -ast-print -std=c++14 %s -o %t.1.cpp +// RUN: %clang_cc1 -ast-print -std=c++14 %t.1.cpp -o %t.2.cpp +// RUN: diff %t.1.cpp %t.2.cpp + +auto func_01(int, char) -> double; + +auto func_02(int x) -> int { return 2 + x; } + +void func_03() { + extern void g(), h(); + return; +} Index: cfe/trunk/test/Coverage/ast-print-temp-class.cpp =================================================================== --- cfe/trunk/test/Coverage/ast-print-temp-class.cpp +++ cfe/trunk/test/Coverage/ast-print-temp-class.cpp @@ -0,0 +1,64 @@ +// RUN: %clang_cc1 -ast-print -std=c++14 %s -v -o %t.1.cpp +// RUN: %clang_cc1 -ast-print -std=c++14 %t.1.cpp -o %t.2.cpp +// RUN: diff %t.1.cpp %t.2.cpp + +// Specializations + +template<typename T> class C0 {}; +template<> class C0<long> {}; +template<> class C0<long*> {}; +C0<int> c0; + +template<int N> class C1 {}; +template<> class C1<11> {}; +C1<2> c1a; +C1<4> c1b; + +template<typename T> class C2a {}; +template<typename T> class C2b {}; +template<template<typename T> class TC> class C2 {}; +template<> class C2<C2a> {}; +C2<C2b> c2; + + +// Default arguments + +template<typename T = int> class C10 {}; +template<int N = 10> class C11 {}; +template<typename T, int N = 22> class C12a {}; +//FIXME: template<template<typename T, int N> class TC = C12a> class C12 {}; +//FIXME: template<template<typename T> class TC = C12a> class C13 {}; + + +// Partial specializations + +template<typename T, typename U> struct C20 { + T a; + U b; +}; +template<typename T> struct C20<T, int> { + T a; +}; + +template<int N, typename U> struct C21 { + U a; + U b[N]; +}; +template<int N> struct C21<N, int> { + int a[N]; +}; + +template<template<typename T2> class TC, typename U> struct C22 { + TC<U> a; + U b; +}; +template<template<typename T2> class TC> struct C22<TC, int> { + TC<int> a; +}; + + +// Declaration only +template<typename T> class C30; +template<> class C30<long>; +template<> class C30<long*>; +extern C30<int> c30; Index: cfe/trunk/test/Coverage/ast-printing.cpp =================================================================== --- cfe/trunk/test/Coverage/ast-printing.cpp +++ cfe/trunk/test/Coverage/ast-printing.cpp @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only %s -// RUN: %clang_cc1 -ast-print %s +// RUN: %clang_cc1 -ast-print %s -o %t.1.cpp +// RUN: %clang_cc1 -ast-print %t.1.cpp -o %t.2.cpp +// RUN: diff %t.1.cpp %t.2.cpp // RUN: %clang_cc1 -ast-dump %s // RUN: %clang_cc1 -print-decl-contexts %s // RUN: %clang_cc1 -fdump-record-layouts %s Index: cfe/trunk/test/Coverage/ast-print-temp-func.cpp =================================================================== --- cfe/trunk/test/Coverage/ast-print-temp-func.cpp +++ cfe/trunk/test/Coverage/ast-print-temp-func.cpp @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -ast-print -std=c++14 %s -o %t.1.cpp +// RUN: %clang_cc1 -ast-print -std=c++14 %t.1.cpp -o %t.2.cpp +// RUN: diff %t.1.cpp %t.2.cpp + +template<typename T> void func_01(); +template<typename T> void func_01() {} +template<> void func_01<int>() {} +template<> void func_01<long>() {} +template<typename T> void func_01(); + +void main_01() { + func_01<int*>(); + func_01<char>(); +} + +template<typename T> void func_02(); +template<typename T> void func_02(); +template<> void func_02<int>(); +template<> void func_02<long>(); +template<typename T> void func_02(); + +void main_02() { + func_02<int*>(); + func_02<char>(); +}
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits