[cfe-commits] r170951 - in /cfe/trunk: lib/AST/ASTDiagnostic.cpp test/Misc/diag-template-diffing.cpp
Douglas Gregor
dgregor at apple.com
Fri Dec 21 15:03:27 PST 2012
Author: dgregor
Date: Fri Dec 21 17:03:27 2012
New Revision: 170951
URL: http://llvm.org/viewvc/llvm-project?rev=170951&view=rev
Log:
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
<rdar://problem/12456626>.
Modified:
cfe/trunk/lib/AST/ASTDiagnostic.cpp
cfe/trunk/test/Misc/diag-template-diffing.cpp
Modified: cfe/trunk/lib/AST/ASTDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDiagnostic.cpp?rev=170951&r1=170950&r2=170951&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTDiagnostic.cpp (original)
+++ cfe/trunk/lib/AST/ASTDiagnostic.cpp Fri Dec 21 17:03:27 2012
@@ -848,7 +848,7 @@
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() &&
Modified: cfe/trunk/test/Misc/diag-template-diffing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-template-diffing.cpp?rev=170951&r1=170950&r2=170951&view=diff
==============================================================================
--- cfe/trunk/test/Misc/diag-template-diffing.cpp (original)
+++ cfe/trunk/test/Misc/diag-template-diffing.cpp Fri Dec 21 17:03:27 2012
@@ -812,6 +812,24 @@
// 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.
More information about the cfe-commits
mailing list