aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td3
-rw-r--r--lib/Sema/SemaDecl.cpp7
-rw-r--r--test/Sema/redefinition.c4
3 files changed, 13 insertions, 1 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 82f059b865..3bb85fc0f0 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1737,6 +1737,9 @@ def err_redefinition : Error<"redefinition of %0">;
def err_definition_of_implicitly_declared_member : Error<
"definition of implicitly declared %select{constructor|copy constructor|"
"copy assignment operator|destructor}1">;
+def err_redefinition_extern_inline : Error<
+ "redefinition of a 'extern inline' function %0 is not supported in "
+ "%select{C99 mode|C++}1">;
def warn_redefinition_of_typedef : Warning<
"redefinition of typedef %0 is invalid in C">,
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index f5e045a722..df077fd709 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -4806,7 +4806,12 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D) {
const FunctionDecl *Definition;
if (FD->hasBody(Definition) &&
!canRedefineFunction(Definition, getLangOptions())) {
- Diag(FD->getLocation(), diag::err_redefinition) << FD->getDeclName();
+ if (getLangOptions().GNUMode && Definition->isInlineSpecified() &&
+ Definition->getStorageClass() == SC_Extern)
+ Diag(FD->getLocation(), diag::err_redefinition_extern_inline)
+ << FD->getDeclName() << getLangOptions().CPlusPlus;
+ else
+ Diag(FD->getLocation(), diag::err_redefinition) << FD->getDeclName();
Diag(Definition->getLocation(), diag::note_previous_definition);
}
diff --git a/test/Sema/redefinition.c b/test/Sema/redefinition.c
index 1092b33ca3..1ee35f7c36 100644
--- a/test/Sema/redefinition.c
+++ b/test/Sema/redefinition.c
@@ -8,3 +8,7 @@ int foo(x) {
return 0;
}
int x = 1;
+
+// <rdar://problem/6880464>
+extern inline int g(void) { return 0; } // expected-note{{previous definition}}
+int g(void) { return 0; } // expected-error{{redefinition of a 'extern inline' function 'g' is not supported in C99 mode}}