r218394 - Downgrade error about stdcall decls with no prototype to a warning

Reid Kleckner reid at kleckner.net
Wed Sep 24 10:49:24 PDT 2014


Author: rnk
Date: Wed Sep 24 12:49:24 2014
New Revision: 218394

URL: http://llvm.org/viewvc/llvm-project?rev=218394&view=rev
Log:
Downgrade error about stdcall decls with no prototype to a warning

Fixes PR21027.  The MIDL compiler produces code that does this.

If we wanted to improve the warning, I think we could do this:
  void __stdcall f(); // Don't warn without -Wstrict-prototypes.
  void g() {
    f(); // Might warn, the user probably meant for f to take no args.
    f(1, 2, 3); // Warn, we have no idea what args f takes.
    f(1); // Error, this is insane, one of these calls is broken.
  }

Reviewers: thakis

Differential Revision: http://reviews.llvm.org/D5481

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/test/CodeGen/mrtd.c
    cfe/trunk/test/Sema/callingconv.c
    cfe/trunk/test/Sema/decl-microsoft-call-conv.c
    cfe/trunk/test/Sema/stdcall-fastcall.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=218394&r1=218393&r2=218394&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Sep 24 12:49:24 2014
@@ -2235,10 +2235,10 @@ def err_cconv_change : Error<
 def warn_cconv_ignored : Warning<
   "calling convention %0 ignored for this target">, InGroup<IgnoredAttributes>;
 def err_cconv_knr : Error<
-  "function with no prototype cannot use %0 calling convention">;
+  "function with no prototype cannot use the callee-cleanup %0 calling convention">;
 def warn_cconv_knr : Warning<
-  "function with no prototype cannot use %0 calling convention">,
-  DefaultError, InGroup<DiagGroup<"missing-prototype-for-cc">>;
+  "function with no prototype cannot use the callee-cleanup %0 calling convention">,
+  InGroup<DiagGroup<"missing-prototype-for-cc">>;
 def err_cconv_varargs : Error<
   "variadic function cannot use %0 calling convention">;
 def warn_cconv_varargs : Warning<

Modified: cfe/trunk/test/CodeGen/mrtd.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mrtd.c?rev=218394&r1=218393&r2=218394&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/mrtd.c (original)
+++ cfe/trunk/test/CodeGen/mrtd.c Wed Sep 24 12:49:24 2014
@@ -3,7 +3,7 @@
 // prototype-less __stdcall functions are only allowed in system headers.
 # 1 "fake_system_header.h" 1 3 4
 
-// CHECK: fake_system_header.h:9:3: warning: function with no prototype cannot use stdcall calling convention
+// CHECK: fake_system_header.h:9:3: warning: function with no prototype cannot use the callee-cleanup stdcall calling convention
 
 void baz(int arg);
 

