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);
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);
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
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) ||
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.
!D->isFunctionTemplateSpecialization())
prettyPrintPragmas(D);
+ if (D->isFunctionTemplateSpecialization())
+ Out << "template<> ";
+
CXXConstructorDecl *CDecl = dyn_cast<CXXConstructorDecl>(D);
CXXConversionDecl *ConversionDecl = dyn_cast<CXXConversionDecl>(D);
if (!Policy.SuppressSpecifiers) {
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)) {
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 << " {}";
+ }
}
}
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);
}
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()) {
// 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() << "}";
+ }
}
}
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 <";
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 ";
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)) {
}
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);
}
//----------------------------------------------------------------------------
}
-// CHECK-LABEL: int *PR18472()
+// CHECK-LABEL: template<> int *PR18472<int>()
// CHECK: [B2 (ENTRY)]
// CHECK-NEXT: Succs (1): B1
// CHECK: [B1]
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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;
--- /dev/null
+// 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>();
+}
// 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
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>
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>
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;
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 {
return T();
}
-// CHECK: int a = int();
+// CHECK: T a = T();
// CHECK-NEXT: #pragma omp atomic
// CHECK-NEXT: a++;
// CHECK-NEXT: #pragma omp atomic read
// 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
}
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
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;
++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;
}
// 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;
#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: }
}
// 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.
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
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: }
};
// 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);
#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;
// 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
// 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() {}
}
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;
}
};
-// 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() {}
}
};
-// 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() {}
}
};
-// 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() {}
#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)
}
};
-// 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() {}
}
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;
}
};
-// 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() {}
};
// 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)
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
// 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
// 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: }
}
};
-// 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 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() {}
#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) {
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;
// 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;
// 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 { };
}
};
-// 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() {}
}
};
-// 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() {}
};
// 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)
#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) {
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
}
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;
};
// 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() {}
};
// 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)
}
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);
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()
// 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()
// 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()
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)
// 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)
// 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)
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;
// 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;
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)
// 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)
// 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)
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)
// 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)
// 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)
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;
// 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;
#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) {
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()
// 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()
// 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()
}
};
-// 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() {}
}
};
-// 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() {}
}
};
-// 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() {}
#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)
}
};
-// 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() {}
#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) {
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;
// 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;
// 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 {};
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;
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;
#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;
#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;
#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) {
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)
}
};
// 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() {}
}
};
// 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-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() {}
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;
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>();
}
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()));
}
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) {
"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) {
"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) {
"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) {
"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) {
"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) {
"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) {
"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) {
"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) {
"void A();",
"A",
"void A()"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestFunctionDecl2) {
"void A() {}",
"A",
"void A()"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestFunctionDecl3) {
"void A() { Z(); }",
"A",
"void A()"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestFunctionDecl4) {
"extern void A();",
"A",
"extern void A()"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestFunctionDecl5) {
"static void A();",
"A",
"static void A()"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestFunctionDecl6) {
"inline void A();",
"A",
"inline void A()"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestFunctionDecl7) {
"constexpr int A(int a);",
"A",
"constexpr int A(int a)"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestFunctionDecl8) {
"void A(int a);",
"A",
"void A(int a)"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestFunctionDecl9) {
"void A(...);",
"A",
"void A(...)"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestFunctionDecl10) {
"void A(int a, ...);",
"A",
"void A(int a, ...)"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestFunctionDecl11) {
"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) {
"void A(int a, int b = 0);",
"A",
"void A(int a, int b = 0)"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestFunctionDecl13) {
"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) {
"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)"));
}
"};",
cxxConstructorDecl(ofClass(hasName("A"))).bind("id"),
"A<T...>(const A<T...> &a)"));
- // WRONG; Should be: "A(const A<T...> &a);"
}
TEST(DeclPrinter, TestCXXConstructorDecl11) {
" 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) {
"};",
cxxMethodDecl(ofClass(hasName("Z"))).bind("id"),
"void *operator new(std::size_t)"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestCXXMethodDecl_AllocationFunction2) {
"};",
cxxMethodDecl(ofClass(hasName("Z"))).bind("id"),
"void *operator new[](std::size_t)"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestCXXMethodDecl_AllocationFunction3) {
"};",
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) {
"};",
cxxMethodDecl(ofClass(hasName("Z"))).bind("id"),
"void operator delete(void *)"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestCXXMethodDecl_AllocationFunction5) {
"};",
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) {
Expected.append("void operator");
Expected.append(OperatorNames[i]);
Expected.append("(Z z)");
- // Should be: with semicolon
ASSERT_TRUE(PrintedDeclCXX98Matches(
Code,
Expected.append("void operator");
Expected.append(OperatorNames[i]);
Expected.append("()");
- // Should be: with semicolon
ASSERT_TRUE(PrintedDeclCXX98Matches(
Code,
"};",
"A",
"void A(int a)"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestCXXMethodDecl2) {
"};",
"A",
"virtual void A(int a)"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestCXXMethodDecl3) {
"};",
"ZZ::A",
"void A(int a)"));
- // Should be: with semicolon
// TODO: should we print "virtual"?
}
"};",
"A",
"inline void A(int a)"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestCXXMethodDecl5) {
"};",
"A",
"virtual void A(int a) = 0"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestCXXMethodDecl_CVQualifier1) {
"};",
"A",
"void A(int a) const"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestCXXMethodDecl_CVQualifier2) {
"};",
"A",
"void A(int a) volatile"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestCXXMethodDecl_CVQualifier3) {
"};",
"A",
"void A(int a) const volatile"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestCXXMethodDecl_RefQualifier1) {
"};",
"A",
"void A(int a) &"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestCXXMethodDecl_RefQualifier2) {
"};",
"A",
"void A(int a) &&"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestFunctionDecl_ExceptionSpecification1) {
"};",
"A",
"void A(int a) throw()"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestFunctionDecl_ExceptionSpecification2) {
"};",
"A",
"void A(int a) throw(int)"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestFunctionDecl_ExceptionSpecification3) {
"};",
"A",
"void A(int a) throw(ZZ, int)"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestFunctionDecl_ExceptionSpecification4) {
"};",
"A",
"void A(int a) noexcept"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestFunctionDecl_ExceptionSpecification5) {
"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) {
"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) {
"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) {
"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) {
"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) {
"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) {
"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) {
"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) {
"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) {
"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) {
"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) {
"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 *> { ... }"
}
"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) {
"void A(T &t);",
functionTemplateDecl(hasName("A")).bind("id"),
"template <typename T> void A(T &t)"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestFunctionTemplateDecl2) {
"void A(T &t) { }",
functionTemplateDecl(hasName("A")).bind("id"),
"template <typename T> void A(T &t)"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestFunctionTemplateDecl3) {
"void A(T... a);",
functionTemplateDecl(hasName("A")).bind("id"),
"template <typename ...T> void A(T ...a)"));
- // Should be: with semicolon.
}
TEST(DeclPrinter, TestFunctionTemplateDecl4) {
"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) {
"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) {
"};",
functionTemplateDecl(hasName("A")).bind("id"),
"template <typename U> void A(U t)"));
- // Should be: with semicolon
}
TEST(DeclPrinter, TestTemplateArgumentList1) {