[cfe-commits] r136437 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp test/PCH/functions.c test/Sema/exprs.c

Peter Collingbourne peter at pcc.me.uk
Thu Jul 28 17:24:42 PDT 2011


Author: pcc
Date: Thu Jul 28 19:24:42 2011
New Revision: 136437

URL: http://llvm.org/viewvc/llvm-project?rev=136437&view=rev
Log:
Fix an inconsistency in Sema::ConvertArgumentsForCall in that
the callee note diagnostic was not emitted in the case where
there were too few arguments.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp
    cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp
    cfe/trunk/test/PCH/functions.c
    cfe/trunk/test/Sema/exprs.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=136437&r1=136436&r2=136437&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 28 19:24:42 2011
@@ -3696,11 +3696,11 @@
 def err_typecheck_call_too_many_args : Error<
   "too many arguments to %select{function|block|method}0 call, "
   "expected %1, have %2">;
-def note_typecheck_call_too_many_args : Note<
-  "%0 declared here">;
 def err_typecheck_call_too_many_args_at_most : Error<
   "too many arguments to %select{function|block|method}0 call, "
   "expected at most %1, have %2">;
+def note_callee_decl : Note<
+  "%0 declared here">;
 def warn_call_wrong_number_of_arguments : Warning<
   "too %select{few|many}0 arguments in call to %1">;
 def err_atomic_builtin_must_be_pointer : Error<

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=136437&r1=136436&r2=136437&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Jul 28 19:24:42 2011
@@ -3231,10 +3231,18 @@
   // If too few arguments are available (and we don't have default
   // arguments for the remaining parameters), don't make the call.
   if (NumArgs < NumArgsInProto) {
-    if (!FDecl || NumArgs < FDecl->getMinRequiredArguments())
-      return Diag(RParenLoc, diag::err_typecheck_call_too_few_args)
+    if (!FDecl || NumArgs < FDecl->getMinRequiredArguments()) {
+      Diag(RParenLoc, diag::err_typecheck_call_too_few_args)
         << Fn->getType()->isBlockPointerType()
         << NumArgsInProto << NumArgs << Fn->getSourceRange();
+
+      // Emit the location of the prototype.
+      if (FDecl && !FDecl->getBuiltinID())
+        Diag(FDecl->getLocStart(), diag::note_callee_decl)
+          << FDecl;
+
+      return true;
+    }
     Call->setNumArgs(Context, NumArgsInProto);
   }
 
@@ -3251,9 +3259,8 @@
 
       // Emit the location of the prototype.
       if (FDecl && !FDecl->getBuiltinID())
-        Diag(FDecl->getLocStart(),
-             diag::note_typecheck_call_too_many_args)
-             << FDecl;
+        Diag(FDecl->getLocStart(), diag::note_callee_decl)
+          << FDecl;
       
       // This deletes the extra arguments.
       Call->setNumArgs(Context, NumArgsInProto);

Modified: cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp?rev=136437&r1=136436&r2=136437&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp Thu Jul 28 19:24:42 2011
@@ -5,7 +5,7 @@
 }; 
 
 struct B : public A {
-  void f(int a);
+  void f(int a); // expected-note{{'f' declared here}}
 }; 
 
 void m() {

Modified: cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp?rev=136437&r1=136436&r2=136437&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp Thu Jul 28 19:24:42 2011
@@ -41,7 +41,7 @@
   
   void m()
   {
-    void f(int, int);
+    void f(int, int); // expected-note{{'f' declared here}}
     f(4);  // expected-error{{too few arguments to function call}}
     void f(int, int = 5); // expected-note{{previous definition}}
     f(4); // okay

Modified: cfe/trunk/test/PCH/functions.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/functions.c?rev=136437&r1=136436&r2=136437&view=diff
==============================================================================
--- cfe/trunk/test/PCH/functions.c (original)
+++ cfe/trunk/test/PCH/functions.c Thu Jul 28 19:24:42 2011
@@ -4,7 +4,7 @@
 // Test with pch.
 // RUN: %clang_cc1 -emit-pch -o %t %S/functions.h
 // RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s 
-
+// expected-note{{'f1' declared here}}
 int f0(int x0, int y0, ...) { return x0 + y0; }
 // expected-note{{passing argument to parameter here}}
 float *test_f1(int val, double x, double y) {

Modified: cfe/trunk/test/Sema/exprs.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/exprs.c?rev=136437&r1=136436&r2=136437&view=diff
==============================================================================
--- cfe/trunk/test/Sema/exprs.c (original)
+++ cfe/trunk/test/Sema/exprs.c Thu Jul 28 19:24:42 2011
@@ -163,7 +163,7 @@
 }
 
 // PR6501
-void test18_a(int a); // expected-note {{'test18_a' declared here}}
+void test18_a(int a); // expected-note 2 {{'test18_a' declared here}}
 void test18(int b) {
   test18_a(b, b); // expected-error {{too many arguments to function call, expected 1, have 2}}
   test18_a(); // expected-error {{too few arguments to function call, expected 1, have 0}}





More information about the cfe-commits mailing list