Skip to content

Commit 52a5167

Browse files
committed
Sema: Forbid variadic templates in explicit DSAs
Fixes llvm#21
1 parent 578d7ad commit 52a5167

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

+2
Original file line numberDiff line numberDiff line change
@@ -9749,6 +9749,8 @@ def err_oss_typecheck_shaping_base_no_ptr_or_array: Error<
97499749
"shaping expression base is not a pointer or array">;
97509750
def err_oss_shape_incomplete_type : Error<
97519751
"shape of pointer to incomplete type %0">;
9752+
def err_oss_variadic_templates_not_clause_allowed : Error<
9753+
"variadic templates are not allowed in OmpSs-2 clauses">;
97529754
def warn_oss_section_is_char : Warning<"array section %select{lower bound|length}0 is of type 'char'">,
97539755
InGroup<CharSubscript>, DefaultIgnore;
97549756
} // end of OmpSs component.

clang/lib/Sema/SemaOmpSs.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
283283
}
284284

285285
public:
286+
286287
void VisitCXXThisExpr(CXXThisExpr *ThisE) {
287288
// Add DSA to 'this' if is the first time we see it
288289
if (!Stack->getThisExpr()) {
@@ -722,9 +723,12 @@ StmtResult Sema::ActOnOmpSsTaskDirective(ArrayRef<OSSClause *> Clauses,
722723
static std::pair<ValueDecl *, bool>
723724
getPrivateItem(Sema &S, Expr *&RefExpr, SourceLocation &ELoc,
724725
SourceRange &ERange) {
725-
if (RefExpr->isTypeDependent() || RefExpr->isValueDependent() ||
726-
RefExpr->containsUnexpandedParameterPack())
726+
if (RefExpr->containsUnexpandedParameterPack()) {
727+
S.Diag(RefExpr->getExprLoc(), diag::err_oss_variadic_templates_not_clause_allowed);
728+
return std::make_pair(nullptr, false);
729+
} else if (RefExpr->isTypeDependent() || RefExpr->isValueDependent()) {
727730
return std::make_pair(nullptr, true);
731+
}
728732

729733
RefExpr = RefExpr->IgnoreParens();
730734
ELoc = RefExpr->getExprLoc();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %clang_cc1 -verify -x c++ -std=c++11 -fompss-2 -ferror-limit 100 -o - %s
2+
3+
template<typename T>
4+
T adder(T v) {
5+
return v;
6+
}
7+
8+
template<typename T, typename... Args>
9+
T adder(T first, Args... args) {
10+
T tmp;
11+
#pragma oss task firstprivate(args) // expected-error {{variadic templates are not allowed in OmpSs-2 clauses}}
12+
{
13+
tmp = first + adder(args...);
14+
}
15+
return tmp;
16+
}
17+
18+
int main() {
19+
int a = adder(1, 2, 3, 4);
20+
}

0 commit comments

Comments
 (0)