ext->minor_version = minor_version;
}
else
- error_at (
- m_loc,
- "%<-march=%s%>: extension %qs appear more than one time",
- m_arch,
- subset);
-
+ {
+ /* The extension is already in the list. */
+ if (!m_allow_adding_dup
+ || ext->major_version != major_version
+ || ext->minor_version != minor_version)
+ error_at (
+ m_loc,
+ "%<-march=%s%>: extension %qs appear more than one time",
+ m_arch,
+ subset);
+ }
return;
}
else if (strlen (subset) == 1 && !standard_extensions_p (subset))
/* Number of subsets. */
unsigned m_subset_num;
+ /* Allow adding the same extension more than once. */
+ bool m_allow_adding_dup;
+
riscv_subset_list (const char *, location_t);
const char *parsing_subset_version (const char *, const char *, unsigned *,
void set_loc (location_t);
+ void set_allow_adding_dup (bool v) { m_allow_adding_dup = v; }
+
void finalize ();
};
? riscv_subset_list::parse (local_arch_str, m_loc)
: riscv_cmdline_subset_list ()->clone ();
m_subset_list->set_loc (m_loc);
+ m_subset_list->set_allow_adding_dup (true);
+
while (token)
{
if (token[0] != '+')
token = strtok_r (NULL, ",", &str_to_check);
}
+ m_subset_list->set_allow_adding_dup (false);
m_subset_list->finalize ();
return true;
}
__attribute__((target("arch=+zbb")))
__attribute__((target("arch=+zbb")))
void bar(void);
-
-/* { dg-error "extension 'zbb' appear more than one time" "" { target *-*-* } 0 } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-march=rv32gc_zba" { target { rv32 } } } */
+/* { dg-options "-march=rv64gc_zba" { target { rv64 } } } */
+
+__attribute__((target("arch=+zba,+zbb")))
+void foo1 (void)
+{
+}
+
+__attribute__((target("arch=+zbb,+zbb")))
+void foo2 (void)
+{
+}
+
+__attribute__((target("arch=+zba")))
+__attribute__((target("arch=+zbb")))
+void foo (void)
+{
+}
+
+__attribute__((target("arch=+zbb")))
+__attribute__((target("arch=+zbb")))
+void bar (void)
+{
+}
+
+/* { dg-final { scan-assembler-times ".option arch, rv32i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zba1p0_zbb1p0" 4 { target { rv32 } } } } */
+/* { dg-final { scan-assembler-times ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zba1p0_zbb1p0" 4 { target { rv64 } } } } */