This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

hw_regaccess.h in MSPWare 2.40.00.37 generates "cast to pointer from integer of different size" warnings when compiled with gcc_msp430_4.9.14r1_364

Other Parts Discussed in Thread: MSPWARE, MSP430FR6989

While evaluating the gcc_msp430_4.9.14r1_364 compiler, imported the OutOfBox_MSP430FR6989 example from MSPWare 2.40.00.37, and changed the compiler from the TI v4.4.6 compiler to GNU v4.9.1 (Red Hat).

The GNU v4.9.1 compiler reported numerous "warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]" warnings when the HWREG8 and HWREG16 macros in hw_regaccess.h are used. E.g. the warnings when compiling one driverlib source file:

Building file: ../driverlib/MSP430FR5xx_6xx/adc12_b.c
Invoking: GNU Compiler
"/opt/ti/ti_ccs6_1_1/ccsv6/tools/compiler/gcc_msp430_4.9.14r1_364/bin/msp430-elf-gcc" -c -mmcu=msp430fr6989 -I"/opt/ti/ti_ccs6_1_1/ccsv6/ccs_base/msp430/include_gcc" -I"/home/Mr_Halfword/workspace_v6_1/OutOfBox_MSP430FR6989/driverlib/MSP430FR5xx_6xx" -I"/opt/ti/ti_ccs6_1_1/ccsv6/tools/compiler/gcc_msp430_4.9.14r1_364/msp430-elf/include" -Os -g -gdwarf-3 -gstrict-dwarf -Wall -mlarge -mcode-region=none -mdata-region=none -save-temps -MMD -MP -MF"driverlib/MSP430FR5xx_6xx/adc12_b.d" -MT"driverlib/MSP430FR5xx_6xx/adc12_b.d" -o"driverlib/MSP430FR5xx_6xx/adc12_b.o"  "../driverlib/MSP430FR5xx_6xx/adc12_b.c"
../driverlib/MSP430FR5xx_6xx/adc12_b.c: In function ‘ADC12_B_init’:
../driverlib/MSP430FR5xx_6xx/adc12_b.c:57:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG8(baseAddress + OFS_ADC12CTL0_L) &= ~ADC12ENC;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:62:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12CTL0) &= ~(ADC12ON + ADC12ENC + ADC12SC);
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:63:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12IER0) &= 0x0000;  //Reset ALL interrupt enables
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:64:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12IER1) &= 0x0000;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:65:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12IER2) &= 0x0000;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:66:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12IFGR0) &= 0x0000;  //Reset ALL interrupt flags
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:67:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12IFGR1) &= 0x0000;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:68:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12IFGR2) &= 0x0000;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:71:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12CTL1) =
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:78:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12CTL2) =
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:82:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12CTL3) =
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c: In function ‘ADC12_B_enable’:
../driverlib/MSP430FR5xx_6xx/adc12_b.c:91:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG8(baseAddress + OFS_ADC12CTL0_L) &= ~ADC12ENC;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:94:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG8(baseAddress + OFS_ADC12CTL0_L) |= ADC12ON;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c: In function ‘ADC12_B_disable’:
../driverlib/MSP430FR5xx_6xx/adc12_b.c:100:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG8(baseAddress + OFS_ADC12CTL0_L) &= ~ADC12ENC;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:103:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG8(baseAddress + OFS_ADC12CTL0_L) &= ~ADC12ON;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c: In function ‘ADC12_B_setupSamplingTimer’:
../driverlib/MSP430FR5xx_6xx/adc12_b.c:111:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12CTL1) |= ADC12SHP;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:114:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12CTL0) &=
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:118:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12CTL0) |= clockCycleHoldCountLowMem
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c: In function ‘ADC12_B_disableSamplingTimer’:
../driverlib/MSP430FR5xx_6xx/adc12_b.c:125:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12CTL1) &= ~(ADC12SHP);
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c: In function ‘ADC12_B_configureMemory’:
../driverlib/MSP430FR5xx_6xx/adc12_b.c:136:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + memoryBufferControlOffset) =
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:141:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + memoryBufferControlOffset)
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:144:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + memoryBufferControlOffset)
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:148:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + memoryBufferControlOffset)
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:151:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + memoryBufferControlOffset)
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c: In function ‘ADC12_B_setWindowCompAdvanced’:
../driverlib/MSP430FR5xx_6xx/adc12_b.c:160:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12HI) = highThreshold;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:161:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12LO) = lowThreshold;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c: In function ‘ADC12_B_enableInterrupt’:
../driverlib/MSP430FR5xx_6xx/adc12_b.c:169:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12IER0) |= interruptMask0;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:170:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12IER1) |= interruptMask1;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:171:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12IER2) |= interruptMask2;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c: In function ‘ADC12_B_disableInterrupt’:
../driverlib/MSP430FR5xx_6xx/adc12_b.c:179:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12IER0) &= ~(interruptMask0);
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:180:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12IER1) &= ~(interruptMask1);
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:181:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12IER2) &= ~(interruptMask2);
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c: In function ‘ADC12_B_clearInterrupt’:
../driverlib/MSP430FR5xx_6xx/adc12_b.c:188:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12IFGR0 + 2 * interruptRegisterChoice) &=
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c: In function ‘ADC12_B_getInterruptStatus’:
../driverlib/MSP430FR5xx_6xx/adc12_b.c:196:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     return (HWREG16(baseAddress + OFS_ADC12IFGR0 + 2 * interruptRegisterChoice)
                ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c: In function ‘ADC12_B_startConversion’:
../driverlib/MSP430FR5xx_6xx/adc12_b.c:206:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG8(baseAddress + OFS_ADC12CTL0_L) &= ~(ADC12ENC);
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:208:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12CTL3) &= ~(ADC12CSTARTADD_31);
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:209:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12CTL1) &= ~(ADC12CONSEQ_3);
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:211:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12CTL3) |= startingMemoryBufferIndex;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:212:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12CTL1) |= conversionSequenceModeSelect;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:213:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG8(baseAddress + OFS_ADC12CTL0_L) |= ADC12ENC + ADC12SC;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c: In function ‘ADC12_B_disableConversions’:
../driverlib/MSP430FR5xx_6xx/adc12_b.c:221:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
         HWREG8(baseAddress + OFS_ADC12CTL1_L) &= ~(ADC12CONSEQ_3);
            ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:224:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     else if(~(HWREG8(baseAddress + OFS_ADC12CTL1_L) & ADC12CONSEQ_3))
                  ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:234:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG8(baseAddress + OFS_ADC12CTL0_L) &= ~(ADC12ENC);
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c: In function ‘ADC12_B_getResults’:
../driverlib/MSP430FR5xx_6xx/adc12_b.c:240:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     return (HWREG16(baseAddress + (OFS_ADC12MEM0 + memoryBufferIndex)));
                ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c: In function ‘ADC12_B_setResolution’:
