r218895 - Diagnose mixed use of '_' and '.' as version

Justin Bogner mail at justinbogner.com
Fri Oct 3 00:42:47 PDT 2014


Fariborz Jahanian <fjahanian at apple.com> writes:
> Author: fjahanian
> Date: Thu Oct  2 12:57:26 2014
> New Revision: 218895
>
> URL: http://llvm.org/viewvc/llvm-project?rev=218895&view=rev
> Log:
> Diagnose mixed use of '_' and '.' as version
> separators in my previous patch. 
>
> Modified:
>     cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
>     cfe/trunk/lib/Parse/ParseDecl.cpp
>     cfe/trunk/test/SemaObjC/attr-availability-1.m
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=218895&r1=218894&r2=218895&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Thu Oct  2 12:57:26 2014
> @@ -775,6 +775,9 @@ def err_lambda_missing_parens : Error<
>  // Availability attribute
>  def err_expected_version : Error<
>    "expected a version of the form 'major[.minor[.subminor]]'">;
> +def warn_expected_consistent_version_separator : Warning<
> +  "use same version number separators '_' or '.'; as in "
> +  "'major[.minor[.subminor]]'">, InGroup<Availability>;
>  def err_zero_version : Error<
>    "version number must have non-zero major, minor, or sub-minor version">;
>  def err_availability_expected_platform : Error<
>
> Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=218895&r1=218894&r2=218895&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Oct  2 12:57:26 2014
> @@ -688,7 +688,8 @@ VersionTuple Parser::ParseVersionTuple(S
>      return VersionTuple(Major);
>    }
>  
> -  if (!VersionNumberSeparator(ThisTokBegin[AfterMajor])
> +  const char AfterMajorSeparator = ThisTokBegin[AfterMajor];
> +  if (!VersionNumberSeparator(AfterMajorSeparator)
>        || (AfterMajor + 1 == ActualLength)) {
>      Diag(Tok, diag::err_expected_version);
>      SkipUntil(tok::comma, tok::r_paren,
> @@ -716,13 +717,17 @@ VersionTuple Parser::ParseVersionTuple(S
>      return VersionTuple(Major, Minor);
>    }
>  
> +  const char AfterMinorSeparator = ThisTokBegin[AfterMinor];
>    // If what follows is not a '.' or '_', we have a problem.
> -  if (!VersionNumberSeparator(ThisTokBegin[AfterMinor])) {
> +  if (!VersionNumberSeparator(AfterMinorSeparator)) {

The comment should probably be updated to reflect that we're looking for
the same separator as before.

>      Diag(Tok, diag::err_expected_version);
>      SkipUntil(tok::comma, tok::r_paren,
>                StopAtSemi | StopBeforeMatch | StopAtCodeCompletion);
>      return VersionTuple();
>    }
> +  
> +  if (AfterMajorSeparator != AfterMinorSeparator)
> +    Diag(Tok, diag::warn_expected_consistent_version_separator);
>  
>    // Parse the subminor version.
>    unsigned AfterSubminor = AfterMinor + 1;
>
> Modified: cfe/trunk/test/SemaObjC/attr-availability-1.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-availability-1.m?rev=218895&r1=218894&r2=218895&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaObjC/attr-availability-1.m (original)
> +++ cfe/trunk/test/SemaObjC/attr-availability-1.m Thu Oct  2 12:57:26 2014
> @@ -90,3 +90,8 @@ id NSNibOwner, topNibObjects;
>  }
>  
>  @end
> +
> + at interface Mixed
> +- (void)Meth1 __attribute__((availability(macosx,introduced=10.3_0))); // expected-warning {{use same version number separators '_' or '.'}}
> +- (void)Meth2 __attribute__((availability(macosx,introduced=10_3.1))); // expected-warning {{use same version number separators '_' or '.'}}
> + at end
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list