================
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -triple bpf -debug-info-kind=limited -fsyntax-only 
-verify=expected,reloc -Wswitch %s
+// RUN: %clang_cc1 -triple bpf -fsyntax-only -verify=expected,reloc -Wswitch %s
+// RUN: %clang_cc1 -triple bpf -debug-info-kind=limited -fsyntax-only -verify 
-Wswitch \
+// RUN:   -fbpf-no-enum-reloc=E %s
+
+// A relocated enumerator in a case label is not diagnosed by
+// -Wbpf-enum-not-relocated. The case labels are checked with the local values,
+// as with -fbpf-no-enum-reloc=.
+
+enum E { A = 1, B = 4, C = 8, D = 300 } __attribute__((preserve_access_index));
+
+int f(int i, char c, enum E e) {
+  switch (i) {
+  case A: // expected-note {{previous case defined here}}
+    return 1;
+  case 1: // expected-error {{duplicate case value: 'A' and '1' both equal 
'1'}}
----------------
YJNSystems wrote:

I think @efriedma-quic is questioning whether the duplicate checks should be 
done at all for relocated values, since their compile-time values aren't 
necessarily representative of their runtime values. E.g. 'A' may be a duplicate 
at compile-time but relocated to something else at runtime. Since the 
precedence and order of relocated conditions is well defined and covers runtime 
duplicates implicitly, I think the compile-time overlap check does more harm 
than good. Perhaps we can just skip it for relocated values?

Besides that, this PR perfectly addresses both of my previous review concerns. 
Thank you!

https://github.com/llvm/llvm-project/pull/243338
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to