r292508 - Module: Improve diagnostic message when cxx modules are disabled and @import is used in Objective CXX.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 19 13:29:04 PST 2017


On 19 Jan 2017 11:16 am, "Manman Ren via cfe-commits" <
cfe-commits at lists.llvm.org> wrote:

Author: mren
Date: Thu Jan 19 13:05:55 2017
New Revision: 292508

URL: http://llvm.org/viewvc/llvm-project?rev=292508&view=rev
Log:
Module: Improve diagnostic message when cxx modules are disabled and
@import is used in Objective CXX.

rdar://problem/19399671

Added:
    cfe/trunk/test/Modules/check-syntax.mm
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
    cfe/trunk/lib/Parse/ParseObjc.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
DiagnosticParseKinds.td?rev=292508&r1=292507&r2=292508&view=diff
============================================================
==================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Thu Jan 19
13:05:55 2017
@@ -243,7 +243,10 @@ def err_expected_property_name : Error<"

 def err_unexpected_at : Error<"unexpected '@' in program">;
 def err_atimport : Error<
-"use of '@import' when modules are disabled">;
+  "use of '@import' when modules are disabled">;
+def err_atimport_cxx : Error<
+  "use of '@import' when C++ modules are disabled, consider using fmodules
"
+  "and fcxx-modules">;

 def err_invalid_reference_qualifier_application : Error<
   "'%0' qualifier may not be applied to a reference">;

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/
ParseObjc.cpp?rev=292508&r1=292507&r2=292508&view=diff
============================================================
==================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu Jan 19 13:05:55 2017
@@ -83,7 +83,10 @@ Parser::DeclGroupPtrTy Parser::ParseObjC
   case tok::objc_import:
     if (getLangOpts().Modules || getLangOpts().DebuggerSupport)
       return ParseModuleImport(AtLoc);
-    Diag(AtLoc, diag::err_atimport);
+    if (getLangOpts().CPlusPlus)
+      Diag(AtLoc, diag::err_atimport_cxx);
+    else
+      Diag(AtLoc, diag::err_atimport);
     SkipUntil(tok::semi);
     return Actions.ConvertDeclToDeclGroup(nullptr);
   default:

Added: cfe/trunk/test/Modules/check-syntax.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
Modules/check-syntax.mm?rev=292508&view=auto
============================================================
==================
--- cfe/trunk/test/Modules/check-syntax.mm (added)
+++ cfe/trunk/test/Modules/check-syntax.mm Thu Jan 19 13:05:55 2017
@@ -0,0 +1,5 @@
+// RUN: not %clang -fmodules -fno-cxx-modules -fsyntax-only %s 2>&1 |
FileCheck %s
+// rdar://19399671
+
+// CHECK: use of '@import' when C++ modules are disabled


Please test for diagnostics with -verify rather than FileCheck when
possible.

+ at import Foundation;


_______________________________________________
cfe-commits mailing list
cfe-commits at lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170119/1e7322e0/attachment.html>


More information about the cfe-commits mailing list