diff --git a/clang/test/Sema/aarch64-sve-enums.c b/clang/test/Sema/aarch64-sve-enums.c new file mode 100644 --- /dev/null +++ b/clang/test/Sema/aarch64-sve-enums.c @@ -0,0 +1,19 @@ +// REQUIRES: aarch64-registered-target +// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify +// expected-no-diagnostics + +// This test makes sure that the enum declarations in section "5. Enum +// declarations" of the SVE ACLE [1] are not presented as typedefs in +// `arm_sve.h`. It does so by creating a typedef'd struct with the +// same identifier as the one defined in `arm_sve.h`, then checking that +// it does not overload the enum defined in `arm_sve.h`. +// +// [1] https://developer.arm.com/documentation/100987/latest version 00bet6 + +typedef struct { float f; } svpattern; +typedef struct { float f; } svprfop; +#include +enum svpattern a1 = SV_ALL; +svpattern b1 = {1.0f}; +enum svprfop a2 = SV_PLDL1KEEP; +svprfop b2 = {1.0f}; diff --git a/clang/utils/TableGen/SveEmitter.cpp b/clang/utils/TableGen/SveEmitter.cpp --- a/clang/utils/TableGen/SveEmitter.cpp +++ b/clang/utils/TableGen/SveEmitter.cpp @@ -416,10 +416,10 @@ std::string SVEType::str() const { if (isPredicatePattern()) - return "sv_pattern"; + return "enum svpattern"; if (isPrefetchOp()) - return "sv_prfop"; + return "enum svprfop"; std::string S; if (Void) @@ -1163,7 +1163,7 @@ OS << "typedef __clang_svbfloat16x4_t svbfloat16x4_t;\n"; OS << "#endif\n"; - OS << "typedef enum\n"; + OS << "enum svpattern\n"; OS << "{\n"; OS << " SV_POW2 = 0,\n"; OS << " SV_VL1 = 1,\n"; @@ -1182,9 +1182,9 @@ OS << " SV_MUL4 = 29,\n"; OS << " SV_MUL3 = 30,\n"; OS << " SV_ALL = 31\n"; - OS << "} sv_pattern;\n\n"; + OS << "};\n\n"; - OS << "typedef enum\n"; + OS << "enum svprfop\n"; OS << "{\n"; OS << " SV_PLDL1KEEP = 0,\n"; OS << " SV_PLDL1STRM = 1,\n"; @@ -1198,7 +1198,7 @@ OS << " SV_PSTL2STRM = 11,\n"; OS << " SV_PSTL3KEEP = 12,\n"; OS << " SV_PSTL3STRM = 13\n"; - OS << "} sv_prfop;\n\n"; + OS << "};\n\n"; OS << "/* Function attributes */\n"; OS << "#define __aio static inline __attribute__((__always_inline__, "