Merge "libdex: Enable -Wimplicit-fallthrough"
diff --git a/libdex/Android.bp b/libdex/Android.bp
index b98d25d..ad0128b 100644
--- a/libdex/Android.bp
+++ b/libdex/Android.bp
@@ -45,6 +45,7 @@
cflags: [
"-Wall",
"-Werror",
+ "-Wimplicit-fallthrough",
],
target: {
android: {
diff --git a/libdex/DexFile.h b/libdex/DexFile.h
index b3dcca1..7fc7d05 100644
--- a/libdex/DexFile.h
+++ b/libdex/DexFile.h
@@ -33,6 +33,12 @@
#ifndef LIBDEX_DEXFILE_H_
#define LIBDEX_DEXFILE_H_
+/*
+ * Annotation to tell clang that we intend to fall through from one case to
+ * another in a switch. Sourced from android-base/macros.h.
+ */
+#define FALLTHROUGH_INTENDED [[clang::fallthrough]]
+
#ifndef LOG_TAG
# define LOG_TAG "libdex"
#endif
diff --git a/libdex/DexSwapVerify.cpp b/libdex/DexSwapVerify.cpp
index 1049bab..d756dc4 100644
--- a/libdex/DexSwapVerify.cpp
+++ b/libdex/DexSwapVerify.cpp
@@ -617,7 +617,7 @@
ALOGE("Invalid use of void");
return false;
}
- // Fall through.
+ FALLTHROUGH_INTENDED;
}
case 'B':
case 'C':
diff --git a/libdex/InstrUtils.cpp b/libdex/InstrUtils.cpp
index 9039f59..56f5dd8 100644
--- a/libdex/InstrUtils.cpp
+++ b/libdex/InstrUtils.cpp
@@ -619,10 +619,11 @@
* instruction, but it's labeled G in the spec.
*/
pDec->arg[4] = INST_A(inst);
+ FALLTHROUGH_INTENDED;
}
- case 4: pDec->arg[3] = (regList >> 12) & 0x0f;
- case 3: pDec->arg[2] = (regList >> 8) & 0x0f;
- case 2: pDec->arg[1] = (regList >> 4) & 0x0f;
+ case 4: pDec->arg[3] = (regList >> 12) & 0x0f; FALLTHROUGH_INTENDED;
+ case 3: pDec->arg[2] = (regList >> 8) & 0x0f; FALLTHROUGH_INTENDED;
+ case 2: pDec->arg[1] = (regList >> 4) & 0x0f; FALLTHROUGH_INTENDED;
case 1: pDec->vC = pDec->arg[0] = regList & 0x0f; break;
case 0: break; // Valid, but no need to do anything.
default: