aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-10-13 17:22:14 +0000
committerDouglas Gregor <dgregor@apple.com>2010-10-13 17:22:14 +0000
commitb535041ee33c5eff255832bc5541c8d52aae8254 (patch)
tree5e2d6d3f5d283e693da17f28cfd9014da894c8d6
parent35495eb14f22c4e96956912e23ca2a433227ad8c (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116411 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/Diagnostic.h3
-rw-r--r--lib/Basic/Diagnostic.cpp10
-rw-r--r--lib/Sema/Sema.cpp2
-rw-r--r--test/SemaTemplate/temp_arg_nontype.cpp5
4 files changed, 17 insertions, 3 deletions
diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h
index e2850d9f04..55bda36e38 100644
--- a/include/clang/Basic/Diagnostic.h
+++ b/include/clang/Basic/Diagnostic.h
@@ -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
diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp
index 6430b7ec1c..102086b69d 100644
--- a/lib/Basic/Diagnostic.cpp
+++ b/lib/Basic/Diagnostic.cpp
@@ -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.
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 1b3572a649..042f605cf0 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -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()));
diff --git a/test/SemaTemplate/temp_arg_nontype.cpp b/test/SemaTemplate/temp_arg_nontype.cpp
index fffd1dd168..48c1289c85 100644
--- a/test/SemaTemplate/temp_arg_nontype.cpp
+++ b/test/SemaTemplate/temp_arg_nontype.cpp
@@ -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'}}
+}