ayzhao added inline comments.
================ Comment at: clang/lib/Sema/SemaDecl.cpp:362 + // allow this as an extension. + if (AllowImplicitTypename == ImplicitTypenameContext::No && + !isClassName && !IsCtorOrDtorName) ---------------- ayzhao wrote: > Status update: > > This line is currently causing > [p2-2.cpp](https://github.com/llvm/llvm-project/blob/main/clang/test/CXX/module/module.interface/p2-2.cpp) > to fail with the following error: > > ``` > FAIL: Clang :: CXX/module/module.interface/p2-2.cpp (2 of 17555) > ******************** TEST 'Clang :: CXX/module/module.interface/p2-2.cpp' > FAILED ******************** > Script: > -- > : 'RUN: at line 3'; /dev/shm/ayzhao_llvm/llvm-project/build/bin/clang -cc1 > -internal-isystem > /dev/shm/ayzhao_llvm/llvm-project/build/lib/clang/16.0.0/include > -nostdsysteminc -std=c++20 > /dev/shm/ayzhao_llvm/llvm-project/clang/test/CXX/module/module.interface/p2-2.cpp > -verify > -- > Exit Code: 1 > > Command Output (stderr): > -- > error: 'error' diagnostics expected but not seen: > File > /dev/shm/ayzhao_llvm/llvm-project/clang/test/CXX/module/module.interface/p2-2.cpp > Line 17: cannot export 'iterator' as it is not at namespace scope > File > /dev/shm/ayzhao_llvm/llvm-project/clang/test/CXX/module/module.interface/p2-2.cpp > Line 35: cannot export 'iterator' as it is not at namespace scope > error: 'error' diagnostics seen but not expected: > File > /dev/shm/ayzhao_llvm/llvm-project/clang/test/CXX/module/module.interface/p2-2.cpp > Line 17: declaration does not declare anything > File > /dev/shm/ayzhao_llvm/llvm-project/clang/test/CXX/module/module.interface/p2-2.cpp > Line 35: declaration does not declare anything > 4 errors generated. > > -- > > ******************** > ``` > > A reduced repro is here: > > ``` > export module X; > > export template <typename T> > struct X { > struct iterator { > T node; > }; > }; > > export template <typename T> X<T>::iterator; > ``` > > `Sema::getTypeName(...)` is called from [these > lines](https://github.com/llvm/llvm-project/blob/ace05124f5494173ae4769259d49f33d75d6f76b/clang/lib/Parse/ParseDecl.cpp#L3391-L3396), > with the result being that `TypeRep` is null in main but not null in this > patch. > > I'm still in the process of trying to figure out how to resolve this, but any > suggestions/insights would be **very** welcome. I fixed this with the following diff: ``` diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 1375431d8998..dacba4d18021 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -362,6 +362,11 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, if (AllowImplicitTypename == ImplicitTypenameContext::No && !isClassName && !IsCtorOrDtorName) return nullptr; + // FIXME: This hack is required in order to make the test + // CXX/module/module.interface/p2-2.cpp pass. Can we get this working + // with this method returning a non-null ParsedType? + if (isa<ExportDecl>(CurContext)) + return nullptr; bool IsImplicitTypename = !isClassName && !IsCtorOrDtorName; if (IsImplicitTypename) { SourceLocation QualifiedLoc = SS->getRange().getBegin(); ``` It's very hacky, but it works (for now) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D53847/new/ https://reviews.llvm.org/D53847 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits