diff options
| author | Douglas Gregor <dgregor@apple.com> | 2012-12-21 23:03:27 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2012-12-21 23:03:27 +0000 |
| commit | 2d5a5613cef7636438e7438d596a12013305e800 (patch) | |
| tree | d85473c0e63df95793488a5c180db3a084905ad2 | |
| parent | e1826d74646eae97c79a8499c1f1743305f8b57d (diff) | |
| download | bcm5719-llvm-2d5a5613cef7636438e7438d596a12013305e800.tar.gz bcm5719-llvm-2d5a5613cef7636438e7438d596a12013305e800.zip | |
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>.
llvm-svn: 170951
| -rw-r--r-- | clang/lib/AST/ASTDiagnostic.cpp | 2 | ||||
| -rw-r--r-- | clang/test/Misc/diag-template-diffing.cpp | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp index 6fd07e1ef33..4b9ecdedd0c 100644 --- a/clang/lib/AST/ASTDiagnostic.cpp +++ b/clang/lib/AST/ASTDiagnostic.cpp @@ -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() && diff --git a/clang/test/Misc/diag-template-diffing.cpp b/clang/test/Misc/diag-template-diffing.cpp index e7a80488706..bb85a45d5d5 100644 --- a/clang/test/Misc/diag-template-diffing.cpp +++ b/clang/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<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. |

