File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed
test/Interop/Cxx/templates Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,10 @@ class ClangDeclFinder
112112 return true ;
113113 }
114114
115+ // Do not traverse type locs, as they might contain expressions that reference
116+ // code that should not be instantiated and/or emitted.
117+ bool TraverseTypeLoc (clang::TypeLoc TL) { return true ; }
118+
115119 bool shouldVisitTemplateInstantiations () const { return true ; }
116120 bool shouldVisitImplicitCode () const { return true ; }
117121};
Original file line number Diff line number Diff line change @@ -35,4 +35,27 @@ inline void initVector() {
3535 vv.push_back (0 );
3636}
3737
38+ template <class T >
39+ class UseDeclVal {
40+ public:
41+ UseDeclVal () {}
42+
43+ auto declTypeRet () const noexcept -> decltype(declval<T>().method()) {
44+ return T ().method ();
45+ }
46+
47+ inline int callMethod () const {
48+ int x = declTypeRet ();
49+ return x;
50+ }
51+ };
52+
53+ struct StructWithMethod {
54+ inline int method () {
55+ return 42 ;
56+ }
57+ };
58+
59+ using UseDeclValStruct = UseDeclVal<StructWithMethod>;
60+
3861#endif // TEST_INTEROP_CXX_TEMPLATES_INPUTS_UNEVALUATED_CONTEXT_H
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ var UnevaluatedTestSuite = TestSuite("UnevaluatedContext")
99
1010UnevaluatedTestSuite . test ( " declval " ) {
1111 initVector ( )
12+ let _ = UseDeclValStruct ( ) . callMethod ( )
1213}
1314
1415runAllTests ( )
You can’t perform that action at this time.
0 commit comments