[cfe-commits] r164967 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/decltype-overloaded-functions.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Mon Oct 1 13:35:07 PDT 2012
Author: rsmith
Date: Mon Oct 1 15:35:07 2012
New Revision: 164967
URL: http://llvm.org/viewvc/llvm-project?rev=164967&view=rev
Log:
PR13978: A 'decltype' DeclSpec has an expression representation, not a type
representation. Fix crash if it appears in the return type of a member function
definition.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/decltype-overloaded-functions.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=164967&r1=164966&r2=164967&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Oct 1 15:35:07 2012
@@ -3400,7 +3400,6 @@
switch (DS.getTypeSpecType()) {
case DeclSpec::TST_typename:
case DeclSpec::TST_typeofType:
- case DeclSpec::TST_decltype:
case DeclSpec::TST_underlyingType:
case DeclSpec::TST_atomic: {
// Grab the type from the parser.
@@ -3424,6 +3423,7 @@
break;
}
+ case DeclSpec::TST_decltype:
case DeclSpec::TST_typeofExpr: {
Expr *E = DS.getRepAsExpr();
ExprResult Result = S.RebuildExprInCurrentInstantiation(E);
Modified: cfe/trunk/test/SemaCXX/decltype-overloaded-functions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/decltype-overloaded-functions.cpp?rev=164967&r1=164966&r2=164967&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/decltype-overloaded-functions.cpp (original)
+++ cfe/trunk/test/SemaCXX/decltype-overloaded-functions.cpp Mon Oct 1 15:35:07 2012
@@ -13,3 +13,18 @@
void f(int); // expected-note{{possible target for call}}
};
S<K> b; // expected-note{{in instantiation of template class 'S<K>' requested here}}
+
+namespace PR13978 {
+ template<typename T> struct S { decltype(1) f(); };
+ template<typename T> decltype(1) S<T>::f() { return 1; }
+
+ // This case is ill-formed (no diagnostic required) because the decltype
+ // expressions are functionally equivalent but not equivalent. It would
+ // be acceptable for us to reject this case.
+ template<typename T> struct U { struct A {}; decltype(A{}) f(); };
+ template<typename T> decltype(typename U<T>::A{}) U<T>::f() {}
+
+ // This case is valid.
+ template<typename T> struct V { struct A {}; decltype(typename V<T>::A{}) f(); };
+ template<typename T> decltype(typename V<T>::A{}) V<T>::f() {}
+}
More information about the cfe-commits
mailing list