def note_uninit_reference_member : Note<
"uninitialized reference member is here">;
+// C++0x decltype
+def err_cannot_determine_declared_type_of_overloaded_function : Error<
+ "can't determine the declared type of an overloaded function">;
+
// C++0x auto
def err_auto_variable_cannot_appear_in_own_initializer : Error<
"variable %0 declared with 'auto' type cannot appear in its own initializer">;
QualType getQualifiedNameType(const CXXScopeSpec &SS, QualType T);
+ QualType BuildTypeofExprType(Expr *E);
+ QualType BuildDecltypeType(Expr *E);
+
//===--------------------------------------------------------------------===//
// Symbol table / Decl tracking callbacks: SemaDecl.cpp.
//
if (E.isInvalid())
return QualType();
- return SemaRef.Context.getTypeOfExprType(E.takeAs<Expr>());
+ return SemaRef.BuildTypeofExprType(E.takeAs<Expr>());
}
QualType
if (E.isInvalid())
return QualType();
- return SemaRef.Context.getDecltypeType(E.takeAs<Expr>());
+ return SemaRef.BuildDecltypeType(E.takeAs<Expr>());
}
QualType
Expr *E = static_cast<Expr *>(DS.getTypeRep());
assert(E && "Didn't get an expression for decltype?");
// TypeQuals handled by caller.
- Result = Context.getDecltypeType(E);
+ Result = BuildDecltypeType(E);
+ if (Result.isNull()) {
+ Result = Context.IntTy;
+ isInvalid = true;
+ }
break;
}
case DeclSpec::TST_auto: {
= static_cast<NestedNameSpecifier *>(SS.getScopeRep());
return Context.getQualifiedNameType(NNS, T);
}
+
+QualType Sema::BuildTypeofExprType(Expr *E) {
+ return Context.getTypeOfExprType(E);
+}
+
+QualType Sema::BuildDecltypeType(Expr *E) {
+ if (E->getType() == Context.OverloadTy) {
+ Diag(E->getLocStart(),
+ diag::err_cannot_determine_declared_type_of_overloaded_function);
+ return QualType();
+ }
+ return Context.getDecltypeType(E);
+}
--- /dev/null
+// RUN: clang-cc -fsyntax-only -verify %s -std=c++0x
+
+void f();
+void f(int);
+decltype(f) a; // expected-error{{can't determine the declared type of an overloaded function}}
+
+template<typename T> struct S {
+ decltype(T::f) * f; // expected-error{{can't determine the declared type of an overloaded function}}
+};
+
+struct K { void f(); void f(int); };
+S<K> b; // expected-note{{in instantiation of template class 'struct S<struct K>' requested here}}