From 03bf10dc4f245a17ee4f702461cba5120cc4d09b Mon Sep 17 00:00:00 2001 From: Richard Trieu Date: Sat, 20 Jul 2013 03:49:02 +0000 Subject: [PATCH] If a default argument is a dependent type, get the real type from the desugared template. Passing around dependent types can lead to integral arguments that cannot be evaluated. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186757 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ASTDiagnostic.cpp | 10 +++++++--- test/Misc/diag-template-diffing.cpp | 26 ++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/lib/AST/ASTDiagnostic.cpp b/lib/AST/ASTDiagnostic.cpp index bc707ddbc1..eb22632c93 100644 --- a/lib/AST/ASTDiagnostic.cpp +++ b/lib/AST/ASTDiagnostic.cpp @@ -1054,10 +1054,14 @@ class TemplateDiff { if (!Iter.isEnd()) return Iter->getAsType(); - if (!isVariadic) - return DefaultTTPD->getDefaultArgument(); + if (isVariadic) + return QualType(); + + QualType ArgType = DefaultTTPD->getDefaultArgument(); + if (ArgType->isDependentType()) + return Iter.getDesugar().getAsType(); - return QualType(); + return ArgType; } /// GetExpr - Retrieves the template expression argument, including default diff --git a/test/Misc/diag-template-diffing.cpp b/test/Misc/diag-template-diffing.cpp index cacc5c97fd..722ce98ecf 100644 --- a/test/Misc/diag-template-diffing.cpp +++ b/test/Misc/diag-template-diffing.cpp @@ -935,10 +935,10 @@ namespace DependentDefault { B b3; b1 = b2; // CHECK-ELIDE-NOTREE: no viable overloaded '=' - // CHECK-ELIDE-NOTREE: no known conversion from 'B::Ty>' to 'B' + // CHECK-ELIDE-NOTREE: no known conversion from 'B' to 'B' b3 = b1; // CHECK-ELIDE-NOTREE: no viable overloaded '=' - // CHECK-ELIDE-NOTREE: no known conversion from 'B<[...], (default) Trait::Ty>' to 'B<[...], char>' + // CHECK-ELIDE-NOTREE: no known conversion from 'B<[...], (default) int>' to 'B<[...], char>' b2 = b3; // CHECK-ELIDE-NOTREE: no viable overloaded '=' // CHECK-ELIDE-NOTREE: no known conversion from 'B' to 'B' @@ -1029,6 +1029,28 @@ namespace PointerArguments { } } +namespace DependentInt { + template struct INT; + + template > + struct C; + + struct N { + static const int val = 1; + }; + + template + struct M {}; + + void test() { + using T1 = M>>; + using T2 = M>; + T2 p; + T1 x = p; + // CHECK-ELIDE-NOTREE: no viable conversion from 'M>>' to 'M>>' + } +} + // CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated. // CHECK-NOELIDE-NOTREE: {{[0-9]*}} errors generated. // CHECK-ELIDE-TREE: {{[0-9]*}} errors generated. -- 2.40.0