llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Serosh (Serosh-commits) <details> <summary>Changes</summary> fix by guarding `CppNamespaceLookup` with an `isFileContext()` check instead of asserting fixes #<!-- -->189344 --- Full diff: https://github.com/llvm/llvm-project/pull/190484.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+1) - (modified) clang/lib/Sema/SemaLookup.cpp (+1-4) - (added) clang/test/SemaCXX/gh189344.cpp (+7) ``````````diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 899a4ee0dee0e..a7cda9b03715a 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -549,6 +549,7 @@ Bug Fixes to Attribute Support Bug Fixes to C++ Support ^^^^^^^^^^^^^^^^^^^^^^^^ +- Fixed a name lookup crash when parsing invalid template parameters. (#GH189344) - Diagnose binding a reference to ``*nullptr`` during constant evaluation. (#GH48665) - Suppress ``-Wdeprecated-declarations`` in implicitly generated functions. (#GH147293) - Fix a crash when deleting a pointer to an incomplete array (#GH150359). diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index b9fac5a4a1153..a5c33d0738e2d 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -1528,10 +1528,7 @@ bool Sema::CppLookupName(LookupResult &R, Scope *S) { // If we have a context, and it's not a context stashed in the // template parameter scope for an out-of-line definition, also // look into that context. - if (!(Found && S->isTemplateParamScope())) { - assert(Ctx->isFileContext() && - "We should have been looking only at file context here already."); - + if (Ctx->isFileContext() && !(Found && S->isTemplateParamScope())) { // Look into context considering using-directives. if (CppNamespaceLookup(*this, R, Context, Ctx, UDirs)) Found = true; diff --git a/clang/test/SemaCXX/gh189344.cpp b/clang/test/SemaCXX/gh189344.cpp new file mode 100644 index 0000000000000..19d1244fbc15d --- /dev/null +++ b/clang/test/SemaCXX/gh189344.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +template <union { } alignas ( union a { c ) ( a :: ) ( :: (b +// expected-error@-1 {{cannot be defined in a type specifier}} +// expected-error@-1 {{'a' cannot be defined in a type specifier}} +// expected-error@-1 {{expected unqualified-id}} +// expected-error@-1 {{expected unqualified-id}} `````````` </details> https://github.com/llvm/llvm-project/pull/190484 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
