]> granicus.if.org Git - clang/commitdiff
Use a safe default width for template-diff'ing integral arguments, in
authorDouglas Gregor <dgregor@apple.com>
Fri, 21 Dec 2012 23:03:27 +0000 (23:03 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 21 Dec 2012 23:03:27 +0000 (23:03 +0000)
case we can't find an exact width to use. Fixes crash in
<rdar://problem/12456626>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170951 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTDiagnostic.cpp
test/Misc/diag-template-diffing.cpp

index 6fd07e1ef33440cdfb590dd95d8411e025bb508f..4b9ecdedd0c13b8c47521187c84c414fb715b96a 100644 (file)
@@ -848,7 +848,7 @@ class TemplateDiff {
               dyn_cast<NonTypeTemplateParmDecl>(ParamND)) {
         Expr *FromExpr, *ToExpr;
         llvm::APSInt FromInt, ToInt;
-        unsigned ParamWidth = 0;
+        unsigned ParamWidth = 128; // Safe default
         if (DefaultNTTPD->getType()->isIntegralOrEnumerationType())
           ParamWidth = Context.getIntWidth(DefaultNTTPD->getType());
         bool HasFromInt = !FromIter.isEnd() &&
index e7a8048870678774bb9fe55967dcb9bd9dc442a4..bb85a45d5d5606d4d4624bf57b936ebbc559c982 100644 (file)
@@ -812,6 +812,24 @@ namespace PR14489 {
   // CHECK-ELIDE-NOTREE: non-const lvalue reference to type 'VariableList<>' cannot bind to a temporary of type 'VariableList<>'
 }
 
+namespace rdar12456626 {
+  struct IntWrapper {
+    typedef int type;
+  };
+  
+  template<typename T, typename T::type V>
+  struct X { };
+  
+  struct A {
+    virtual X<IntWrapper, 1> foo();
+  };
+  
+  struct B : A {
+    // CHECK-ELIDE-NOTREE: virtual function 'foo' has a different return type
+    virtual X<IntWrapper, 2> foo();
+  };
+}
+
 // CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated.
 // CHECK-NOELIDE-NOTREE: {{[0-9]*}} errors generated.
 // CHECK-ELIDE-TREE: {{[0-9]*}} errors generated.