]> granicus.if.org Git - clang/commitdiff
Fix a silly bug in the suppression of non-error diagnostics in a
authorDouglas Gregor <dgregor@apple.com>
Wed, 13 Oct 2010 17:22:14 +0000 (17:22 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 13 Oct 2010 17:22:14 +0000 (17:22 +0000)
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

include/clang/Basic/Diagnostic.h
lib/Basic/Diagnostic.cpp
lib/Sema/Sema.cpp
test/SemaTemplate/temp_arg_nontype.cpp

index e2850d9f048564d6a7877c95ac558a8ca6db4aa5..55bda36e38ee49ee26edd8ae62d77cebac3068d6 100644 (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
index 6430b7ec1c825142436c31b5408bd6f76fd3d16a..102086b69d1c57396fbeae8ffa4a8cfb0da32208 100644 (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.
index 1b3572a6498b33a96e2384741751250cd7dc303e..042f605cf0cd340ce1fb2716b1b5d20832a7c8af 100644 (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()));
index fffd1dd1684f799f86245f52476f2ced78b76e3c..48c1289c855ffc4a17b709b1dee0b627e5e2b321 100644 (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'}}
+}