From 4fb20533baff585c27531fe90c9bf7b004e07bb7 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Fri, 14 May 2010 21:35:02 +0000 Subject: [PATCH] Patch to fix a crash on incomplete class declaration. Radar 7923673. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103812 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDecl.cpp | 10 +++++++--- test/Parser/cxx-undeclared-identifier.cpp | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 test/Parser/cxx-undeclared-identifier.cpp diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 76334e9a12..5bb0b524d1 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -5329,9 +5329,13 @@ CreateNewDecl: // Maybe add qualifier info. if (SS.isNotEmpty()) { - NestedNameSpecifier *NNS - = static_cast(SS.getScopeRep()); - New->setQualifierInfo(NNS, SS.getRange()); + if (SS.isSet()) { + NestedNameSpecifier *NNS + = static_cast(SS.getScopeRep()); + New->setQualifierInfo(NNS, SS.getRange()); + } + else + Invalid = true; } if (Kind != TTK_Enum) { diff --git a/test/Parser/cxx-undeclared-identifier.cpp b/test/Parser/cxx-undeclared-identifier.cpp new file mode 100644 index 0000000000..36d8f7a653 --- /dev/null +++ b/test/Parser/cxx-undeclared-identifier.cpp @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s + +class Foo::Bar { // expected-error {{use of undeclared identifier 'Foo'}} \ + // expected-note {{to match this '{'}} \ + // expected-error {{expected ';' after class}} + // expected-error {{expected '}'}} -- 2.40.0