]> granicus.if.org Git - clang/commitdiff
Revert "Fix for merging decls in pragma weak Calling CheckFunctionDeclaration so...
authorAlexander Kornienko <alexfh@google.com>
Thu, 3 Dec 2015 11:37:28 +0000 (11:37 +0000)
committerAlexander Kornienko <alexfh@google.com>
Thu, 3 Dec 2015 11:37:28 +0000 (11:37 +0000)
This reverts commit r254143 which introduces a crash on the following input:
  f(char *);
  g(char *);
  #pragma weak f = g
  int g(char *p) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@254605 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclAttr.cpp
test/CodeGen/pragma-weak.c
test/Sema/pragma-weak.c

index fed22c934ce1375a80e4bece78fcadb376c86cdc..5a0f0f84af7e7e961b5e0d0c5ab9863d84a904a1 100644 (file)
@@ -5546,22 +5546,17 @@ NamedDecl * Sema::DeclClonePragmaWeak(NamedDecl *ND, IdentifierInfo *II,
   assert(isa<FunctionDecl>(ND) || isa<VarDecl>(ND));
   NamedDecl *NewD = nullptr;
   if (FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
+    FunctionDecl *NewFD;
+    // FIXME: Missing call to CheckFunctionDeclaration().
     // FIXME: Mangling?
     // FIXME: Is the qualifier info correct?
     // FIXME: Is the DeclContext correct?
-
-    LookupResult Previous(*this, II, Loc, LookupOrdinaryName);
-    LookupParsedName(Previous, TUScope, nullptr, true);
-
-    auto NewFD = FunctionDecl::Create(
-        FD->getASTContext(), FD->getDeclContext(), Loc, Loc,
-        DeclarationName(II), FD->getType(), FD->getTypeSourceInfo(), SC_None,
-        false /*isInlineSpecified*/, FD->hasPrototype(),
-        false /*isConstexprSpecified*/);
-
-    CheckFunctionDeclaration(TUScope, NewFD, Previous,
-                             false /*IsExplicitSpecialization*/);
-
+    NewFD = FunctionDecl::Create(FD->getASTContext(), FD->getDeclContext(),
+                                 Loc, Loc, DeclarationName(II),
+                                 FD->getType(), FD->getTypeSourceInfo(),
+                                 SC_None, false/*isInlineSpecified*/,
+                                 FD->hasPrototype(),
+                                 false/*isConstexprSpecified*/);
     NewD = NewFD;
 
     if (FD->getQualifier())
index e63277fc2307128963f4c8b4338ca7be28138e11..36abca5de32bbf5d5fc5160d41d036a64a2baecd 100644 (file)
@@ -17,7 +17,6 @@
 // CHECK-DAG: @mix2 = weak alias void (), void ()* @__mix2
 // CHECK-DAG: @a1 = weak alias void (), void ()* @__a1
 // CHECK-DAG: @xxx = weak alias void (), void ()* @__xxx
-// CHECK-DAG: @weakfoo = weak alias void {{.*}} @localfoo
 
 
 
@@ -174,14 +173,6 @@ label:
 // CHECK: declare extern_weak i32 @PR16705b()
 // CHECK: declare extern_weak i32 @PR16705c()
 
-// In this test case, we have a declaration of weakfoo before #pragma weak.
-// Test that 2 decls for the weakfoo are merged.
-extern void weakfoo();
-void localfoo() { }
-#pragma weak weakfoo=localfoo
-extern void externmain() { return weakfoo(); }
-// CHECK-LABEL: define void @externmain()
-// CHECK: call{{.*}}@weakfoo
 
 ///////////// TODO: stuff that still doesn't work
 
index 031e78f15ff9de41b08b5468f1cf832c59cffe83..c14125eac9f7cbd17329ced19db889ac76a6703d 100644 (file)
@@ -9,9 +9,3 @@ void __a3(void) __attribute((noinline));
 #pragma weak a3 = __a3 // expected-note {{previous definition}}
 void a3(void) __attribute((alias("__a3"))); // expected-error {{redefinition of 'a3'}}
 void __a3(void) {}
-
-extern void weak2foo(int); // expected-note {{previous declaration is here}} expected-note {{'weak2foo' declared here}}
-void local2foo(double d1, double d2) { }
-#pragma weak weak2foo=local2foo // expected-error {{conflicting types for 'weak2foo'}}
-extern void extern2main() { return weak2foo(); } // expected-error {{too few arguments to function call, expected 1, have 0}}
-