From owner-svn-src-all@FreeBSD.ORG Thu Oct 25 12:18:20 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EC06F16E; Thu, 25 Oct 2012 12:18:19 +0000 (UTC) (envelope-from rdivacky@vlakno.cz) Received: from vlakno.cz (mail.vlakno.cz [178.238.39.38]) by mx1.freebsd.org (Postfix) with ESMTP id 83A4C8FC0C; Thu, 25 Oct 2012 12:18:18 +0000 (UTC) Received: by vlakno.cz (Postfix, from userid 1002) id B275F1CC55C6; Thu, 25 Oct 2012 14:12:23 +0200 (CEST) Date: Thu, 25 Oct 2012 14:12:23 +0200 From: Roman Divacky To: Ed Schouten Subject: Re: svn commit: r242080 - in head/contrib/llvm/tools/clang: include/clang/Basic lib/Sema Message-ID: <20121025121223.GA23573@freebsd.org> References: <201210251013.q9PADwYO029047@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201210251013.q9PADwYO029047@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Oct 2012 12:18:20 -0000 Why? I can understand cherry picking revisions that fix bugs FreeBSD users hit but why additional features? Why cant this wait for next proper llvm/clang import? On Thu, Oct 25, 2012 at 10:13:58AM +0000, Ed Schouten wrote: > Author: ed > Date: Thu Oct 25 10:13:58 2012 > New Revision: 242080 > URL: http://svn.freebsd.org/changeset/base/242080 > > Log: > Pull in r166498 from upstream clang trunk: > > Add a new warning -Wmissing-variable-declarations, to warn about variables > defined without a previous declaration. This is similar to > -Wmissing-prototypes, but for variables instead of functions. > > Modified: > head/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td > head/contrib/llvm/tools/clang/lib/Sema/Sema.cpp > head/contrib/llvm/tools/clang/lib/Sema/SemaDecl.cpp > > Modified: head/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td > ============================================================================== > --- head/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td Thu Oct 25 09:39:14 2012 (r242079) > +++ head/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td Thu Oct 25 10:13:58 2012 (r242080) > @@ -3058,6 +3058,9 @@ def note_sentinel_here : Note< > def warn_missing_prototype : Warning< > "no previous prototype for function %0">, > InGroup>, DefaultIgnore; > +def warn_missing_variable_declarations : Warning< > + "no previous extern declaration for non-static variable %0">, > + InGroup>, DefaultIgnore; > def err_redefinition : Error<"redefinition of %0">; > def err_definition_of_implicitly_declared_member : Error< > "definition of implicitly declared %select{default constructor|copy " > > Modified: head/contrib/llvm/tools/clang/lib/Sema/Sema.cpp > ============================================================================== > --- head/contrib/llvm/tools/clang/lib/Sema/Sema.cpp Thu Oct 25 09:39:14 2012 (r242079) > +++ head/contrib/llvm/tools/clang/lib/Sema/Sema.cpp Thu Oct 25 10:13:58 2012 (r242080) > @@ -648,6 +648,8 @@ void Sema::ActOnEndOfTranslationUnit() { > diag::err_tentative_def_incomplete_type)) > VD->setInvalidDecl(); > > + CheckCompleteVariableDeclaration(VD); > + > // Notify the consumer that we've completed a tentative definition. > if (!VD->isInvalidDecl()) > Consumer.CompleteTentativeDefinition(VD); > > Modified: head/contrib/llvm/tools/clang/lib/Sema/SemaDecl.cpp > ============================================================================== > --- head/contrib/llvm/tools/clang/lib/Sema/SemaDecl.cpp Thu Oct 25 09:39:14 2012 (r242079) > +++ head/contrib/llvm/tools/clang/lib/Sema/SemaDecl.cpp Thu Oct 25 10:13:58 2012 (r242080) > @@ -6957,6 +6957,17 @@ void Sema::CheckCompleteVariableDeclarat > } > } > > + if (var->isThisDeclarationADefinition() && > + var->getLinkage() == ExternalLinkage) { > + // Find a previous declaration that's not a definition. > + VarDecl *prev = var->getPreviousDecl(); > + while (prev && prev->isThisDeclarationADefinition()) > + prev = prev->getPreviousDecl(); > + > + if (!prev) > + Diag(var->getLocation(), diag::warn_missing_variable_declarations) << var; > + } > + > // All the following checks are C++ only. > if (!getLangOpts().CPlusPlus) return; >