[cfe-commits] r127150 - in /cfe/trunk: lib/Sema/TreeTransform.h test/SemaTemplate/instantiate-member-template.cpp
Douglas Gregor
dgregor at apple.com
Sun Mar 6 18:33:33 PST 2011
Author: dgregor
Date: Sun Mar 6 20:33:33 2011
New Revision: 127150
URL: http://llvm.org/viewvc/llvm-project?rev=127150&view=rev
Log:
When transforming a dependent template specialization type, make sure
to set the source-location information for the template arguments to
the *transformed* source-location information, not the original
source-location information. Fixes <rdar://problem/8986308> (a libc++
SFINAE issue) and the Boost.Polygon failure.
Modified:
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/SemaTemplate/instantiate-member-template.cpp
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=127150&r1=127149&r2=127150&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Sun Mar 6 20:33:33 2011
@@ -4513,19 +4513,32 @@
// Copy information relevant to the template specialization.
TemplateSpecializationTypeLoc NamedTL
- = TLB.push<TemplateSpecializationTypeLoc>(NamedT);
+ = TLB.push<TemplateSpecializationTypeLoc>(NamedT);
NamedTL.setLAngleLoc(TL.getLAngleLoc());
NamedTL.setRAngleLoc(TL.getRAngleLoc());
- for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I)
- NamedTL.setArgLocInfo(I, TL.getArgLocInfo(I));
+ for (unsigned I = 0, E = NamedTL.getNumArgs(); I != E; ++I)
+ NamedTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
// Copy information relevant to the elaborated type.
ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
NewTL.setKeywordLoc(TL.getKeywordLoc());
NewTL.setQualifierLoc(QualifierLoc);
+ } else if (isa<DependentTemplateSpecializationType>(Result)) {
+ DependentTemplateSpecializationTypeLoc SpecTL
+ = TLB.push<DependentTemplateSpecializationTypeLoc>(Result);
+ SpecTL.setQualifierLoc(QualifierLoc);
+ SpecTL.setLAngleLoc(TL.getLAngleLoc());
+ SpecTL.setRAngleLoc(TL.getRAngleLoc());
+ SpecTL.setNameLoc(TL.getNameLoc());
+ for (unsigned I = 0, E = SpecTL.getNumArgs(); I != E; ++I)
+ SpecTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
} else {
- TypeLoc NewTL(Result, TL.getOpaqueData());
- TLB.pushFullCopy(NewTL);
+ TemplateSpecializationTypeLoc SpecTL
+ = TLB.push<TemplateSpecializationTypeLoc>(Result);
+ SpecTL.setLAngleLoc(TL.getLAngleLoc());
+ SpecTL.setRAngleLoc(TL.getRAngleLoc());
+ for (unsigned I = 0, E = SpecTL.getNumArgs(); I != E; ++I)
+ SpecTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
}
return Result;
}
Modified: cfe/trunk/test/SemaTemplate/instantiate-member-template.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-member-template.cpp?rev=127150&r1=127149&r2=127150&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-member-template.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-member-template.cpp Sun Mar 6 20:33:33 2011
@@ -215,3 +215,47 @@
c.F(); // expected-error{{no matching member function}}
}
}
+
+namespace rdar8986308 {
+ template <bool> struct __static_assert_test;
+ template <> struct __static_assert_test<true> {};
+ template <unsigned> struct __static_assert_check {};
+
+ namespace std {
+
+ template <class _Tp, class _Up>
+ struct __has_rebind
+ {
+ private:
+ struct __two {char _; char __;};
+ template <class _Xp> static __two __test(...);
+ template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0);
+ public:
+ static const bool value = sizeof(__test<_Tp>(0)) == 1;
+ };
+
+ }
+
+ template <class T> struct B1 {};
+
+ template <class T>
+ struct B
+ {
+ template <class U> struct rebind {typedef B1<U> other;};
+ };
+
+ template <class T, class U> struct D1 {};
+
+ template <class T, class U>
+ struct D
+ {
+ template <class V> struct rebind {typedef D1<V, U> other;};
+ };
+
+ int main()
+ {
+ typedef __static_assert_check<sizeof(__static_assert_test<((std::__has_rebind<B<int>, double>::value))>)> __t64;
+ typedef __static_assert_check<sizeof(__static_assert_test<((std::__has_rebind<D<char, int>, double>::value))>)> __t64;
+ }
+
+}
More information about the cfe-commits
mailing list