parser BUGFIX config deviation add/replace checks

Fixes #991
diff --git a/src/parser_yang.c b/src/parser_yang.c
index a6b528c..9a93bd1 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -4452,6 +4452,17 @@
     }
 
     if ((deviate->flags & LYS_CONFIG_MASK)) {
+        /* cannot add if it was explicitly set */
+        if ((deviate->mod == LY_DEVIATE_ADD) && (dev_target->flags & LYS_CONFIG_SET)) {
+            LOGVAL(module->ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, "config");
+            LOGVAL(module->ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Adding property that already exists.");
+            goto error;
+        } else if ((deviate->mod == LY_DEVIATE_RPL) && !(dev_target->flags & LYS_CONFIG_SET)) {
+            LOGVAL(module->ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, "config");
+            LOGVAL(module->ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Replacing a property that does not exist.");
+            goto error;
+        }
+
         /* add and replace are the same in this case */
         /* remove current config value of the target ... */
         dev_target->flags &= ~LYS_CONFIG_MASK;
diff --git a/src/parser_yin.c b/src/parser_yin.c
index 1deb978..6a71b92 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -2432,6 +2432,14 @@
                     /* del config is forbidden */
                     LOGVAL(ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, "config", "deviate delete");
                     goto error;
+                } else if ((d->mod == LY_DEVIATE_ADD) && (dev_target->flags & LYS_CONFIG_SET)) {
+                    LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, "config");
+                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Adding property that already exists.");
+                    goto error;
+                } else if ((d->mod == LY_DEVIATE_RPL) && !(dev_target->flags & LYS_CONFIG_SET)) {
+                    LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, "config");
+                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Replacing a property that does not exist.");
+                    goto error;
                 } else { /* add and replace are the same in this case */
                     /* remove current config value of the target ... */
                     dev_target->flags &= ~LYS_CONFIG_MASK;