../driverlib/MSP430FR5xx_6xx/adc12_b.c:247:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG8(baseAddress + OFS_ADC12CTL2_L) &= ~(ADC12RES_3);
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:248:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG8(baseAddress + OFS_ADC12CTL2_L) |= resolutionSelect;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c: In function ‘ADC12_B_setSampleHoldSignalInversion’:
../driverlib/MSP430FR5xx_6xx/adc12_b.c:254:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12CTL1) &= ~(ADC12ISSH);
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:255:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG16(baseAddress + OFS_ADC12CTL1) |= invertedSignal;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c: In function ‘ADC12_B_setDataReadBackFormat’:
../driverlib/MSP430FR5xx_6xx/adc12_b.c:261:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG8(baseAddress + OFS_ADC12CTL2_L) &= ~(ADC12DF);
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:262:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG8(baseAddress + OFS_ADC12CTL2_L) |= readBackFormat;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c: In function ‘ADC12_B_setAdcPowerMode’:
../driverlib/MSP430FR5xx_6xx/adc12_b.c:268:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG8(baseAddress + OFS_ADC12CTL2_L) &= ~(ADC12PWRMD);
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c:269:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     HWREG8(baseAddress + OFS_ADC12CTL2_L) |= powerMode;
        ^
../driverlib/MSP430FR5xx_6xx/adc12_b.c: In function ‘ADC12_B_isBusy’:
../driverlib/MSP430FR5xx_6xx/adc12_b.c:281:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     return (HWREG8(baseAddress + OFS_ADC12CTL1_L) & ADC12BUSY);
                ^
Finished building: ../driverlib/MSP430FR5xx_6xx/adc12_b.c

These warnings are generated because the HWREG16 and HWREG8 are casting a uint16_t peripheral base address to a pointer, and on the MSP430FR6659 with -mlarge pointers are 20-bits.

To remove the warnings the hw_regaccess.h was modified to add #include "stddef.h" and change the HWREGxx macros to cast the peripheral base address to size_t:

#define HWREG32(x)                                                              \
    (*((volatile uint32_t *)((size_t)x)))
#define HWREG16(x)                                                             \
    (*((volatile uint16_t *)((size_t)x)))
#define HWREG8(x)                                                             \
    (*((volatile uint8_t *)((size_t)x)))

