Fix a silly bug in the suppression of non-error diagnostics in a

SFINAE context, where we weren't getting the right diagnostic argument
count. I blame DiagnosticBuilder's weirdness. Fixes PR8372.

llvm-svn: 116411
This commit is contained in:
Douglas Gregor 2010-10-13 17:22:14 +00:00
parent 2216af3fa8
commit b39215942e
4 changed files with 17 additions and 3 deletions

View File

@ -669,6 +669,9 @@ class DiagnosticBuilder {
: DiagObj(diagObj), NumArgs(0), NumRanges(0), NumFixItHints(0) {}
friend class PartialDiagnostic;
protected:
void FlushCounts();
public:
/// Copy constructor. When copied, this "takes" the diagnostic info from the

View File

@ -625,6 +625,12 @@ bool Diagnostic::ProcessDiag() {
return true;
}
void DiagnosticBuilder::FlushCounts() {
DiagObj->NumDiagArgs = NumArgs;
DiagObj->NumDiagRanges = NumRanges;
DiagObj->NumFixItHints = NumFixItHints;
}
bool DiagnosticBuilder::Emit() {
// If DiagObj is null, then its soul was stolen by the copy ctor
// or the user called Emit().
@ -632,9 +638,7 @@ bool DiagnosticBuilder::Emit() {
// When emitting diagnostics, we set the final argument count into
// the Diagnostic object.
DiagObj->NumDiagArgs = NumArgs;
DiagObj->NumDiagRanges = NumRanges;
DiagObj->NumFixItHints = NumFixItHints;
FlushCounts();
// Process the diagnostic, sending the accumulated information to the
// DiagnosticClient.

View File

@ -455,7 +455,9 @@ Sema::SemaDiagnosticBuilder::~SemaDiagnosticBuilder() {
case Diagnostic::SFINAE_Suppress:
// Make a copy of this suppressed diagnostic and store it with the
// template-deduction information;
FlushCounts();
DiagnosticInfo DiagInfo(&SemaRef.Diags);
Info->addSuppressedDiagnostic(DiagInfo.getLocation(),
PartialDiagnostic(DiagInfo,
SemaRef.Context.getDiagAllocator()));

View File

@ -243,3 +243,8 @@ namespace test8 {
B<&c03> b03;
}
}
namespace PR8372 {
template <int I> void foo() { } // expected-note{{template parameter is declared here}}
void bar() { foo <0x80000000> (); } // expected-warning{{non-type template argument value '2147483648' truncated to '-2147483648' for template parameter of type 'int'}}
}