aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mds-kbdc/process-includes.c9
-rw-r--r--test-files/mds-kbdc/process-includes/invalid/inclusion_circle6
-rw-r--r--test-files/mds-kbdc/process-includes/invalid/inclusion_rho16
-rw-r--r--test-files/mds-kbdc/process-includes/valid/include_include_empty_file6
4 files changed, 21 insertions, 16 deletions
diff --git a/src/mds-kbdc/process-includes.c b/src/mds-kbdc/process-includes.c
index 64dd7eb..cfd0fe3 100644
--- a/src/mds-kbdc/process-includes.c
+++ b/src/mds-kbdc/process-includes.c
@@ -86,7 +86,7 @@ static int transfer_errors(mds_kbdc_parsed_t* restrict subresult, mds_kbdc_tree_
mds_kbdc_parse_error_t** errors = NULL;
mds_kbdc_parse_error_t* suberror;
size_t errors_ptr = 0;
- int saved_errno;
+ int saved_errno, annotated = 0;
/* Allocate temporary list for errors. */
if (subresult->errors_ptr == 0)
@@ -99,16 +99,21 @@ static int transfer_errors(mds_kbdc_parsed_t* restrict subresult, mds_kbdc_tree_
suberror = subresult->errors[subresult->errors_ptr];
/* If it is more severe than a note, we want to say there it was included. */
- if (suberror->severity > MDS_KBDC_PARSE_ERROR_NOTE)
+ if (annotated == 0)
{
NEW_ERROR(tree, NOTE, "included from here");
errors[errors_ptr++] = error;
result->errors[--(result->errors_ptr)] = NULL;
+ annotated = 1;
}
/* Include error. */
errors[errors_ptr++] = suberror;
subresult->errors[subresult->errors_ptr] = NULL;
+
+ /* Make sure when there are nested inclusions that the outermost inclusion * is annotated last. */
+ if (suberror->severity > MDS_KBDC_PARSE_ERROR_NOTE)
+ annotated = 0;
}
/* Append errors. */
diff --git a/test-files/mds-kbdc/process-includes/invalid/inclusion_circle b/test-files/mds-kbdc/process-includes/invalid/inclusion_circle
index 11214e7..aa5f01d 100644
--- a/test-files/mds-kbdc/process-includes/invalid/inclusion_circle
+++ b/test-files/mds-kbdc/process-includes/invalid/inclusion_circle
@@ -13,10 +13,10 @@ include "_inclusion_circle"
# )
# .../test-files/mds-kbdc/process-includes/invalid/inclusion_circle: error: resursive inclusion
#
-# .../test-files/mds-kbdc/process-includes/invalid/inclusion_circle:1:0–7: note: included from here
-# include "_inclusion_circle"
-# ^^^^^^^
# .../test-files/mds-kbdc/process-includes/invalid/_inclusion_circle:1:0–7: note: included from here
# include "inclusion_circle"
# ^^^^^^^
+# .../test-files/mds-kbdc/process-includes/invalid/inclusion_circle:1:0–7: note: included from here
+# include "_inclusion_circle"
+# ^^^^^^^
diff --git a/test-files/mds-kbdc/process-includes/invalid/inclusion_rho b/test-files/mds-kbdc/process-includes/invalid/inclusion_rho
index 43aabc9..5763ade 100644
--- a/test-files/mds-kbdc/process-includes/invalid/inclusion_rho
+++ b/test-files/mds-kbdc/process-includes/invalid/inclusion_rho
@@ -25,19 +25,19 @@ include "_inclusion_rho_1"
# )
# .../test-files/mds-kbdc/process-includes/invalid/_inclusion_rho_2: error: resursive inclusion
#
-# .../test-files/mds-kbdc/process-includes/invalid/inclusion_rho:1:0–7: note: included from here
-# include "_inclusion_rho_1"
-# ^^^^^^^
-# .../test-files/mds-kbdc/process-includes/invalid/_inclusion_rho_1:1:0–7: note: included from here
+# .../test-files/mds-kbdc/process-includes/invalid/_inclusion_rho_4:1:0–7: note: included from here
# include "_inclusion_rho_2"
# ^^^^^^^
-# .../test-files/mds-kbdc/process-includes/invalid/_inclusion_rho_2:1:0–7: note: included from here
-# include "_inclusion_rho_3"
-# ^^^^^^^
# .../test-files/mds-kbdc/process-includes/invalid/_inclusion_rho_3:1:0–7: note: included from here
# include "_inclusion_rho_4"
# ^^^^^^^
-# .../test-files/mds-kbdc/process-includes/invalid/_inclusion_rho_4:1:0–7: note: included from here
+# .../test-files/mds-kbdc/process-includes/invalid/_inclusion_rho_2:1:0–7: note: included from here
+# include "_inclusion_rho_3"
+# ^^^^^^^
+# .../test-files/mds-kbdc/process-includes/invalid/_inclusion_rho_1:1:0–7: note: included from here
# include "_inclusion_rho_2"
# ^^^^^^^
+# .../test-files/mds-kbdc/process-includes/invalid/inclusion_rho:1:0–7: note: included from here
+# include "_inclusion_rho_1"
+# ^^^^^^^
diff --git a/test-files/mds-kbdc/process-includes/valid/include_include_empty_file b/test-files/mds-kbdc/process-includes/valid/include_include_empty_file
index 9b8e1c1..f9e816f 100644
--- a/test-files/mds-kbdc/process-includes/valid/include_include_empty_file
+++ b/test-files/mds-kbdc/process-includes/valid/include_include_empty_file
@@ -9,10 +9,10 @@ include "include_empty_file"
# )
# .../test-files/mds-kbdc/process-includes/valid/_empty: warning: file is empty
#
-# .../test-files/mds-kbdc/process-includes/valid/include_include_empty_file:1:0–7: note: included from here
-# include "include_empty_file"
-# ^^^^^^^
# .../test-files/mds-kbdc/process-includes/valid/include_empty_file:1:0–7: note: included from here
# include "_empty"
# ^^^^^^^
+# .../test-files/mds-kbdc/process-includes/valid/include_include_empty_file:1:0–7: note: included from here
+# include "include_empty_file"
+# ^^^^^^^