CPUSpecifc/CPUDispatch call resolution assumed that all declarations
that would be passed are valid, however this was an invalid assumption.
This patch deals with those situations by making the valid version take
priority. Note that the checked ordering is arbitrary, since both are
replaced by calls to the resolver later.
Change-Id: I7ff2ec88c55a721d51bc1f39ea1a1fe242b4e45f
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@350398
91177308-0d34-0410-b5e6-
96231b3b80d8
!Cand2.Function->isMultiVersion())
return false;
+ // If Cand1 is invalid, it cannot be a better match, if Cand2 is invalid, this
+ // is obviously better.
+ if (Cand1.Function->isInvalidDecl()) return false;
+ if (Cand2.Function->isInvalidDecl()) return true;
+
// If this is a cpu_dispatch/cpu_specific multiversion situation, prefer
// cpu_dispatch, else arbitrarily based on the identifiers.
bool Cand1CPUDisp = Cand1.Function->hasAttr<CPUDispatchAttr>();
int __attribute__((cpu_dispatch(atom))) disp_with_body(void) {
return 5;
}
+
+// expected-error@+1 {{invalid option 'INVALID'}}
+int __attribute__((cpu_specific(INVALID))) called_invalid_value(void){ return 1;}
+// expected-warning@+3 {{attribute declaration must precede definition}}
+// expected-note@-2 2 {{previous definition is here}}
+// expected-error@+1 {{redefinition of}}
+int __attribute__((cpu_specific(pentium_iii))) called_invalid_value(void){ return 2;}
+int __attribute__((cpu_specific(pentium_4))) called_invalid_value(void){ return 3;}
+
+int use3(void) {
+ return called_invalid_value();
+}