aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Parse/ParseCXXInlineMethods.cpp2
-rw-r--r--lib/Sema/SemaDeclCXX.cpp16
-rw-r--r--test/SemaTemplate/constructor-template.cpp4
3 files changed, 21 insertions, 1 deletions
diff --git a/lib/Parse/ParseCXXInlineMethods.cpp b/lib/Parse/ParseCXXInlineMethods.cpp
index f967c7a69d..bfdbde6ddf 100644
--- a/lib/Parse/ParseCXXInlineMethods.cpp
+++ b/lib/Parse/ParseCXXInlineMethods.cpp
@@ -174,7 +174,7 @@ void Parser::ParseLexedMethodDefs(ParsingClass &Class) {
// Append the current token at the end of the new token stream so that it
// doesn't get lost.
LM.Toks.push_back(Tok);
- PP.EnterTokenStream(&LM.Toks.front(), LM.Toks.size(), true, false);
+ PP.EnterTokenStream(LM.Toks.data(), LM.Toks.size(), true, false);
// Consume the previously pushed token.
ConsumeAnyToken();
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 79dc24e596..462999b0a5 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -703,6 +703,8 @@ Sema::ActOnMemInitializer(DeclPtrTy ConstructorD,
if (!ConstructorD)
return true;
+ AdjustDeclIfTemplate(ConstructorD);
+
CXXConstructorDecl *Constructor
= dyn_cast<CXXConstructorDecl>(ConstructorD.getAs<Decl>());
if (!Constructor) {
@@ -922,6 +924,8 @@ void Sema::ActOnMemInitializers(DeclPtrTy ConstructorDecl,
MemInitTy **MemInits, unsigned NumMemInits) {
if (!ConstructorDecl)
return;
+
+ AdjustDeclIfTemplate(ConstructorDecl);
CXXConstructorDecl *Constructor
= dyn_cast<CXXConstructorDecl>(ConstructorDecl.getAs<Decl>());
@@ -1041,6 +1045,8 @@ void Sema::ActOnDefaultCtorInitializers(DeclPtrTy CDtorDecl) {
if (!CDtorDecl)
return;
+ AdjustDeclIfTemplate(CDtorDecl);
+
if (CXXConstructorDecl *Constructor
= dyn_cast<CXXConstructorDecl>(CDtorDecl.getAs<Decl>()))
BuildBaseOrMemberInitializers(Context,
@@ -1529,6 +1535,8 @@ void Sema::ActOnStartDelayedCXXMethodDeclaration(Scope *S, DeclPtrTy MethodD) {
if (!MethodD)
return;
+ AdjustDeclIfTemplate(MethodD);
+
CXXScopeSpec SS;
FunctionDecl *Method = cast<FunctionDecl>(MethodD.getAs<Decl>());
QualType ClassTy
@@ -1569,6 +1577,8 @@ void Sema::ActOnFinishDelayedCXXMethodDeclaration(Scope *S, DeclPtrTy MethodD) {
if (!MethodD)
return;
+ AdjustDeclIfTemplate(MethodD);
+
FunctionDecl *Method = cast<FunctionDecl>(MethodD.getAs<Decl>());
CXXScopeSpec SS;
QualType ClassTy
@@ -3648,6 +3658,8 @@ Sema::DeclPtrTy Sema::ActOnFriendDecl(Scope *S,
}
void Sema::SetDeclDeleted(DeclPtrTy dcl, SourceLocation DelLoc) {
+ AdjustDeclIfTemplate(dcl);
+
Decl *Dcl = dcl.getAs<Decl>();
FunctionDecl *Fn = dyn_cast<FunctionDecl>(Dcl);
if (!Fn) {
@@ -3782,6 +3794,8 @@ bool Sema::CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New,
/// static data member of class X, names should be looked up in the scope of
/// class X.
void Sema::ActOnCXXEnterDeclInitializer(Scope *S, DeclPtrTy Dcl) {
+ AdjustDeclIfTemplate(Dcl);
+
Decl *D = Dcl.getAs<Decl>();
// If there is no declaration, there was an error parsing it.
if (D == 0)
@@ -3805,6 +3819,8 @@ void Sema::ActOnCXXEnterDeclInitializer(Scope *S, DeclPtrTy Dcl) {
/// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
/// initializer for the declaration 'Dcl'.
void Sema::ActOnCXXExitDeclInitializer(Scope *S, DeclPtrTy Dcl) {
+ AdjustDeclIfTemplate(Dcl);
+
Decl *D = Dcl.getAs<Decl>();
// If there is no declaration, there was an error parsing it.
if (D == 0)
diff --git a/test/SemaTemplate/constructor-template.cpp b/test/SemaTemplate/constructor-template.cpp
index 14df2e2632..5a2630c2cf 100644
--- a/test/SemaTemplate/constructor-template.cpp
+++ b/test/SemaTemplate/constructor-template.cpp
@@ -4,6 +4,10 @@ struct X0 { // expected-note{{candidate}}
X0(int); // expected-note{{candidate}}
template<typename T> X0(T);
template<typename T, typename U> X0(T*, U*);
+
+ // PR4761
+ template<typename T> X0() : f0(T::foo) {}
+ int f0;
};
void accept_X0(X0);