浏览代码

Added warnings for illegal type specifiers

Brian Fiete 5 年之前
父节点
当前提交
7f56fecc6c
共有 1 个文件被更改,包括 28 次插入0 次删除
  1. 28 0
      IDEHelper/Compiler/BfDefBuilder.cpp

+ 28 - 0
IDEHelper/Compiler/BfDefBuilder.cpp

@@ -1553,6 +1553,34 @@ void BfDefBuilder::Visit(BfTypeDeclaration* typeDeclaration)
 	else
 		BF_FATAL("Unknown type token");
 
+	if (mCurTypeDef->mIsStatic)
+	{
+		if ((mCurTypeDef->mTypeCode != BfTypeCode_Object) &&
+			(mCurTypeDef->mTypeCode != BfTypeCode_Struct))
+		{
+			mPassInstance->Warn(0, StrFormat("Types declared as '%s' cannot be 'static'", BfTokenToString(typeToken)).c_str(), typeDeclaration->mStaticSpecifier);
+			mCurTypeDef->mIsStatic = false;
+		}
+	}
+
+	if (mCurTypeDef->mIsAbstract)
+	{
+		if (mCurTypeDef->mTypeCode != BfTypeCode_Object)
+		{
+			mPassInstance->Warn(0, StrFormat("Types declared as '%s' cannot be 'abstract'", BfTokenToString(typeToken)).c_str(), typeDeclaration->mStaticSpecifier);
+			mCurTypeDef->mIsAbstract = false;
+		}
+	}
+
+	if (mCurTypeDef->mIsConcrete)
+	{
+		if (mCurTypeDef->mTypeCode != BfTypeCode_Interface)
+		{
+			mPassInstance->Warn(0, StrFormat("Types declared as '%s' cannot be 'concrete'", BfTokenToString(typeToken)).c_str(), typeDeclaration->mStaticSpecifier);
+			mCurTypeDef->mIsConcrete = false;
+		}
+	}
+
 	if (!isAutoCompleteTempType)
 	{
 		BfTypeDef* prevDef = NULL;