aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaDeclCXX.cpp5
-rw-r--r--lib/Sema/SemaExprCXX.cpp5
-rw-r--r--lib/Sema/SemaOverload.cpp4
-rw-r--r--test/SemaCXX/attr-sentinel.cpp17
4 files changed, 31 insertions, 0 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index d271921b7b..0b785f3099 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -8973,6 +8973,11 @@ Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor,
Proto, 0, Args, NumArgs, AllArgs,
CallType);
ConvertedArgs.append(AllArgs.begin(), AllArgs.end());
+
+ DiagnoseSentinelCalls(Constructor, Loc, AllArgs.data(), AllArgs.size());
+
+ // FIXME: Missing call to CheckFunctionCall or equivalent
+
return Invalid;
}
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 74bac67140..80078207da 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -1228,6 +1228,11 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
NumPlaceArgs = AllPlaceArgs.size();
if (NumPlaceArgs > 0)
PlaceArgs = &AllPlaceArgs[0];
+
+ DiagnoseSentinelCalls(OperatorNew, PlacementLParen,
+ PlaceArgs, NumPlaceArgs);
+
+ // FIXME: Missing call to CheckFunctionCall or equivalent
}
// Warn if the type is over-aligned and is being allocated by global operator
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 2b025da088..bc48f08a34 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -10398,6 +10398,8 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
RParenLoc))
return ExprError();
+ DiagnoseSentinelCalls(Method, LParenLoc, Args, NumArgs);
+
if (CheckFunctionCall(Method, TheCall))
return ExprError();
@@ -10701,6 +10703,8 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
if (IsError) return true;
+ DiagnoseSentinelCalls(Method, LParenLoc, Args, NumArgs);
+
if (CheckFunctionCall(Method, TheCall))
return true;
diff --git a/test/SemaCXX/attr-sentinel.cpp b/test/SemaCXX/attr-sentinel.cpp
index 56c8f88160..92c6e21444 100644
--- a/test/SemaCXX/attr-sentinel.cpp
+++ b/test/SemaCXX/attr-sentinel.cpp
@@ -1,6 +1,23 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+
void f(int, ...) __attribute__((sentinel));
void g() {
f(1, 2, __null);
}
+
+typedef __typeof__(sizeof(int)) size_t;
+
+struct S {
+ S(int,...) __attribute__((sentinel)); // expected-note {{marked sentinel}}
+ void a(int,...) __attribute__((sentinel)); // expected-note {{marked sentinel}}
+ void* operator new(size_t,...) __attribute__((sentinel)); // expected-note {{marked sentinel}}
+ void operator()(int,...) __attribute__((sentinel)); // expected-note {{marked sentinel}}
+};
+
+void class_test() {
+ S s(1,2,3); // expected-warning {{missing sentinel in function call}}
+ S* s2 = new (1,2,3) S(1, __null); // expected-warning {{missing sentinel in function call}}
+ s2->a(1,2,3); // expected-warning {{missing sentinel in function call}}
+ s(1,2,3); // expected-warning {{missing sentinel in function call}}
+}