[cfe-commits] r172878 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDecl.cpp

NAKAMURA Takumi geek4civic at gmail.com
Fri Jan 18 17:49:49 PST 2013


Ted, I have reverted it in r172879, excuse me.
SemaCXX/uninitialized.cpp failed;
http://bb.pgr.jp/builders/cmake-clang-x86_64-linux/builds/2861

Could you reproduce?

...Takumi

2013/1/19 Ted Kremenek <kremenek at apple.com>:
> Author: kremenek
> Date: Fri Jan 18 18:49:00 2013
> New Revision: 172878
>
> URL: http://llvm.org/viewvc/llvm-project?rev=172878&view=rev
> Log:
> Reword warning about using a *static* variable within its own initialization.
>
> The warning is still under -Wuninitialized (although technically this
> is defined behavior), but under a subgroup -Wstatic-self-init.
>
> This addresses PR 10265.
>
> Modified:
>     cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>     cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>     cfe/trunk/lib/Sema/SemaDecl.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=172878&r1=172877&r2=172878&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jan 18 18:49:00 2013
> @@ -259,7 +259,9 @@
>  def Unicode  : DiagGroup<"unicode">;
>  def UninitializedMaybe : DiagGroup<"conditional-uninitialized">;
>  def UninitializedSometimes : DiagGroup<"sometimes-uninitialized">;
> -def Uninitialized  : DiagGroup<"uninitialized", [UninitializedSometimes]>;
> +def UninitializedStaticSelfInit : DiagGroup<"static-self-init">;
> +def Uninitialized  : DiagGroup<"uninitialized", [UninitializedSometimes,
> +                                                 UninitializedStaticSelfInit]>;
>  def UnknownPragmas : DiagGroup<"unknown-pragmas">;
>  def UnknownWarningOption : DiagGroup<"unknown-warning-option">;
>  def NSobjectAttribute : DiagGroup<"NSObject-attribute">;
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=172878&r1=172877&r2=172878&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jan 18 18:49:00 2013
> @@ -1292,6 +1292,9 @@
>  def warn_reference_field_is_uninit : Warning<
>    "reference %0 is not yet bound to a value when used here">,
>    InGroup<Uninitialized>;
> +def warn_static_self_reference_in_init : Warning<
> +  "static variable %0 is suspiciously used within its own initialization">,
> +  InGroup<UninitializedStaticSelfInit>;
>  def warn_uninit_self_reference_in_init : Warning<
>    "variable %0 is uninitialized when used within its own initialization">,
>    InGroup<Uninitialized>;
>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=172878&r1=172877&r2=172878&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Jan 18 18:49:00 2013
> @@ -6683,11 +6683,17 @@
>      void VisitObjCMessageExpr(ObjCMessageExpr *E) { return; }
>
>      void HandleDeclRefExpr(DeclRefExpr *DRE) {
> -      Decl* ReferenceDecl = DRE->getDecl();
> +      Decl* ReferenceDecl = DRE->getDecl();
>        if (OrigDecl != ReferenceDecl) return;
> -      unsigned diag = isReferenceType
> -          ? diag::warn_uninit_self_reference_in_reference_init
> -          : diag::warn_uninit_self_reference_in_init;
> +      unsigned diag;
> +      if (isReferenceType) {
> +        diag = diag::warn_uninit_self_reference_in_reference_init;
> +      } else if (cast<VarDecl>(OrigDecl)->isStaticLocal()) {
> +        diag = diag::warn_static_self_reference_in_init;
> +      } else {
> +        diag = diag::warn_uninit_self_reference_in_init;
> +      }
> +
>        S.DiagRuntimeBehavior(DRE->getLocStart(), DRE,
>                              S.PDiag(diag)
>                                << DRE->getNameInfo().getName()
>
>
> _______________________________________________
> 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