From: Gauthier Harnisch Date: Fri, 14 Jun 2019 08:25:52 +0000 (+0000) Subject: [clang] Don't segfault on incorrect using directive (PR41400) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=20e4ccc974ae571714d649105c34fa03b3a1156f;p=clang [clang] Don't segfault on incorrect using directive (PR41400) Summary: this is a bugfixe for [[ https://bugs.llvm.org/show_bug.cgi?id=41400 | PR41400 ]] added nullptr check at the relevent place and test Reviewers: rsmith, riccibruno Reviewed By: rsmith Subscribers: jkooker, jkorous, riccibruno, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60523 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@363360 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 2e5d1c7c38..b59f3faa6e 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -90,7 +90,7 @@ ParsedType Sema::getConstructorName(IdentifierInfo &II, // When naming a constructor as a member of a dependent context (eg, in a // friend declaration or an inherited constructor declaration), form an // unresolved "typename" type. - if (CurClass->isDependentContext() && !EnteringContext) { + if (CurClass->isDependentContext() && !EnteringContext && SS.getScopeRep()) { QualType T = Context.getDependentNameType(ETK_None, SS.getScopeRep(), &II); return ParsedType::make(T); } diff --git a/test/SemaCXX/using-decl-1.cpp b/test/SemaCXX/using-decl-1.cpp index 93f38f28e7..b4477e2c62 100644 --- a/test/SemaCXX/using-decl-1.cpp +++ b/test/SemaCXX/using-decl-1.cpp @@ -396,3 +396,10 @@ namespace tag_vs_var { using N::Y; using N::Z; } + +// expected-error@+5 {{requires a qualified name}} +// expected-error@+4 {{expected ';'}} +// expected-error@+3 {{expected '}'}} +// expected-note@+2 {{to match this '{'}} +// expected-error@+1 {{expected ';'}} +template struct S { using S \ No newline at end of file