aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-11-23 17:04:52 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-11-23 17:04:52 +0000
commit63b6ebe4e732f20fa24ea0666ed438dd5004cc20 (patch)
tree483ccd81b45e5ce99380a63a147c4d1763088f47
parent919b7e69781daf68766bb9af11ca1b9f246ce935 (diff)
Sema: Provide a valid source location when instantiating templates based on a CXXDefaultArgExpr.
Fixes PR13758. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168521 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/ExprCXX.h2
-rw-r--r--lib/Sema/SemaOverload.cpp2
-rw-r--r--test/SemaTemplate/default-expr-arguments.cpp18
3 files changed, 21 insertions, 1 deletions
diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h
index d4a0c32acd..9f213f1004 100644
--- a/include/clang/AST/ExprCXX.h
+++ b/include/clang/AST/ExprCXX.h
@@ -795,6 +795,8 @@ public:
return SourceRange();
}
+ SourceLocation getExprLoc() const LLVM_READONLY { return Loc; }
+
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXDefaultArgExprClass;
}
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 549fa8fc9a..0c37c599e8 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -2980,7 +2980,7 @@ IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
S.IsDerivedFrom(From->getType(), ToType)))
ConstructorsOnly = true;
- S.RequireCompleteType(From->getLocStart(), ToType, 0);
+ S.RequireCompleteType(From->getExprLoc(), ToType, 0);
// RequireCompleteType may have returned true due to some invalid decl
// during template instantiation, but ToType may be complete enough now
// to try to recover.
diff --git a/test/SemaTemplate/default-expr-arguments.cpp b/test/SemaTemplate/default-expr-arguments.cpp
index 1eefa9f895..4e76a5a04c 100644
--- a/test/SemaTemplate/default-expr-arguments.cpp
+++ b/test/SemaTemplate/default-expr-arguments.cpp
@@ -303,3 +303,21 @@ namespace PR12581 {
{
}
}
+
+namespace PR13758 {
+ template <typename T> struct move_from {
+ T invalid; // expected-error {{field has incomplete type 'void'}}
+ };
+ template <class K>
+ struct unordered_map {
+ explicit unordered_map(int n = 42);
+ unordered_map(move_from<K> other);
+ };
+ template<typename T>
+ void StripedHashTable() {
+ new unordered_map<void>(); // expected-note {{in instantiation of template class 'PR13758::move_from<void>' requested here}}
+ }
+ void tt() {
+ StripedHashTable<int>(); // expected-note {{in instantiation of function template specialization 'PR13758::StripedHashTable<int>' requested here}}
+ }
+}