Skip to content

Commit 3e362cd

Browse files
committed
Add C++98 tests, guard variable template behind C++14
1 parent 7e100c3 commit 3e362cd

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %check_clang_tidy -std=c++98 %s readability-redundant-typename %t \
2+
// RUN: -- -- -fno-delayed-template-parsing
3+
4+
struct NotDependent {
5+
typedef int R;
6+
};
7+
8+
template <typename T>
9+
typename T::R f() {
10+
static_cast<typename T::R>(0);
11+
12+
typename NotDependent::R NotDependentVar;
13+
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: redundant 'typename' [readability-redundant-typename]
14+
// CHECK-FIXES: NotDependent::R NotDependentVar;
15+
16+
void notDependentFunctionDeclaration(typename NotDependent::R);
17+
// CHECK-MESSAGES: :[[@LINE-1]]:40: warning: redundant 'typename' [readability-redundant-typename]
18+
// CHECK-FIXES: void notDependentFunctionDeclaration(NotDependent::R);
19+
}

clang-tools-extra/test/clang-tidy/checkers/readability/redundant-typename.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,14 @@ struct PartiallySpecializedType {};
122122
template <typename T>
123123
struct PartiallySpecializedType<T, typename T::R> {};
124124

125+
#if __cplusplus >= 201402L
126+
125127
template <typename T>
126-
auto v = typename T::type();
128+
typename T::R v = typename T::R();
129+
// CHECK-MESSAGES-20: :[[@LINE-1]]:1: warning: redundant 'typename' [readability-redundant-typename]
130+
// CHECK-FIXES-20: T::R v = typename T::R();
131+
132+
#endif // __cplusplus >= 201402L
127133

128134
template <typename T>
129135
typename T::R f();

0 commit comments

Comments
 (0)