diff trunk/src/dil/semantic/Pass1.d @ 787:47c5099562c7

Added two semantic error messages.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sun, 24 Feb 2008 03:11:39 +0100
parents 8380fb2c765f
children c24be8d4f6ab
line wrap: on
line diff
--- a/trunk/src/dil/semantic/Pass1.d	Sun Feb 24 02:41:11 2008 +0100
+++ b/trunk/src/dil/semantic/Pass1.d	Sun Feb 24 03:11:39 2008 +0100
@@ -72,6 +72,12 @@
     scop = scop.exit();
   }
 
+  /// Returns true if this is the module scope.
+  bool isModuleScope()
+  {
+    return scop.symbol.isModule();
+  }
+
   /// Insert a symbol into the current scope.
   void insert(Symbol symbol, Identifier* name)
   {
@@ -352,7 +358,9 @@
   {
     if (d.isSpecification)
     {
-      if (d.spec.kind == TOK.Identifier)
+      if (!isModuleScope())
+        error(d.begin, MSG.DebugSpecModuleLevel, d.spec.srcText);
+      else if (d.spec.kind == TOK.Identifier)
         context.addDebugId(d.spec.ident.str);
       else
         context.debugLevel = d.spec.uint_;
@@ -372,7 +380,9 @@
   {
     if (d.isSpecification)
     {
-      if (d.spec.kind == TOK.Identifier)
+      if (!isModuleScope())
+        error(d.begin, MSG.VersionSpecModuleLevel, d.spec.srcText);
+      else if (d.spec.kind == TOK.Identifier)
         context.addVersionId(d.spec.ident.str);
       else
         context.versionLevel = d.spec.uint_;