From: Douglas Gregor Date: Fri, 21 Dec 2012 23:03:27 +0000 (+0000) Subject: Use a safe default width for template-diff'ing integral arguments, in X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=335153679daf37c13a8c89266056b4be061e34e3;p=clang Use a safe default width for template-diff'ing integral arguments, in case we can't find an exact width to use. Fixes crash in . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170951 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTDiagnostic.cpp b/lib/AST/ASTDiagnostic.cpp index 6fd07e1ef3..4b9ecdedd0 100644 --- a/lib/AST/ASTDiagnostic.cpp +++ b/lib/AST/ASTDiagnostic.cpp @@ -848,7 +848,7 @@ class TemplateDiff { dyn_cast(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() && diff --git a/test/Misc/diag-template-diffing.cpp b/test/Misc/diag-template-diffing.cpp index e7a8048870..bb85a45d5d 100644 --- a/test/Misc/diag-template-diffing.cpp +++ b/test/Misc/diag-template-diffing.cpp @@ -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 + struct X { }; + + struct A { + virtual X foo(); + }; + + struct B : A { + // CHECK-ELIDE-NOTREE: virtual function 'foo' has a different return type + virtual X foo(); + }; +} + // CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated. // CHECK-NOELIDE-NOTREE: {{[0-9]*}} errors generated. // CHECK-ELIDE-TREE: {{[0-9]*}} errors generated.