[cfe-commits] r135681 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDeclObjC.cpp test/SemaObjC/missing-method-return-type.m
Douglas Gregor
dgregor at apple.com
Thu Jul 21 10:02:33 PDT 2011
On Jul 21, 2011, at 10:00 AM, Fariborz Jahanian wrote:
> Author: fjahanian
> Date: Thu Jul 21 12:00:47 2011
> New Revision: 135681
>
> URL: http://llvm.org/viewvc/llvm-project?rev=135681&view=rev
> Log:
> objc - Diagnose missing method return type specifier under
> a warning flag. // rdar://9615045
>
> Added:
> cfe/trunk/test/SemaObjC/missing-method-return-type.m
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=135681&r1=135680&r2=135681&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Jul 21 12:00:47 2011
> @@ -108,6 +108,7 @@
> def BindToTemporaryCopy : DiagGroup<"bind-to-temporary-copy">;
> def SelfAssignment : DiagGroup<"self-assign">;
> def SemiBeforeMethodBody : DiagGroup<"semicolon-before-method-body">;
> +def MissingMethodReturnType : DiagGroup<"missing-method-return-type">;
> def : DiagGroup<"sequence-point">;
> def Shadow : DiagGroup<"shadow">;
> def : DiagGroup<"shorten-64-to-32">;
> @@ -243,6 +244,7 @@
> IgnoredQualifiers,
> InitializerOverrides,
> SemiBeforeMethodBody,
> + MissingMethodReturnType,
> SignCompare,
> UnusedParameter
> ]>;
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=135681&r1=135680&r2=135681&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 21 12:00:47 2011
> @@ -4339,6 +4339,9 @@
> def ext_typecheck_base_super : Warning<
> "method parameter type %0 does not match "
> "super class method parameter type %1">, InGroup<SuperSubClassMismatch>, DefaultIgnore;
> +def warn_missing_method_return_type : Warning<
> + "method has no return type specified; defaults to 'id'">,
> + InGroup<MissingMethodReturnType>, DefaultIgnore;
>
> // Spell-checking diagnostics
> def err_unknown_typename_suggest : Error<
>
> Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=135681&r1=135680&r2=135681&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Jul 21 12:00:47 2011
> @@ -2298,8 +2298,10 @@
> << 0 << resultDeclType;
> return 0;
> }
> - } else // get the type for "id".
> + } else { // get the type for "id".
> resultDeclType = Context.getObjCIdType();
> + Diag(MethodLoc, diag::warn_missing_method_return_type);
> + }
How about adding a Fix-It to add the "(id)"?
- Doug
More information about the cfe-commits
mailing list