bool HasTrailingLParen);
ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS,
- const DeclarationNameInfo &NameInfo);
+ const DeclarationNameInfo &NameInfo,
+ bool IsAddressOfOperand);
ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS,
SourceLocation TemplateKWLoc,
const DeclarationNameInfo &NameInfo,
/// this path.
ExprResult
Sema::BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS,
- const DeclarationNameInfo &NameInfo) {
+ const DeclarationNameInfo &NameInfo,
+ bool IsAddressOfOperand) {
DeclContext *DC;
if (!(DC = computeDeclContext(SS, false)) || DC->isDependentContext())
return BuildDependentDeclRefExpr(SS, /*TemplateKWLoc=*/SourceLocation(),
return ExprError();
}
- return BuildDeclarationNameExpr(SS, R, /*ADL*/ false);
+ // Defend against this resolving to an implicit member access. We usually
+ // won't get here if this might be a legitimate a class member (we end up in
+ // BuildMemberReferenceExpr instead), but this can be valid if we're forming
+ // a pointer-to-member or in an unevaluated context in C++11.
+ if (!R.empty() && (*R.begin())->isCXXClassMember() && !IsAddressOfOperand)
+ return BuildPossibleImplicitMemberExpr(SS,
+ /*TemplateKWLoc=*/SourceLocation(),
+ R, /*TemplateArgs=*/0);
+
+ return BuildDeclarationNameExpr(SS, R, /* ADL */ false);
}
/// LookupInObjCMethod - The parser has read a name in, and Sema has
/// \brief Transform the captures and body of a lambda expression.
ExprResult TransformLambdaScope(LambdaExpr *E, CXXMethodDecl *CallOperator);
+ ExprResult TransformDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E,
+ bool IsAddressOfOperand);
+
#define STMT(Node, Parent) \
StmtResult Transform##Node(Node *S);
#define EXPR(Node, Parent) \
NestedNameSpecifierLoc QualifierLoc,
SourceLocation TemplateKWLoc,
const DeclarationNameInfo &NameInfo,
- const TemplateArgumentListInfo *TemplateArgs) {
+ const TemplateArgumentListInfo *TemplateArgs,
+ bool IsAddressOfOperand) {
CXXScopeSpec SS;
SS.Adopt(QualifierLoc);
return getSema().BuildQualifiedTemplateIdExpr(SS, TemplateKWLoc,
NameInfo, TemplateArgs);
- return getSema().BuildQualifiedDeclarationNameExpr(SS, NameInfo);
+ return getSema().BuildQualifiedDeclarationNameExpr(SS, NameInfo,
+ IsAddressOfOperand);
}
/// \brief Build a new template-id expression.
template<typename Derived>
ExprResult
TreeTransform<Derived>::TransformUnaryOperator(UnaryOperator *E) {
- ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
+ ExprResult SubExpr;
+
+ if (DependentScopeDeclRefExpr *DRE =
+ dyn_cast<DependentScopeDeclRefExpr>(E->getSubExpr()))
+ SubExpr = getDerived().TransformDependentScopeDeclRefExpr(DRE, true);
+ else
+ SubExpr = getDerived().TransformExpr(E->getSubExpr());
if (SubExpr.isInvalid())
return ExprError();
ExprResult
TreeTransform<Derived>::TransformDependentScopeDeclRefExpr(
DependentScopeDeclRefExpr *E) {
+ return TransformDependentScopeDeclRefExpr(E, /*IsAddressOfOperand*/false);
+}
+
+template<typename Derived>
+ExprResult
+TreeTransform<Derived>::TransformDependentScopeDeclRefExpr(
+ DependentScopeDeclRefExpr *E,
+ bool IsAddressOfOperand) {
NestedNameSpecifierLoc QualifierLoc
= getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
if (!QualifierLoc)
return getDerived().RebuildDependentScopeDeclRefExpr(QualifierLoc,
TemplateKWLoc,
NameInfo,
- /*TemplateArgs*/ 0);
+ /*TemplateArgs*/ 0,
+ IsAddressOfOperand);
}
TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
return getDerived().RebuildDependentScopeDeclRefExpr(QualifierLoc,
TemplateKWLoc,
NameInfo,
- &TransArgs);
+ &TransArgs,
+ IsAddressOfOperand);
}
template<typename Derived>
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
-void f(); // expected-note{{possible target for call}}
-void f(int); // expected-note{{possible target for call}}
+void f(); // expected-note{{possible target for call}}
+void f(int); // expected-note{{possible target for call}}
decltype(f) a; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} expected-error {{variable has incomplete type 'decltype(f())' (aka 'void')}}
template<typename T> struct S {
- decltype(T::f) * f; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} expected-error {{call to non-static member function without an object argument}}
+ decltype(T::f) * f; // expected-error {{call to non-static member function without an object argument}}
};
struct K {
- void f(); // expected-note{{possible target for call}}
- void f(int); // expected-note{{possible target for call}}
+ void f();
+ void f(int);
};
S<K> b; // expected-note{{in instantiation of template class 'S<K>' requested here}}
namespace rdar9027658 {
template <typename T>
-void f() {
- if ((T::g == 3)) { } // expected-warning {{equality comparison with extraneous parentheses}} \
+void f(T t) {
+ if ((t.g == 3)) { } // expected-warning {{equality comparison with extraneous parentheses}} \
// expected-note {{use '=' to turn this equality comparison into an assignment}} \
// expected-note {{remove extraneous parentheses around the comparison to silence this warning}}
}
struct S { int g; };
void test() {
- f<S>(); // expected-note {{in instantiation}}
+ f(S()); // expected-note {{in instantiation}}
}
}
template class B<int>;
}
+
+namespace PR14124 {
+ template<typename T> struct S {
+ int value;
+ };
+ template<typename T> void f() { S<T>::value; } // expected-error {{invalid use of non-static data member 'value'}}
+ template void f<int>(); // expected-note {{in instantiation of}}
+}