r363360 - [clang] Don't segfault on incorrect using directive (PR41400)

Gauthier Harnisch via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 14 01:25:53 PDT 2019


Author: tyker
Date: Fri Jun 14 01:25:52 2019
New Revision: 363360

URL: http://llvm.org/viewvc/llvm-project?rev=363360&view=rev
Log:
[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

Modified:
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/test/SemaCXX/using-decl-1.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=363360&r1=363359&r2=363360&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Jun 14 01:25:52 2019
@@ -90,7 +90,7 @@ ParsedType Sema::getConstructorName(Iden
   // 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);
   }

Modified: cfe/trunk/test/SemaCXX/using-decl-1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/using-decl-1.cpp?rev=363360&r1=363359&r2=363360&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/using-decl-1.cpp (original)
+++ cfe/trunk/test/SemaCXX/using-decl-1.cpp Fri Jun 14 01:25:52 2019
@@ -396,3 +396,10 @@ namespace tag_vs_var {
   using N::Y;
   using N::Z;
 }
+
+// expected-error at +5 {{requires a qualified name}}
+// expected-error at +4 {{expected ';'}}
+// expected-error at +3 {{expected '}'}}
+// expected-note at +2 {{to match this '{'}}
+// expected-error at +1 {{expected ';'}}
+template<class> struct S { using S
\ No newline at end of file




More information about the cfe-commits mailing list