]> granicus.if.org Git - clang/commitdiff
Add a bunch of missing calls to DiagnoseSentinelCalls. <rdar://problem/10885993>.
authorEli Friedman <eli.friedman@gmail.com>
Sat, 18 Feb 2012 04:48:30 +0000 (04:48 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sat, 18 Feb 2012 04:48:30 +0000 (04:48 +0000)
This should probably be refactored... but it isn't completely obvious what refactoring is best.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150869 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
lib/Sema/SemaExprCXX.cpp
lib/Sema/SemaOverload.cpp
test/SemaCXX/attr-sentinel.cpp

index d271921b7bc34ba28f6b5b03f8d5b2b5697f51f8..0b785f3099054b4363dfa214dcab760018f36175 100644 (file)
@@ -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;
 }
 
index 74bac6714007a8fa0d96f0cb49d179697e8d41b4..80078207da6d63a93b7b74e906a6709224f889ad 100644 (file)
@@ -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
index 2b025da08854e6c6e6c2b58d77103ca388b48ceb..bc48f08a34085d9c463a94bcb2e87b1201955865 100644 (file)
@@ -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;
 
index 56c8f881600b90b2160bf55d329447d9a6aed7f8..92c6e21444fa35e834300fcd364ed8366c207a8f 100644 (file)
@@ -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}}
+}