================
@@ -0,0 +1,89 @@
+// RUN: %check_clang_tidy %s readability-redundant-tag %t -- -- -std=c++20
+
+struct Struct {};
+class Class {};
+union Union {};
+enum Enum {};
+
+void basic() {
+  struct Struct s;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: redundant 'struct' keyword in 
C++ declaration
+  // CHECK-FIXES: Struct s;
+
+  class Class c;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: redundant 'class' keyword in C++ 
declaration
+  // CHECK-FIXES: Class c;
+
+  union Union u;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: redundant 'union' keyword in C++ 
declaration
+  // CHECK-FIXES: Union u;
+
+  enum Enum e;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: redundant 'enum' keyword in C++ 
declaration
+  // CHECK-FIXES: Enum e;
+}
+
+// Hidden by variable (GitHub issue)
+struct Hidden {} Hidden;
+
+void hiddenByVariable() {
+  struct Hidden h;
+}
+
+// Forward declaration
+struct Forward;
+
+void forwardDecl() {
+  struct Forward *p;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: redundant 'struct' keyword in 
C++ declaration
+  // CHECK-FIXES: Forward *p;
+}
+
+// Namespace-qualified type
+namespace N {
+struct NS {};
+}
+
+void namespaceQualified() {
+  struct N::NS x;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: redundant 'struct' keyword in 
C++ declaration
+  // CHECK-FIXES: N::NS x;
+}
+
+// Nested type
+struct Outer {
+  struct Inner {};
+};
+
+void nestedType() {
+  struct Outer::Inner x;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: redundant 'struct' keyword in 
C++ declaration
+  // CHECK-FIXES: Outer::Inner x;
+}
+
+// Hidden by function
+struct FuncTag {};
+
+void FuncTag();
+
+void hiddenByFunction() {
+  struct FuncTag x;
+}
+
+// Hidden by enum constant
+struct EnumTag {};
+
+enum { EnumTag };
+
+void hiddenByEnumConstant() {
+  struct EnumTag x;
+}
+
+// Hidden by another variable
+struct A {};
+
+A A;
+
+void anotherHiddenVariable() {
+  struct A x;
+}
----------------
EugeneZelenko wrote:

Please add newline.

https://github.com/llvm/llvm-project/pull/210007
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to