623 lines · cpp
1// RUN: %clang_cc1 %s -fopenacc -verify2 3// expected-error@+1{{use of undeclared identifier 'UnnamedYet'}}4#pragma acc routine(UnnamedYet) seq5void UnnamedYet();6// expected-error@+1{{use of undeclared identifier 'Invalid'}}7#pragma acc routine(Invalid) seq8 9// Fine, since these are the same function.10void SameFunc();11#pragma acc routine(SameFunc) seq12void SameFunc();13 14namespace NS {15void DifferentFunc();16};17// expected-warning@+2{{OpenACC 'routine' directive with a name refers to a function with the same name as the function on the following line; this may be unintended}}18// expected-note@-3{{'DifferentFunc' declared here}}19#pragma acc routine(NS::DifferentFunc) seq20void DifferentFunc();21 22void NoMagicStatic() {23 static int F = 1;24}25// expected-error@-2{{function static variables are not permitted in functions to which an OpenACC 'routine' directive applies}}26// expected-note@+1{{'routine' construct is here}}27#pragma acc routine(NoMagicStatic) seq28 29void NoMagicStatic2();30// expected-error@+4{{function static variables are not permitted in functions to which an OpenACC 'routine' directive applies}}31// expected-note@+1{{'routine' construct is here}}32#pragma acc routine(NoMagicStatic2) seq33void NoMagicStatic2() {34 static int F = 1;35}36 37#pragma acc routine seq38void NoMagicStatic3() {39 // expected-error@+2{{function static variables are not permitted in functions to which an OpenACC 'routine' directive applies}}40 // expected-note@-3{{'routine' construct is here}}41 static int F = 1;42}43 44#pragma acc routine seq45void NoMagicStatic4();46void NoMagicStatic4() {47 // expected-error@+2{{function static variables are not permitted in functions to which an OpenACC 'routine' directive applies}}48 // expected-note@-4{{'routine' construct is here}}49 static int F = 1;50}51 52void HasMagicStaticLambda() {53 auto MSLambda = []() {54 static int I = 5;55 };56// expected-error@-2{{function static variables are not permitted in functions to which an OpenACC 'routine' directive applies}}57// expected-note@+1{{'routine' construct is here}}58#pragma acc routine (MSLambda) seq59 60// expected-error@+4{{function static variables are not permitted in functions to which an OpenACC 'routine' directive applies}}61// expected-note@+1{{'routine' construct is here}}62#pragma acc routine seq63 auto MSLambda2 = []() {64 static int I = 5;65 };66 67// Properly handle error recovery.68// expected-error@+1{{expected function or lambda declaration for 'routine' construct}}69#pragma acc routine seq70 auto MSLambda2 = [](auto) {71 // expected-error@-1{{redefinition of 'MSLambda2'}}72 // expected-note@-9{{previous definition is here}}73 static int I = 5;74 };75// expected-error@+4{{function static variables are not permitted in functions to which an OpenACC 'routine' directive applies}}76// expected-note@+1{{'routine' construct is here}}77#pragma acc routine seq78 auto MSLambda3 = [](auto) {79 static int I = 5;80 };81}82 83auto Lambda = [](){};84#pragma acc routine(Lambda) seq85 86#pragma acc routine seq87auto Lambda2 = [](){};88auto GenLambda = [](auto){};89// expected-error@+1{{OpenACC routine name 'GenLambda' names a set of overloads}}90#pragma acc routine(GenLambda) seq91 92#pragma acc routine seq93auto GenLambda2 = [](auto){};94 95// Variable?96// expected-error@+1{{expected function or lambda declaration for 'routine' construct}}97#pragma acc routine seq98int Variable;99// Plain function100#pragma acc routine seq101int function();102 103#pragma acc routine (function) seq104// expected-error@+1{{OpenACC routine name 'Variable' does not name a function}}105#pragma acc routine (Variable) seq106 107// Var template?108// expected-error@+1{{expected function or lambda declaration for 'routine' construct}}109#pragma acc routine seq110template<typename T>111T VarTempl = 0;112// expected-error@+2{{use of variable template 'VarTempl' requires template arguments}}113// expected-note@-2{{template is declared here}}114#pragma acc routine (VarTempl) seq115// expected-error@+1{{OpenACC routine name 'VarTempl<int>' does not name a function}}116#pragma acc routine (VarTempl<int>) seq117 118// Function in NS119namespace NS {120 int NSFunc();121auto Lambda = [](){};122}123#pragma acc routine(NS::NSFunc) seq124#pragma acc routine(NS::Lambda) seq125 126// Ambiguous Function127int ambig_func();128int ambig_func(int);129// expected-error@+1{{OpenACC routine name 'ambig_func' names a set of overloads}}130#pragma acc routine (ambig_func) seq131 132#pragma acc routine seq133int ambig_func2();134#pragma acc routine seq135int ambig_func2(int);136 137// Ambiguous in NS138namespace NS {139int ambig_func();140int ambig_func(int);141}142// expected-error@+1{{OpenACC routine name 'NS::ambig_func' names a set of overloads}}143#pragma acc routine (NS::ambig_func) seq144 145// function template146template<typename T, typename U>147void templ_func();148#pragma acc routine seq149template<typename T, typename U>150void templ_func2();151 152// expected-error@+1{{OpenACC routine name 'templ_func' names a set of overloads}}153#pragma acc routine(templ_func) seq154// expected-error@+1{{OpenACC routine name 'templ_func<int>' names a set of overloads}}155#pragma acc routine(templ_func<int>) seq156// expected-error@+1{{OpenACC routine name 'templ_func<int, float>' names a set of overloads}}157#pragma acc routine(templ_func<int, float>) seq158 159struct S {160 void MemFunc();161#pragma acc routine seq162 void MemFunc2();163 static void StaticMemFunc();164#pragma acc routine seq165 static void StaticMemFunc2();166 template<typename U>167 void TemplMemFunc();168#pragma acc routine seq169 template<typename U>170 void TemplMemFunc2();171 template<typename U>172 static void TemplStaticMemFunc();173#pragma acc routine seq174 template<typename U>175 static void TemplStaticMemFunc2();176 177 void MemFuncAmbig();178 void MemFuncAmbig(int);179 template<typename T>180 void TemplMemFuncAmbig();181 template<typename T>182 void TemplMemFuncAmbig(int);183 184 int Field;185 186 constexpr static auto Lambda = [](){};187#pragma acc routine seq188 constexpr static auto Lambda2 = [](){};189#pragma acc routine seq190 constexpr static auto Lambda3 = [](auto){};191 192#pragma acc routine(S::MemFunc) seq193#pragma acc routine(S::StaticMemFunc) seq194#pragma acc routine(S::Lambda) seq195// expected-error@+1{{OpenACC routine name 'S::TemplMemFunc' names a set of overloads}}196#pragma acc routine(S::TemplMemFunc) seq197// expected-error@+1{{OpenACC routine name 'S::TemplStaticMemFunc' names a set of overloads}}198#pragma acc routine(S::TemplStaticMemFunc) seq199// expected-error@+1{{OpenACC routine name 'S::template TemplMemFunc<int>' names a set of overloads}}200#pragma acc routine(S::template TemplMemFunc<int>) seq201// expected-error@+1{{OpenACC routine name 'S::template TemplStaticMemFunc<int>' names a set of overloads}}202#pragma acc routine(S::template TemplStaticMemFunc<int>) seq203// expected-error@+1{{OpenACC routine name 'S::MemFuncAmbig' names a set of overloads}}204#pragma acc routine(S::MemFuncAmbig) seq205// expected-error@+1{{OpenACC routine name 'S::TemplMemFuncAmbig' names a set of overloads}}206#pragma acc routine(S::TemplMemFuncAmbig) seq207// expected-error@+1{{OpenACC routine name 'S::template TemplMemFuncAmbig<int>' names a set of overloads}}208#pragma acc routine(S::template TemplMemFuncAmbig<int>) seq209// expected-error@+1{{OpenACC routine name 'S::Field' does not name a function}}210#pragma acc routine(S::Field) seq211};212 213#pragma acc routine(S::MemFunc) seq214#pragma acc routine(S::StaticMemFunc) seq215#pragma acc routine(S::Lambda) seq216// expected-error@+1{{OpenACC routine name 'S::TemplMemFunc' names a set of overloads}}217#pragma acc routine(S::TemplMemFunc) seq218// expected-error@+1{{OpenACC routine name 'S::TemplStaticMemFunc' names a set of overloads}}219#pragma acc routine(S::TemplStaticMemFunc) seq220// expected-error@+1{{OpenACC routine name 'S::template TemplMemFunc<int>' names a set of overloads}}221#pragma acc routine(S::template TemplMemFunc<int>) seq222// expected-error@+1{{OpenACC routine name 'S::template TemplStaticMemFunc<int>' names a set of overloads}}223#pragma acc routine(S::template TemplStaticMemFunc<int>) seq224// expected-error@+1{{OpenACC routine name 'S::MemFuncAmbig' names a set of overloads}}225#pragma acc routine(S::MemFuncAmbig) seq226// expected-error@+1{{OpenACC routine name 'S::TemplMemFuncAmbig' names a set of overloads}}227#pragma acc routine(S::TemplMemFuncAmbig) seq228// expected-error@+1{{OpenACC routine name 'S::template TemplMemFuncAmbig<int>' names a set of overloads}}229#pragma acc routine(S::template TemplMemFuncAmbig<int>) seq230// expected-error@+1{{OpenACC routine name 'S::Field' does not name a function}}231#pragma acc routine(S::Field) seq232 233constexpr auto getLambda() {234 return [](){};235}236template<typename T>237constexpr auto getTemplLambda() {238 return [](T){};239}240constexpr auto getDepLambda() {241 return [](auto){};242}243template<typename T>244constexpr auto getTemplDepLambda() {245 return [](auto){};246}247 248template<typename T>249struct DepS { // #DEPS250 void MemFunc();251 static void StaticMemFunc();252 253 template<typename U>254 void TemplMemFunc();255 template<typename U>256 static void TemplStaticMemFunc();257 258 void MemFuncAmbig();259 void MemFuncAmbig(int);260 template<typename U>261 void TemplMemFuncAmbig();262 template<typename U>263 void TemplMemFuncAmbig(int);264 265 int Field;266 constexpr static auto Lambda = [](){};267 // expected-error@+2{{non-const static data member must be initialized out of line}}268 // expected-note@#DEPSInst{{in instantiation of template class}}269 static auto LambdaBroken = [](){};270 271#pragma acc routine seq272 constexpr static auto LambdaKinda = getLambda();273 // FIXME: We can't really handle this/things like this, see comment in274 // SemaOpenACC.cpp's LegalizeNextParsedDecl.275 // expected-error@+1{{expected function or lambda declaration for 'routine' construct}}276#pragma acc routine seq277 constexpr static auto LambdaKinda2 = getTemplLambda<T>();278#pragma acc routine seq279 constexpr static auto DepLambdaKinda = getDepLambda();280 // expected-error@+1{{expected function or lambda declaration for 'routine' construct}}281#pragma acc routine seq282 constexpr static auto DepLambdaKinda2 = getTemplDepLambda<T>();283 284// expected-error@+1{{expected function or lambda declaration for 'routine' construct}}285#pragma acc routine seq286 constexpr static auto Bad = T{};287 288#pragma acc routine seq289 constexpr static auto LambdaHasMagicStatic = []() {290 // expected-error@+2{{function static variables are not permitted in functions to which an OpenACC 'routine' directive applies}}291 // expected-note@-3{{'routine' construct is here}}292 static int F = 1;293 };294 295 void HasMagicStatic() {296 static int F = 1; // #HasMagicStaticFunc297 }298 void HasMagicStatic2() {299 static int F = 1; // #HasMagicStaticFunc2300 }301 302#pragma acc routine(DepS::MemFunc) seq303#pragma acc routine(DepS::StaticMemFunc) seq304#pragma acc routine(DepS::Lambda) seq305#pragma acc routine(DepS::LambdaBroken) seq306// expected-error@+1{{OpenACC routine name 'DepS<T>::TemplMemFunc' names a set of overloads}}307#pragma acc routine(DepS::TemplMemFunc) seq308// expected-error@+1{{OpenACC routine name 'DepS<T>::TemplStaticMemFunc' names a set of overloads}}309#pragma acc routine(DepS::TemplStaticMemFunc) seq310// expected-error@+1{{OpenACC routine name 'DepS<T>::template TemplMemFunc<int>' names a set of overloads}}311#pragma acc routine(DepS::template TemplMemFunc<int>) seq312// expected-error@+1{{OpenACC routine name 'DepS<T>::template TemplStaticMemFunc<int>' names a set of overloads}}313#pragma acc routine(DepS::template TemplStaticMemFunc<int>) seq314// expected-error@+1{{OpenACC routine name 'DepS<T>::MemFuncAmbig' names a set of overloads}}315#pragma acc routine(DepS::MemFuncAmbig) seq316// expected-error@+1{{OpenACC routine name 'DepS<T>::TemplMemFuncAmbig' names a set of overloads}}317#pragma acc routine(DepS::TemplMemFuncAmbig) seq318// expected-error@+1{{OpenACC routine name 'DepS<T>::template TemplMemFuncAmbig<int>' names a set of overloads}}319#pragma acc routine(DepS::template TemplMemFuncAmbig<int>) seq320// expected-error@+1{{OpenACC routine name 'DepS<T>::Field' does not name a function}}321#pragma acc routine(DepS::Field) seq322 323#pragma acc routine(DepS<T>::MemFunc) seq324#pragma acc routine(DepS<T>::StaticMemFunc) seq325#pragma acc routine(DepS<T>::Lambda) seq326#pragma acc routine(DepS<T>::LambdaBroken) seq327// expected-error@+1{{OpenACC routine name 'DepS<T>::TemplMemFunc' names a set of overloads}}328#pragma acc routine(DepS<T>::TemplMemFunc) seq329// expected-error@+1{{OpenACC routine name 'DepS<T>::TemplStaticMemFunc' names a set of overloads}}330#pragma acc routine(DepS<T>::TemplStaticMemFunc) seq331// expected-error@+1{{OpenACC routine name 'DepS<T>::template TemplMemFunc<int>' names a set of overloads}}332#pragma acc routine(DepS<T>::template TemplMemFunc<int>) seq333// expected-error@+1{{OpenACC routine name 'DepS<T>::template TemplStaticMemFunc<int>' names a set of overloads}}334#pragma acc routine(DepS<T>::template TemplStaticMemFunc<int>) seq335// expected-error@+1{{OpenACC routine name 'DepS<T>::MemFuncAmbig' names a set of overloads}}336#pragma acc routine(DepS<T>::MemFuncAmbig) seq337// expected-error@+1{{OpenACC routine name 'DepS<T>::TemplMemFuncAmbig' names a set of overloads}}338#pragma acc routine(DepS<T>::TemplMemFuncAmbig) seq339// expected-error@+1{{OpenACC routine name 'DepS<T>::template TemplMemFuncAmbig<int>' names a set of overloads}}340#pragma acc routine(DepS<T>::template TemplMemFuncAmbig<int>) seq341// expected-error@+1{{OpenACC routine name 'DepS<T>::Field' does not name a function}}342#pragma acc routine(DepS<T>::Field) seq343 344// FIXME: We could do better about suppressing this double diagnostic, but we345// don't want to invalidate the vardecl for openacc, so we don't have a good346// way to do this in the AST.347// expected-error@#HasMagicStaticFunc 2{{function static variables are not permitted in functions to which an OpenACC 'routine' directive applies}}348// expected-note@+2 2{{'routine' construct is here}}349// expected-note@+1{{in instantiation of member function}}}350#pragma acc routine(DepS<T>::HasMagicStatic) seq351};352 353template<typename T>354void DepF() {355#pragma acc routine seq356 auto LambdaKinda = getLambda();357// expected-error@+1{{expected function or lambda declaration for 'routine' construct}}358#pragma acc routine seq359 auto LambdaKinda2 = getTemplLambda<T>();360#pragma acc routine seq361 auto DepLambdaKinda = getDepLambda();362// expected-error@+1{{expected function or lambda declaration for 'routine' construct}}363#pragma acc routine seq364 auto DepLambdaKinda2 = getTemplDepLambda<T>();365 366// expected-error@+1{{expected function or lambda declaration for 'routine' construct}}367#pragma acc routine seq368 constexpr static auto Bad = T{};369}370 371void Inst() {372 DepS<int> S; // #DEPSInst373 S.HasMagicStatic2();374 DepF<int>(); // #DEPFInst375}376 377 378//expected-error@+2{{use of class template 'DepS' requires template arguments}}379// expected-note@#DEPS{{template is declared here}}380#pragma acc routine(DepS::Lambda) seq381//expected-error@+2{{use of class template 'DepS' requires template arguments}}382// expected-note@#DEPS{{template is declared here}}383#pragma acc routine(DepS::MemFunc) seq384//expected-error@+2{{use of class template 'DepS' requires template arguments}}385// expected-note@#DEPS{{template is declared here}}386#pragma acc routine(DepS::StaticMemFunc) seq387//expected-error@+2{{use of class template 'DepS' requires template arguments}}388// expected-note@#DEPS{{template is declared here}}389#pragma acc routine(DepS::TemplMemFunc) seq390//expected-error@+2{{use of class template 'DepS' requires template arguments}}391// expected-note@#DEPS{{template is declared here}}392#pragma acc routine(DepS::TemplStaticMemFunc) seq393//expected-error@+2{{use of class template 'DepS' requires template arguments}}394// expected-note@#DEPS{{template is declared here}}395#pragma acc routine(DepS::TemplMemFunc<int>) seq396//expected-error@+2{{use of class template 'DepS' requires template arguments}}397// expected-note@#DEPS{{template is declared here}}398#pragma acc routine(DepS::TemplStaticMemFunc<int>) seq399//expected-error@+2{{use of class template 'DepS' requires template arguments}}400// expected-note@#DEPS{{template is declared here}}401#pragma acc routine(DepS::MemFuncAmbig) seq402//expected-error@+2{{use of class template 'DepS' requires template arguments}}403// expected-note@#DEPS{{template is declared here}}404#pragma acc routine(DepS::TemplMemFuncAmbig) seq405//expected-error@+2{{use of class template 'DepS' requires template arguments}}406// expected-note@#DEPS{{template is declared here}}407#pragma acc routine(DepS::TemplMemFuncAmbig<int>) seq408//expected-error@+2{{use of class template 'DepS' requires template arguments}}409// expected-note@#DEPS{{template is declared here}}410#pragma acc routine(DepS::Field) seq411 412//expected-error@+1{{use of undeclared identifier 'T'}}413#pragma acc routine(DepS<T>::Lambda) seq414//expected-error@+1{{use of undeclared identifier 'T'}}415#pragma acc routine(DepS<T>::MemFunc) seq416//expected-error@+1{{use of undeclared identifier 'T'}}417#pragma acc routine(DepS<T>::StaticMemFunc) seq418//expected-error@+1{{use of undeclared identifier 'T'}}419#pragma acc routine(DepS<T>::TemplMemFunc) seq420//expected-error@+1{{use of undeclared identifier 'T'}}421#pragma acc routine(DepS<T>::TemplStaticMemFunc) seq422//expected-error@+1{{use of undeclared identifier 'T'}}423#pragma acc routine(DepS<T>::TemplMemFunc<int>) seq424//expected-error@+1{{use of undeclared identifier 'T'}}425#pragma acc routine(DepS<T>::TemplStaticMemFunc<int>) seq426//expected-error@+1{{use of undeclared identifier 'T'}}427#pragma acc routine(DepS<T>::MemFuncAmbig) seq428//expected-error@+1{{use of undeclared identifier 'T'}}429#pragma acc routine(DepS<T>::TemplMemFuncAmbig) seq430//expected-error@+1{{use of undeclared identifier 'T'}}431#pragma acc routine(DepS<T>::TemplMemFuncAmbig<int>) seq432//expected-error@+1{{use of undeclared identifier 'T'}}433#pragma acc routine(DepS<T>::Field) seq434 435#pragma acc routine(DepS<int>::Lambda) seq436#pragma acc routine(DepS<int>::LambdaBroken) seq437#pragma acc routine(DepS<int>::MemFunc) seq438#pragma acc routine(DepS<int>::StaticMemFunc) seq439// expected-error@+1{{OpenACC routine name 'DepS<int>::TemplMemFunc' names a set of overloads}}440#pragma acc routine(DepS<int>::TemplMemFunc) seq441// expected-error@+1{{OpenACC routine name 'DepS<int>::TemplStaticMemFunc' names a set of overloads}}442#pragma acc routine(DepS<int>::TemplStaticMemFunc) seq443// expected-error@+1{{OpenACC routine name 'DepS<int>::TemplMemFunc<int>' names a set of overloads}}444#pragma acc routine(DepS<int>::TemplMemFunc<int>) seq445// expected-error@+1{{OpenACC routine name 'DepS<int>::TemplStaticMemFunc<int>' names a set of overloads}}446#pragma acc routine(DepS<int>::TemplStaticMemFunc<int>) seq447// expected-error@+1{{OpenACC routine name 'DepS<int>::MemFuncAmbig' names a set of overloads}}448#pragma acc routine(DepS<int>::MemFuncAmbig) seq449// expected-error@+1{{OpenACC routine name 'DepS<int>::TemplMemFuncAmbig' names a set of overloads}}450#pragma acc routine(DepS<int>::TemplMemFuncAmbig) seq451// expected-error@+1{{OpenACC routine name 'DepS<int>::TemplMemFuncAmbig<int>' names a set of overloads}}452#pragma acc routine(DepS<int>::TemplMemFuncAmbig<int>) seq453// expected-error@+1{{OpenACC routine name 'DepS<int>::Field' does not name a function}}454#pragma acc routine(DepS<int>::Field) seq455 456// expected-error@#HasMagicStaticFunc2{{function static variables are not permitted in functions to which an OpenACC 'routine' directive applies}}457// expected-note@+2{{'routine' construct is here}}458// expected-note@+1{{in instantiation of member function}}}459#pragma acc routine(DepS<int>::HasMagicStatic2) seq460 461template<typename T>462void TemplFunc() {463#pragma acc routine(T::MemFunc) seq464#pragma acc routine(T::StaticMemFunc) seq465#pragma acc routine(T::Lambda) seq466// expected-error@+1{{OpenACC routine name 'S::TemplMemFunc' names a set of overloads}}467#pragma acc routine(T::TemplMemFunc) seq468// expected-error@+1{{OpenACC routine name 'S::TemplStaticMemFunc' names a set of overloads}}469#pragma acc routine(T::TemplStaticMemFunc) seq470// expected-error@+1{{OpenACC routine name 'S::template TemplMemFunc<int>' names a set of overloads}}471#pragma acc routine(T::template TemplMemFunc<int>) seq472// expected-error@+1{{OpenACC routine name 'S::template TemplStaticMemFunc<int>' names a set of overloads}}473#pragma acc routine(T::template TemplStaticMemFunc<int>) seq474// expected-error@+1{{OpenACC routine name 'S::MemFuncAmbig' names a set of overloads}}475#pragma acc routine(T::MemFuncAmbig) seq476// expected-error@+1{{OpenACC routine name 'S::TemplMemFuncAmbig' names a set of overloads}}477#pragma acc routine(T::TemplMemFuncAmbig) seq478// expected-error@+1{{OpenACC routine name 'S::template TemplMemFuncAmbig<int>' names a set of overloads}}479#pragma acc routine(T::template TemplMemFuncAmbig<int>) seq480// expected-error@+1{{OpenACC routine name 'S::Field' does not name a function}}481#pragma acc routine(T::Field) seq482}483 484template <typename T>485struct DepRefersToT {486#pragma acc routine(T::MemFunc) seq487#pragma acc routine(T::StaticMemFunc) seq488#pragma acc routine(T::Lambda) seq489// expected-error@+1{{OpenACC routine name 'S::TemplMemFunc' names a set of overloads}}490#pragma acc routine(T::TemplMemFunc) seq491// expected-error@+1{{OpenACC routine name 'S::TemplStaticMemFunc' names a set of overloads}}492#pragma acc routine(T::TemplStaticMemFunc) seq493// expected-error@+1{{OpenACC routine name 'S::template TemplMemFunc<int>' names a set of overloads}}494#pragma acc routine(T::template TemplMemFunc<int>) seq495// expected-error@+1{{OpenACC routine name 'S::template TemplStaticMemFunc<int>' names a set of overloads}}496#pragma acc routine(T::template TemplStaticMemFunc<int>) seq497// expected-error@+1{{OpenACC routine name 'S::MemFuncAmbig' names a set of overloads}}498#pragma acc routine(T::MemFuncAmbig) seq499// expected-error@+1{{OpenACC routine name 'S::TemplMemFuncAmbig' names a set of overloads}}500#pragma acc routine(T::TemplMemFuncAmbig) seq501// expected-error@+1{{OpenACC routine name 'S::template TemplMemFuncAmbig<int>' names a set of overloads}}502#pragma acc routine(T::template TemplMemFuncAmbig<int>) seq503// expected-error@+1{{OpenACC routine name 'S::Field' does not name a function}}504#pragma acc routine(T::Field) seq505 506 void MemFunc() {507#pragma acc routine(T::MemFunc) seq508#pragma acc routine(T::StaticMemFunc) seq509#pragma acc routine(T::Lambda) seq510// expected-error@+1{{OpenACC routine name 'S::TemplMemFunc' names a set of overloads}}511#pragma acc routine(T::TemplMemFunc) seq512// expected-error@+1{{OpenACC routine name 'S::TemplStaticMemFunc' names a set of overloads}}513#pragma acc routine(T::TemplStaticMemFunc) seq514// expected-error@+1{{OpenACC routine name 'S::template TemplMemFunc<int>' names a set of overloads}}515#pragma acc routine(T::template TemplMemFunc<int>) seq516// expected-error@+1{{OpenACC routine name 'S::template TemplStaticMemFunc<int>' names a set of overloads}}517#pragma acc routine(T::template TemplStaticMemFunc<int>) seq518// expected-error@+1{{OpenACC routine name 'S::MemFuncAmbig' names a set of overloads}}519#pragma acc routine(T::MemFuncAmbig) seq520// expected-error@+1{{OpenACC routine name 'S::TemplMemFuncAmbig' names a set of overloads}}521#pragma acc routine(T::TemplMemFuncAmbig) seq522// expected-error@+1{{OpenACC routine name 'S::template TemplMemFuncAmbig<int>' names a set of overloads}}523#pragma acc routine(T::template TemplMemFuncAmbig<int>) seq524// expected-error@+1{{OpenACC routine name 'S::Field' does not name a function}}525#pragma acc routine(T::Field) seq526 }527 528 template<typename U>529 void TemplMemFunc() {530#pragma acc routine(T::MemFunc) seq531#pragma acc routine(T::StaticMemFunc) seq532#pragma acc routine(T::Lambda) seq533// expected-error@+1{{OpenACC routine name 'S::TemplMemFunc' names a set of overloads}}534#pragma acc routine(T::TemplMemFunc) seq535// expected-error@+1{{OpenACC routine name 'S::TemplStaticMemFunc' names a set of overloads}}536#pragma acc routine(T::TemplStaticMemFunc) seq537// expected-error@+1{{OpenACC routine name 'S::template TemplMemFunc<int>' names a set of overloads}}538#pragma acc routine(T::template TemplMemFunc<int>) seq539// expected-error@+1{{OpenACC routine name 'S::template TemplStaticMemFunc<int>' names a set of overloads}}540#pragma acc routine(T::template TemplStaticMemFunc<int>) seq541// expected-error@+1{{OpenACC routine name 'S::MemFuncAmbig' names a set of overloads}}542#pragma acc routine(T::MemFuncAmbig) seq543// expected-error@+1{{OpenACC routine name 'S::TemplMemFuncAmbig' names a set of overloads}}544#pragma acc routine(T::TemplMemFuncAmbig) seq545// expected-error@+1{{OpenACC routine name 'S::template TemplMemFuncAmbig<int>' names a set of overloads}}546#pragma acc routine(T::template TemplMemFuncAmbig<int>) seq547// expected-error@+1{{OpenACC routine name 'S::Field' does not name a function}}548#pragma acc routine(T::Field) seq549 550// expected-error@+1{{expected function or lambda declaration for 'routine' construct}}551#pragma acc routine seq552 auto L = getTemplLambda<U>();553// expected-error@+1{{expected function or lambda declaration for 'routine' construct}}554#pragma acc routine seq555 auto L2 = getTemplDepLambda<U>();556 }557 558};559 560void inst() {561 TemplFunc<S>(); // expected-note{{in instantiation of}}562 DepRefersToT<S> s; // expected-note{{in instantiation of}}563 s.MemFunc(); // expected-note{{in instantiation of}}564 s.TemplMemFunc<S>(); // expected-note{{in instantiation of}}565}566 567// A.3.4 tests:568 569void DiffFuncs(); // #GLOBALDIFFFUNCS570namespace NS {571// expected-warning@+2{{OpenACC 'routine' directive with a name refers to a function with the same name as the function on the following line; this may be unintended}}572// expected-note@#GLOBALDIFFFUNCS{{'DiffFuncs' declared here}}573#pragma acc routine(DiffFuncs) seq574void DiffFuncs();575}576 577void has_diff_func() {578// expected-warning@+2{{OpenACC 'routine' directive with a name refers to a function with the same name as the function on the following line; this may be unintended}}579// expected-note@#GLOBALDIFFFUNCS{{'DiffFuncs' declared here}}580#pragma acc routine(DiffFuncs) seq581auto DiffFuncs = [](){};582}583 584template<typename T>585void has_diff_func_templ() {586// expected-warning@+3{{OpenACC 'routine' directive with a name refers to a function with the same name as the function on the following line; this may be unintended}}587// expected-note@#GLOBALDIFFFUNCS{{'DiffFuncs' declared here}}588// expected-note@#HDFT_INST{{in instantiation of function template specialization}}589#pragma acc routine(DiffFuncs) seq590auto DiffFuncs = [](){};591}592 593void inst_diff() {594 has_diff_func_templ<int>();// #HDFT_INST595}596 597struct SDiff {598// expected-warning@+2{{OpenACC 'routine' directive with a name refers to a function with the same name as the function on the following line; this may be unintended}}599// expected-note@#GLOBALDIFFFUNCS{{'DiffFuncs' declared here}}600#pragma acc routine(DiffFuncs) seq601 void DiffFuncs();602};603template<typename T>604struct TemplSDiff {605// expected-warning@+2{{OpenACC 'routine' directive with a name refers to a function with the same name as the function on the following line; this may be unintended}}606// expected-note@#GLOBALDIFFFUNCS{{'DiffFuncs' declared here}}607#pragma acc routine(DiffFuncs) seq608 void DiffFuncs();609};610 611struct SOperator {612#pragma acc routine(DiffFuncs) seq613 bool operator==(const S&);614};615 616namespace NS2 {617 // Shouldn't diagnose.618#pragma acc routine(DiffFuncs) seq619#pragma acc routine seq620 void DiffFuncs();621};622 623