1// Check violations for rule 5.7 2// https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_05_07.c 3// 4// Confidence: Moderate 5// Copyright: (C) 2020 Intel Corporation 6// 7// SPDX-License-Identifier: Apache-2.0 8 9virtual report 10 11@initialize:python@ 12@@ 13 14@common_case@ 15position p; 16identifier t, v; 17@@ 18( 19struct t *v@p; 20| 21struct t v@p; 22| 23union t v@p; 24) 25 26@ script:python @ 27t << common_case.t; 28v << common_case.v; 29p << common_case.p; 30@@ 31 32msg = "WARNING: Violation to rule 5.7 (Tag name should be unique) tag: {}".format(v) 33if t == v: 34 coccilib.report.print_report(p[0], msg) 35 36@per_type@ 37type T; 38identifier v; 39position p; 40@@ 41( 42T v@p; 43| 44T *v@p; 45) 46 47@ script:python @ 48t << per_type.T; 49v << per_type.v; 50p << per_type.p; 51@@ 52 53msg = "WARNING: Violation to rule 5.7 (Tag name should be unique) tag: {}".format(v) 54if t == v: 55 coccilib.report.print_report(p[0], msg) 56 57@function_match@ 58type T1, T2; 59identifier function, v; 60position p; 61parameter list[n] P1; 62parameter list[n1] P2; 63@@ 64T1 function(P1, T2 *v@p, P2) { 65... 66} 67 68@ script:python @ 69v << function_match.v; 70t << function_match.T2; 71p << function_match.p; 72@@ 73 74msg = "WARNING: Violation to rule 5.7 (Tag name should be unique) tag: {}".format(v) 75if v == t.split(" ")[-1]: 76 coccilib.report.print_report(p[0], msg) 77