From 6ceb89b2955472b83d1cd1734231b46188e0c9bf Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
Date: Mon, 4 Jun 2018 12:04:54 +0100
Subject: [PATCH] MSP430: Fix device name symbol defined for msp430i* devices
2018-06-04 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* gcc/config/msp430/msp430.c (msp430_mcu_name): Set the "i" in the
symbol defined for msp430i* devices to be lower case.
gcc/testsuite/gcc.target/msp430/
* msp430i-device-symbol.c: New test.
* msp430.h: New test header file.
---
gcc/config/msp430/msp430.c | 16 ++++++++++++----
gcc/testsuite/gcc.target/msp430/msp430.h | 6 ++++++
gcc/testsuite/gcc.target/msp430/msp430i-device-symbol.c | 4 ++++
3 files changed, 22 insertions(+), 4 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/msp430/msp430.h
create mode 100644 gcc/testsuite/gcc.target/msp430/msp430i-device-symbol.c
@@ -725,11 +725,19 @@ msp430_mcu_name (void)
if (target_mcu)
{
unsigned int i;
- static char mcu_name [64];
+ static char mcu_name[64];
- snprintf (mcu_name, sizeof (mcu_name) - 1, "__%s__", target_mcu);
- for (i = strlen (mcu_name); i--;)
- mcu_name[i] = TOUPPER (mcu_name[i]);
+ /* The 'i' in the device name symbol for msp430i* devices must be lower
+ case, to match the expected symbol in msp430.h. */
+ if (strncmp (target_mcu, "msp430i", 7) == 0)
+ snprintf (mcu_name, sizeof (mcu_name) - 1, "__MSP430i%s__",
+ target_mcu + 7);
+ else
+ {
+ snprintf (mcu_name, sizeof (mcu_name) - 1, "__%s__", target_mcu);
+ for (i = strlen (mcu_name); i--;)
+ mcu_name[i] = TOUPPER (mcu_name[i]);
+ }
return mcu_name;
}
new file mode 100644
@@ -0,0 +1,6 @@
+#if defined (__MSP430i2020__)
+
+#else
+#error "Device not supported by msp430.h"
+
+#endif
new file mode 100644
@@ -0,0 +1,4 @@
+/* { dg-do preprocess } */
+/* { dg-skip-if "" { "*-*-*" } { "-mlarge" "-mcpu=msp430x*" "-mmcu=*" "-mhwmult=32bit" "-mhwmult=f5series" } { "" } } */
+/* { dg-options "-mmcu=msp430i2020" } */
+#include "msp430.h"
--
2.7.4