Following this change, the GNU v4.9.1 compiler no longer reported any warnings for driverlib. The change also reduced the size of the code generated for peripheral access by the GNU v4.9.1 compiler, such that the .text size for the OutOfBox_MSP430FR6989 example from 25120 bytes to 23428 bytes. I haven't analyzed the change in the generate code, but the OutOfBox_MSP430FR6989 example still functions.

Also, when using the TI v4.4.6 compiler:
- There are no warnings before and after the change.
- With Optimization Level 0 the TI v4.4.6 compiler generates the same image before and after the change.
- With Optimization Level 2 the TI v4.4.6 compiler generates 44 bytes more code, but the example still functions in both cases.

Therefore, suggest changing the hw_regaccess.h in future MSPWare releases.

The modified hw_regaccess.h is attached hw_regaccess.h

  • For reference, attached are:

    1) 0602.OutOfBox_MSP430FR6989.zip - the example project with the original hw_regaccess.h

    2) OutOfBox_MSP430FR6989_size_t.zip - the example with the modified hw_regaccess.h

    In both case the assembler files generate by the compilers have been saved:

    - The Debug directory is the TI v4.4.6 compiler with Optimization Level 0
    - The Release directory is the TI v4.4.6 compiler with Optimization Level 2
    - The Debug__GNU directory is the GNU v4.9.1 compiler

    I also forgot to mention that the vector attributes for ISR functions in the original OutOfBox_MSP430FR6989 example were only for the TI or IAR compiler, and had to add conditional compilation to support the GNU compiler.

  • Just nitpicking, but the correct type for pointer-sized integers is not size_t but uintptr_t.
  • With gcc 5.2, I cannot get this warning, and the generated code does not change. (gcc does not implement address spaces for MSP430, so specifying __near has no effect, and all accesses use MOVX, even when the address is known to use only 16 bits.)
  • Clemens Ladisch said:
    Just nitpicking, but the correct type for pointer-sized integers is not size_t but uintptr_t.

    Thanks, I wasn't aware of that.

    Clemens Ladisch said:
    With gcc 5.2, I cannot get this warning, and the generated code does not change. (gcc does not implement address spaces for MSP430, so specifying __near has no effect, and all accesses use MOVX, even when the address is known to use only 16 bits.)

    Using With the unmodified hw_regaccess.h gcc_msp430_5.2.1 I am still getting warnings. i.e. using:

    #define HWREG32(x)                                                              \
        (*((volatile uint32_t *)((uint16_t)x)))
    #define HWREG16(x)                                                             \
        (*((volatile uint16_t *)((uint16_t)x)))
    #define HWREG8(x)                                                             \
        (*((volatile uint8_t *)((uint16_t)x)))
    

    The following warnings are generated for the ADC12_B_startConversion function (other functions in the same source file generate warnings, but warnings from only one function shown for an example):

    Building file: ../driverlib/MSP430FR5xx_6xx/adc12_b.c
    Invoking: GNU Compiler
    "/opt/ti/ti_ccs6_1_1/ccsv6/tools/compiler/gcc_msp430_5.2.1/bin/msp430-elf-gcc" -c -mmcu=msp430fr6989 -I"/opt/ti/ti_ccs6_1_1/ccsv6/ccs_base/msp430/include_gcc" -I"/home/Mr_Halfword/workspace_v6_1/OutOfBox_MSP430FR6989/driverlib/MSP430FR5xx_6xx" -I"/opt/ti/ti_ccs6_1_1/ccsv6/tools/compiler/gcc_msp430_5.2.1/msp430-elf/include" -Os -g -gdwarf-3 -gstrict-dwarf -Wall -mlarge -mcode-region=none -mdata-region=none -save-temps -MMD -MP -MF"driverlib/MSP430FR5xx_6xx/adc12_b.d" -MT"driverlib/MSP430FR5xx_6xx/adc12_b.d" -o"driverlib/MSP430FR5xx_6xx/adc12_b.o"  "../driverlib/MSP430FR5xx_6xx/adc12_b.c"
    <snip>
    ../driverlib/MSP430FR5xx_6xx/adc12_b.c: In function ‘ADC12_B_startConversion’:
    ../driverlib/MSP430FR5xx_6xx/adc12_b.c:206:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
         HWREG8(baseAddress + OFS_ADC12CTL0_L) &= ~(ADC12ENC);
            ^
    ../driverlib/MSP430FR5xx_6xx/adc12_b.c:208:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
         HWREG16(baseAddress + OFS_ADC12CTL3) &= ~(ADC12CSTARTADD_31);
            ^
    ../driverlib/MSP430FR5xx_6xx/adc12_b.c:209:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
         HWREG16(baseAddress + OFS_ADC12CTL1) &= ~(ADC12CONSEQ_3);
            ^
    ../driverlib/MSP430FR5xx_6xx/adc12_b.c:211:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
         HWREG16(baseAddress + OFS_ADC12CTL3) |= startingMemoryBufferIndex;
            ^
    ../driverlib/MSP430FR5xx_6xx/adc12_b.c:212:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
         HWREG16(baseAddress + OFS_ADC12CTL1) |= conversionSequenceModeSelect;
            ^
    ../driverlib/MSP430FR5xx_6xx/adc12_b.c:213:8: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
         HWREG8(baseAddress + OFS_ADC12CTL0_L) |= ADC12ENC + ADC12SC;
            ^
    

    And with the unmodified hw_regaccess.h the GCC v5.2.1 compiler generates the following code for ADC12_B_startConversion:

    	.global	ADC12_B_startConversion
    ADC12_B_startConversion:
    .LFB11:
    	.loc 1 203 0
    ; start of function
    ; framesize_regs:     8
    ; framesize_locals:   0
    ; framesize_outgoing: 0
    ; framesize:          8
    ; elim ap -> fp       12
    ; elim fp -> sp       0
    ; saved regs: R8 R10
    .LVL33:
    	; start of prologue
    	PUSHM.A	#1, R10
    .LCFI6:
    	PUSHM.A	#1, R8
    .LCFI7:
    	; end of prologue
    	AND	#0xff, R14
    	.loc 1 206 0
    	MOVX	R12, R8
    	BIC.B	#2, @R8
    	.loc 1 208 0
    	MOV.W	R12, R10
    	ADD.W	#6, R10
    	MOVX	R10, R10
    	AND.W	#-32, @R10
    	.loc 1 209 0
    	ADD.W	#2, R12
    .LVL34:
    	MOVX	R12, R12
    	AND.W	#-7, @R12
    	.loc 1 211 0
    	BIS.W	R13, @R10
    	.loc 1 212 0
    	BIS.W	R14, @R12
    	.loc 1 213 0
    	BIS.B	#3, @R8
    	.loc 1 214 0
    	; start of epilogue
    	POPM.A	#1, r8
    	POPM.A	#1, r10
    	RETA
    .LFE11:
    	.size	ADC12_B_startConversion, .-ADC12_B_startConversion
    	.balign 2
    

    When hw_regaccess.h is changed to the following the GCC v5.2.1 compiler generates no warning:

    #define HWREG32(x)                                                              \
        (*((volatile uint32_t *)((uintptr_t)x)))
    #define HWREG16(x)                                                             \
        (*((volatile uint16_t *)((uintptr_t)x)))
    #define HWREG8(x)                                                             \
        (*((volatile uint8_t *)((uintptr_t)x)))
    

    And the code generated for the ADC12_B_startConversion function is different:

    	.global	ADC12_B_startConversion
    ADC12_B_startConversion:
    .LFB11:
    	.loc 1 203 0
    ; start of function
    ; framesize_regs:     8
    ; framesize_locals:   0
    ; framesize_outgoing: 0
    ; framesize:          8
    ; elim ap -> fp       12
    ; elim fp -> sp       0
    ; saved regs: R8 R10
    .LVL27:
    	; start of prologue
    	PUSHM.A	#1, R10
    .LCFI4:
    	PUSHM.A	#1, R8
    .LCFI5:
    	; end of prologue
    	AND	#0xff, R14
    	.loc 1 206 0
    	MOVX	R12, R12
    	BIC.B	#2, @R12
    	.loc 1 208 0
    	MOVA	R12, R8
    	ADDA	#6, R8
    	AND.W	#-32, @R8
    	.loc 1 209 0
    	MOVA	R12, R10
    	ADDA	#2, R10
    	AND.W	#-7, @R10
    	.loc 1 211 0
    	BIS.W	R13, @R8
    	.loc 1 212 0
    	BIS.W	R14, @R10
    	.loc 1 213 0
    	BIS.B	#3, @R12
    	.loc 1 214 0
    	; start of epilogue
    	POPM.A	#1, r8
    	POPM.A	#1, r10
    	RETA
    .LFE11:
    	.size	ADC12_B_startConversion, .-ADC12_B_startConversion
    	.balign 2
    

    I am curious about why you couldn't repeat the warnings / code change with gcc 5.2.

    I got GCC v5.2.1 from http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/4_00_00_900/index_FDS.html 

  • Apparently, there is no warning if the address is a constant.

    I can now confirm that gcc behaves as shown by you.

**Attention** This is a public forum