summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-05-09 20:45:16 +0000
committerDouglas Gregor <dgregor@apple.com>2011-05-09 20:45:16 +0000
commita7203e537df20b554f7aa678c7de546bc23b87d7 (patch)
tree366ff5f9e584023009e42d31befdba9068e90f6c /clang
parent539ec3ae90e2515ed82c418c20c92b87f64a2484 (diff)
downloadbcm5719-llvm-a7203e537df20b554f7aa678c7de546bc23b87d7.tar.gz
bcm5719-llvm-a7203e537df20b554f7aa678c7de546bc23b87d7.zip
When determining whether we need to instantiate a function type,
also consider whether any of the parameter types (as written, prior to decay) are dependent. Fixes PR9880 and <rdar://problem/9408413>. llvm-svn: 131099
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiate.cpp6
-rw-r--r--clang/test/SemaTemplate/instantiate-function-1.cpp22
2 files changed, 28 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 03c2befbc56..564f099ad9f 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1388,6 +1388,12 @@ static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T) {
for (unsigned I = 0, E = FP.getNumArgs(); I != E; ++I) {
ParmVarDecl *P = FP.getArg(I);
+ // The parameter's type as written might be dependent even if the
+ // decayed type was not dependent.
+ if (TypeSourceInfo *TSInfo = P->getTypeSourceInfo())
+ if (TSInfo->getType()->isDependentType())
+ return true;
+
// TODO: currently we always rebuild expressions. When we
// properly get lazier about this, we should use the same
// logic to avoid rebuilding prototypes here.
diff --git a/clang/test/SemaTemplate/instantiate-function-1.cpp b/clang/test/SemaTemplate/instantiate-function-1.cpp
index 688d0095267..5406fbcd1ba 100644
--- a/clang/test/SemaTemplate/instantiate-function-1.cpp
+++ b/clang/test/SemaTemplate/instantiate-function-1.cpp
@@ -225,3 +225,25 @@ namespace PR7016 {
template<typename T> void f() { T x = x; }
template void f<int>();
}
+
+namespace PR9880 {
+ struct lua_State;
+ struct no_tag { char a; }; // (A)
+ struct yes_tag { long a; long b; }; // (A)
+
+ template <typename T>
+ struct HasIndexMetamethod {
+ template <typename U>
+ static no_tag check(...);
+ template <typename U>
+ static yes_tag check(char[sizeof(&U::luaIndex)]);
+ enum { value = sizeof(check<T>(0)) == sizeof(yes_tag) };
+ };
+
+ class SomeClass {
+ public:
+ int luaIndex(lua_State* L);
+ };
+
+ int i = HasIndexMetamethod<SomeClass>::value;
+}
OpenPOWER on IntegriCloud