r177110 - [PR15513/<rdar://problem/13409707>] Template arguments in diagnostics aren't always known at compile time.

Douglas Gregor dgregor at apple.com
Thu Mar 14 13:44:43 PDT 2013


Author: dgregor
Date: Thu Mar 14 15:44:43 2013
New Revision: 177110

URL: http://llvm.org/viewvc/llvm-project?rev=177110&view=rev
Log:
[PR15513/<rdar://problem/13409707>] Template arguments in diagnostics aren't always known at compile time.

Modified:
    cfe/trunk/lib/AST/ASTDiagnostic.cpp
    cfe/trunk/test/Misc/diag-template-diffing-cxx98.cpp

Modified: cfe/trunk/lib/AST/ASTDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDiagnostic.cpp?rev=177110&r1=177109&r2=177110&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTDiagnostic.cpp (original)
+++ cfe/trunk/lib/AST/ASTDiagnostic.cpp Thu Mar 14 15:44:43 2013
@@ -1093,7 +1093,7 @@ class TemplateDiff {
     Expr::EvalResult FromResult, ToResult;
     if (!FromExpr->EvaluateAsRValue(FromResult, Context) ||
         !ToExpr->EvaluateAsRValue(ToResult, Context))
-      assert(0 && "Template arguments must be known at compile time.");
+      return false;
 
     APValue &FromVal = FromResult.Val;
     APValue &ToVal = ToResult.Val;

Modified: cfe/trunk/test/Misc/diag-template-diffing-cxx98.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-template-diffing-cxx98.cpp?rev=177110&r1=177109&r2=177110&view=diff
==============================================================================
--- cfe/trunk/test/Misc/diag-template-diffing-cxx98.cpp (original)
+++ cfe/trunk/test/Misc/diag-template-diffing-cxx98.cpp Thu Mar 14 15:44:43 2013
@@ -4,4 +4,14 @@ namespace PR14342 {
   template<typename T, char a> struct X {};
   X<int, 1> x = X<long, 257>();
   // CHECK: error: no viable conversion from 'X<long, [...]>' to 'X<int, [...]>'
-}
\ No newline at end of file
+}
+
+namespace PR15513 {
+  template <int x, int y = x+1>
+  class A {};
+
+  void foo(A<0> &M) {
+    // CHECK: no viable conversion from 'A<[...], (default) x + 1>' to 'A<[...], 0>'
+    A<0, 0> N = M;
+  }
+}





More information about the cfe-commits mailing list