summaryrefslogtreecommitdiffstats
path: root/clang/test/Misc/diag-template-diffing.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2013-04-03 02:11:36 +0000
committerRichard Trieu <rtrieu@google.com>2013-04-03 02:11:36 +0000
commit981de5cef3ef4bf2502717bbeeaa772cdb870237 (patch)
tree4eecb53fed53131777e8c4cd12a4fbb2d323e9ea /clang/test/Misc/diag-template-diffing.cpp
parent43fe217b119998264be04a773c4770592663c306 (diff)
downloadbcm5719-llvm-981de5cef3ef4bf2502717bbeeaa772cdb870237.tar.gz
bcm5719-llvm-981de5cef3ef4bf2502717bbeeaa772cdb870237.zip
Fix a crasher in Template Diffing.
Value depenedent expressions for default arguments cannot be evaluated. Instead, use the desugared template type to get an argument expression that can be used. This is needed for both integer and declaration arguements. Also, move this common code into a separate function. Patch by Olivier Goffart! llvm-svn: 178609
Diffstat (limited to 'clang/test/Misc/diag-template-diffing.cpp')
-rw-r--r--clang/test/Misc/diag-template-diffing.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/clang/test/Misc/diag-template-diffing.cpp b/clang/test/Misc/diag-template-diffing.cpp
index 823bad2798c..fd331139a82 100644
--- a/clang/test/Misc/diag-template-diffing.cpp
+++ b/clang/test/Misc/diag-template-diffing.cpp
@@ -903,6 +903,61 @@ namespace ValueDecl {
}
}
+namespace DependentDefault {
+ template <typename> struct Trait {
+ enum { V = 40 };
+ typedef int Ty;
+ static int I;
+ };
+ int other;
+
+ template <typename T, int = Trait<T>::V > struct A {};
+ template <typename T, typename = Trait<T>::Ty > struct B {};
+ template <typename T, int& = Trait<T>::I > struct C {};
+
+ void test() {
+
+ A<int> a1;
+ A<char> a2;
+ A<int, 10> a3;
+ a1 = a2;
+ // CHECK-ELIDE-NOTREE: no viable overloaded '='
+ // CHECK-ELIDE-NOTREE: no known conversion from 'A<char, [...]>' to 'A<int, [...]>'
+ a3 = a1;
+ // CHECK-ELIDE-NOTREE: no viable overloaded '='
+ // CHECK-ELIDE-NOTREE: no known conversion from 'A<[...], (default) 40>' to 'A<[...], 10>'
+ a2 = a3;
+ // CHECK-ELIDE-NOTREE: no viable overloaded '='
+ // CHECK-ELIDE-NOTREE: no known conversion from 'A<int, 10>' to 'A<char, 40>'
+
+ B<int> b1;
+ B<char> b2;
+ B<int, char> b3;
+ b1 = b2;
+ // CHECK-ELIDE-NOTREE: no viable overloaded '='
+ // CHECK-ELIDE-NOTREE: no known conversion from 'B<char, (default) Trait<T>::Ty>' to 'B<int, int>'
+ b3 = b1;
+ // CHECK-ELIDE-NOTREE: no viable overloaded '='
+ // CHECK-ELIDE-NOTREE: no known conversion from 'B<[...], (default) Trait<T>::Ty>' to 'B<[...], char>'
+ b2 = b3;
+ // CHECK-ELIDE-NOTREE: no viable overloaded '='
+ // CHECK-ELIDE-NOTREE: no known conversion from 'B<int, char>' to 'B<char, int>'
+
+ C<int> c1;
+ C<char> c2;
+ C<int, other> c3;
+ c1 = c2;
+ // CHECK-ELIDE-NOTREE: no viable overloaded '='
+ // CHECK-ELIDE-NOTREE: no known conversion from 'C<char, (default) I>' to 'C<int, I>'
+ c3 = c1;
+ // CHECK-ELIDE-NOTREE: no viable overloaded '='
+ // CHECK-ELIDE-NOTREE: no known conversion from 'C<[...], (default) I>' to 'C<[...], other>'
+ c2 = c3;
+ // CHECK-ELIDE-NOTREE: no viable overloaded '='
+ // CHECK-ELIDE-NOTREE: no known conversion from 'C<int, other>' to 'C<char, I>'
+ }
+}
+
// CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated.
// CHECK-NOELIDE-NOTREE: {{[0-9]*}} errors generated.
// CHECK-ELIDE-TREE: {{[0-9]*}} errors generated.
OpenPOWER on IntegriCloud