From: Chad Rosier Date: Fri, 3 Feb 2012 01:49:51 +0000 (+0000) Subject: [frontend] Don't allow a mapping to a warning override an error/fatal mapping. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7a0a31ce0cd38147bfe853f71a3f7261444ddf4c;p=clang [frontend] Don't allow a mapping to a warning override an error/fatal mapping. rdar://10736625 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149662 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp index 369c32dc12..d18d7606d8 100644 --- a/lib/Basic/Diagnostic.cpp +++ b/lib/Basic/Diagnostic.cpp @@ -172,6 +172,13 @@ void DiagnosticsEngine::setDiagnosticMapping(diag::kind Diag, diag::Mapping Map, FullSourceLoc Loc(L, *SourceMgr); FullSourceLoc LastStateChangePos = DiagStatePoints.back().Loc; + // Don't allow a mapping to a warning override an error/fatal mapping. + if (Map == diag::MAP_WARNING) { + DiagnosticMappingInfo &Info = GetCurDiagState()->getOrAddMappingInfo(Diag); + if (Info.getMapping() == diag::MAP_ERROR || + Info.getMapping() == diag::MAP_FATAL) + Map = Info.getMapping(); + } DiagnosticMappingInfo MappingInfo = makeMappingInfo(Map, L); // Common case; setting all the diagnostics of a group in one place. diff --git a/test/Analysis/null-deref-ps.c b/test/Analysis/null-deref-ps.c index 31dafe1610..a707970a34 100644 --- a/test/Analysis/null-deref-ps.c +++ b/test/Analysis/null-deref-ps.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode,experimental.deadcode.IdempotentOperations,experimental.core -std=gnu99 -analyzer-store=region -analyzer-constraints=range -analyzer-purge=none -verify %s -Wreturn-type -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode,experimental.deadcode.IdempotentOperations,experimental.core -std=gnu99 -analyzer-store=region -analyzer-constraints=range -verify %s -Wreturn-type +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode,experimental.deadcode.IdempotentOperations,experimental.core -std=gnu99 -analyzer-store=region -analyzer-constraints=range -analyzer-purge=none -verify %s -Wno-error=return-type +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode,experimental.deadcode.IdempotentOperations,experimental.core -std=gnu99 -analyzer-store=region -analyzer-constraints=range -verify %s -Wno-error=return-type typedef unsigned uintptr_t; diff --git a/test/CodeGen/statements.c b/test/CodeGen/statements.c index 1d4f633f61..e2bbb5a90a 100644 --- a/test/CodeGen/statements.c +++ b/test/CodeGen/statements.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Wreturn-type %s -emit-llvm-only +// RUN: %clang_cc1 -Wno-error=return-type %s -emit-llvm-only void test1(int x) { switch (x) { diff --git a/test/Sema/return.c b/test/Sema/return.c index d9456b6e35..7a4c1f8e51 100644 --- a/test/Sema/return.c +++ b/test/Sema/return.c @@ -1,4 +1,4 @@ -// RUN: %clang %s -fsyntax-only -Wignored-qualifiers -Wreturn-type -Xclang -verify -fblocks -Wno-unreachable-code -Wno-unused-value +// RUN: %clang %s -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -Xclang -verify -fblocks -Wno-unreachable-code -Wno-unused-value // clang emits the following warning by default. // With GCC, -pedantic, -Wreturn-type or -Wall are required to produce the diff --git a/test/SemaCXX/vararg-non-pod.cpp b/test/SemaCXX/vararg-non-pod.cpp index 7e193ec839..86b560e814 100644 --- a/test/SemaCXX/vararg-non-pod.cpp +++ b/test/SemaCXX/vararg-non-pod.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s -Wnon-pod-varargs +// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s -Wno-error=non-pod-varargs extern char version[]; diff --git a/test/SemaObjCXX/vararg-non-pod.mm b/test/SemaObjCXX/vararg-non-pod.mm index 7e5c4c6c97..5a6281d71c 100644 --- a/test/SemaObjCXX/vararg-non-pod.mm +++ b/test/SemaObjCXX/vararg-non-pod.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -Wnon-pod-varargs +// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-error=non-pod-varargs extern char version[];