[PATCH] D134578: Add missing `struct` keyword to the test p2-2.cpp

Alan Zhao via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 23 17:44:08 PDT 2022


ayzhao created this revision.
Herald added a project: All.
ayzhao requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

While working on D53847 <https://reviews.llvm.org/D53847>, I noticed that this test would fail once we
started recognizing the types in the modified `export` statement [0].
The tests would fail because Clang would emit a "declaration does not
declare anything" diagnostic instead of the expected namespace scope
diagnostic.

I believe that the test is currently incorrectly passing because Clang
doesn't parse the type and therefore doesn't treat the statement as a
declaration. My understanding is that the intention of this test case is
that it wants to export a `struct` type, which I believe requires a
`struct` keyword, even for types with template parameters. With this
change, the only error with these two statements should be the
namespace scope issue.

[0]: https://reviews.llvm.org/D53847?id=462032#inline-1297053


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134578

Files:
  clang/test/CXX/module/module.interface/p2-2.cpp


Index: clang/test/CXX/module/module.interface/p2-2.cpp
===================================================================
--- clang/test/CXX/module/module.interface/p2-2.cpp
+++ clang/test/CXX/module/module.interface/p2-2.cpp
@@ -14,7 +14,7 @@
   U bar();
 };
 
-export template <typename T> X<T>::iterator;                      // expected-error {{cannot export 'iterator' as it is not at namespace scope}}
+export template <typename T> struct X<T>::iterator;               // expected-error {{cannot export 'iterator' as it is not at namespace scope}}
 export template <typename T> void X<T>::foo();                    // expected-error {{cannot export 'foo' as it is not at namespace scope}}
 export template <typename T> template <typename U> U X<T>::bar(); // expected-error {{cannot export 'bar' as it is not at namespace scope}}
 
@@ -32,6 +32,6 @@
 export template <typename U> U Y::bar(); // expected-error {{cannot export 'bar' as it is not at namespace scope}}
 
 export {
-  template <typename T> X<T>::iterator; // expected-error {{cannot export 'iterator' as it is not at namespace scope}}
-  struct Y::iterator;                   // expected-error {{cannot export 'iterator' as it is not at namespace scope}}
+  template <typename T> struct X<T>::iterator; // expected-error {{cannot export 'iterator' as it is not at namespace scope}}
+  struct Y::iterator;                          // expected-error {{cannot export 'iterator' as it is not at namespace scope}}
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134578.462631.patch
Type: text/x-patch
Size: 1482 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220924/4c1143fd/attachment.bin>


More information about the cfe-commits mailing list