Modified: cfe/trunk/test/Sema/callingconv.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/callingconv.c?rev=218394&r1=218393&r2=218394&view=diff
==============================================================================
--- cfe/trunk/test/Sema/callingconv.c (original)
+++ cfe/trunk/test/Sema/callingconv.c Wed Sep 24 12:49:24 2014
@@ -10,7 +10,7 @@ void __attribute__((stdcall)) bar(float
 void __attribute__((fastcall(1))) baz(float *a) { // expected-error {{'fastcall' attribute takes no arguments}}
 }
 
-void __attribute__((fastcall)) test0() { // expected-error {{function with no prototype cannot use fastcall calling convention}}
+void __attribute__((fastcall)) test0() { // expected-error {{function with no prototype cannot use the callee-cleanup fastcall calling convention}}
 }
 
 void __attribute__((fastcall)) test1(void) {

Modified: cfe/trunk/test/Sema/decl-microsoft-call-conv.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/decl-microsoft-call-conv.c?rev=218394&r1=218393&r2=218394&view=diff
==============================================================================
--- cfe/trunk/test/Sema/decl-microsoft-call-conv.c (original)
+++ cfe/trunk/test/Sema/decl-microsoft-call-conv.c Wed Sep 24 12:49:24 2014
@@ -12,10 +12,10 @@ void __thiscall CrcGenerateTableThiscall
 void __pascal CrcGenerateTablePascal(void);
 void __pascal CrcGenerateTablePascal() {}
 
-void __fastcall CrcGenerateTableNoProtoFastcall() {} // expected-error{{function with no prototype cannot use fastcall calling convention}}
-void __stdcall CrcGenerateTableNoProtoStdcall() {} // expected-error{{function with no prototype cannot use stdcall calling convention}}
-void __thiscall CrcGenerateTableNoProtoThiscall() {} // expected-error{{function with no prototype cannot use thiscall calling convention}}
-void __pascal CrcGenerateTableNoProtoPascal() {} // expected-error{{function with no prototype cannot use pascal calling convention}}
+void __fastcall CrcGenerateTableNoProtoFastcall() {} // expected-error{{function with no prototype cannot use the callee-cleanup fastcall calling convention}}
+void __stdcall CrcGenerateTableNoProtoStdcall() {} // expected-warning{{function with no prototype cannot use the callee-cleanup stdcall calling convention}}
+void __thiscall CrcGenerateTableNoProtoThiscall() {} // expected-error{{function with no prototype cannot use the callee-cleanup thiscall calling convention}}
+void __pascal CrcGenerateTableNoProtoPascal() {} // expected-error{{function with no prototype cannot use the callee-cleanup pascal calling convention}}
 
 // Regular calling convention is fine.
 void CrcGenerateTableNoProto() {}
@@ -23,7 +23,7 @@ void CrcGenerateTableNoProto() {}
 
 // In system headers, the stdcall version should be a warning.
 # 1 "fake_system_header.h" 1 3 4
-void __fastcall SystemHeaderFastcall() {} // expected-error{{function with no prototype cannot use fastcall calling convention}}
+void __fastcall SystemHeaderFastcall() {} // expected-error{{function with no prototype cannot use the callee-cleanup fastcall calling convention}}
 void __stdcall SystemHeaderStdcall() {}
-void __thiscall SystemHeaderThiscall() {} // expected-error{{function with no prototype cannot use thiscall calling convention}}
-void __pascal SystemHeaderPascal() {} // expected-error{{function with no prototype cannot use pascal calling convention}}
+void __thiscall SystemHeaderThiscall() {} // expected-error{{function with no prototype cannot use the callee-cleanup thiscall calling convention}}
+void __pascal SystemHeaderPascal() {} // expected-error{{function with no prototype cannot use the callee-cleanup pascal calling convention}}

Modified: cfe/trunk/test/Sema/stdcall-fastcall.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/stdcall-fastcall.c?rev=218394&r1=218393&r2=218394&view=diff
==============================================================================
--- cfe/trunk/test/Sema/stdcall-fastcall.c (original)
+++ cfe/trunk/test/Sema/stdcall-fastcall.c Wed Sep 24 12:49:24 2014
@@ -6,7 +6,7 @@ int __attribute__((fastcall)) var2; // e
 
 // Different CC qualifiers are not compatible
 void __attribute__((stdcall, fastcall)) foo3(void); // expected-error{{fastcall and stdcall attributes are not compatible}}
-void __attribute__((stdcall)) foo4(); // expected-note{{previous declaration is here}} expected-error{{function with no prototype cannot use stdcall calling convention}}
+void __attribute__((stdcall)) foo4(); // expected-note{{previous declaration is here}} expected-warning{{function with no prototype cannot use the callee-cleanup stdcall calling convention}}
 void __attribute__((fastcall)) foo4(void); // expected-error{{function declared 'fastcall' here was previously declared 'stdcall'}}
 
 // rdar://8876096





More information about the cfe-commits mailing list