From cd1293d5c455af9ea009b123cbf03c9a260c431d Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 26 Mar 2014 22:02:43 +0000 Subject: [PATCH] Objective-C. Improve diagnostic error for '@import' when modules are disabled. // rdar://15505492 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204862 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticParseKinds.td | 2 ++ lib/Parse/ParseObjc.cpp | 6 +++--- test/Parser/check-objc2-syntax-1.m | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td index 3f5cee1bfc..f33160c3ef 100644 --- a/include/clang/Basic/DiagnosticParseKinds.td +++ b/include/clang/Basic/DiagnosticParseKinds.td @@ -224,6 +224,8 @@ def err_expected_selector_for_method : Error< def err_expected_property_name : Error<"expected property name">; def err_unexpected_at : Error<"unexpected '@' in program">; +def err_atimport : Error< +"use of '@import' when modules are disabled, add -fmodules">; def err_invalid_reference_qualifier_application : Error< "'%0' qualifier may not be applied to a reference">; diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index 8697c08bb5..776dbd6eed 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -81,9 +81,9 @@ Parser::DeclGroupPtrTy Parser::ParseObjCAtDirectives() { case tok::objc_import: if (getLangOpts().Modules) return ParseModuleImport(AtLoc); - - // Fall through - + Diag(AtLoc, diag::err_atimport); + SkipUntil(tok::semi); + return Actions.ConvertDeclToDeclGroup(0); default: Diag(AtLoc, diag::err_unexpected_at); SkipUntil(tok::semi); diff --git a/test/Parser/check-objc2-syntax-1.m b/test/Parser/check-objc2-syntax-1.m index 9aff963774..6c30096cdd 100644 --- a/test/Parser/check-objc2-syntax-1.m +++ b/test/Parser/check-objc2-syntax-1.m @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics + +// rdar://15505492 +@import Foundation; // expected-error {{use of '@import' when modules are disabled, add -fmodules}} @interface Subclass + (int)magicNumber; -- 2.40.0