[cfe-commits] r74917 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/implicit-builtin-redecl.c
Douglas Gregor
dgregor at apple.com
Tue Jul 7 10:00:06 PDT 2009
Author: dgregor
Date: Tue Jul 7 12:00:05 2009
New Revision: 74917
URL: http://llvm.org/viewvc/llvm-project?rev=74917&view=rev
Log:
Tighten up the conditions under which we build an implicit function
declaration for a builtin.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/implicit-builtin-redecl.c
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=74917&r1=74916&r2=74917&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jul 7 12:00:05 2009
@@ -1431,15 +1431,18 @@
if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef)
/* Do nothing*/;
else if (R->isFunctionType()) {
- if (CurContext->isFunctionOrMethod())
+ if (CurContext->isFunctionOrMethod() ||
+ D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_static)
NameKind = LookupRedeclarationWithLinkage;
} else if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_extern)
NameKind = LookupRedeclarationWithLinkage;
+ else if (CurContext->getLookupContext()->isTranslationUnit() &&
+ D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_static)
+ NameKind = LookupRedeclarationWithLinkage;
DC = CurContext;
PrevDecl = LookupName(S, Name, NameKind, true,
- D.getDeclSpec().getStorageClassSpec() !=
- DeclSpec::SCS_static,
+ NameKind == LookupRedeclarationWithLinkage,
D.getIdentifierLoc());
} else { // Something like "int foo::x;"
DC = computeDeclContext(D.getCXXScopeSpec());
Modified: cfe/trunk/test/Sema/implicit-builtin-redecl.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/implicit-builtin-redecl.c?rev=74917&r1=74916&r2=74917&view=diff
==============================================================================
--- cfe/trunk/test/Sema/implicit-builtin-redecl.c (original)
+++ cfe/trunk/test/Sema/implicit-builtin-redecl.c Tue Jul 7 12:00:05 2009
@@ -12,3 +12,15 @@
void f1(void) {
calloc(0, 0, 0);
}
+
+void f2() {
+ int index = 1;
+}
+
+static int index;
+
+int f3() {
+ return index << 2;
+}
+
+typedef int rindex;
\ No newline at end of file
More information about the cfe-commits
mailing list