[PATCH] D16171: Warning on redeclaring with a conflicting asm label
Nick Lewycky via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 14 03:34:28 PST 2016
nicholas added a subscriber: nicholas.
nicholas added a comment.
Weiming Zhao wrote:
> weimingz created this revision.
> weimingz added a reviewer: nicholas.
> weimingz added a subscriber: cfe-commits.
>
> r255371 errors on redeclaring with a conflicting asm label.
> This patch changes errors to warnings to prevent breaking existing codes.
Can you include a testcase where the warning is issued but clang and gcc
emit the same .o file?
> http://reviews.llvm.org/D16171
>
> Files:
>
> include/clang/Basic/DiagnosticSemaKinds.td
> lib/Sema/SemaDecl.cpp
> test/Sema/asm-label.c
>
> Index: test/Sema/asm-label.c
> ===================================================================
>
> - test/Sema/asm-label.c +++ test/Sema/asm-label.c @@ -7,21 +7,21 @@ void f() { g(); } -void g() __asm__("gold"); // expected-error{{cannot apply asm label to function after its first use}} +void g() __asm__("gold"); // expected-warning{{cannot apply asm label to function after its first use}}
>
> void h() __asm__("hose"); // expected-note{{previous declaration is here}} -void h() __asm__("hair"); // expected-error{{conflicting asm label}} +void h() __asm__("hair"); // expected-warning{{conflicting asm label}}
>
> int x; int x __asm__("xenon"); int y;
>
> int test() { return y; }
>
> -int y __asm__("yacht"); // expected-error{{cannot apply asm label to variable after its first use}} +int y __asm__("yacht"); // expected-warning{{cannot apply asm label to variable after its first use}}
>
> int z __asm__("zebra"); // expected-note{{previous declaration is here}} -int z __asm__("zooms"); // expected-error{{conflicting asm label}} +int z __asm__("zooms"); // expected-warning{{conflicting asm label}}
>
>
>
> // No diagnostics on the following.
>
> Index: lib/Sema/SemaDecl.cpp
> ===================================================================
>
> - lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -2385,13 +2385,13 @@ if (AsmLabelAttr *OldA = Old->getAttr<AsmLabelAttr>()) { if (OldA->getLabel() != NewA->getLabel()) { // This redeclaration changes __asm__ label.
> - Diag(New->getLocation(), diag::err_different_asm_label); + Diag(New->getLocation(), diag::warn_different_asm_label); Diag(OldA->getLocation(), diag::note_previous_declaration); } } else if (Old->isUsed()) { // This redeclaration adds an __asm__ label to a declaration that has // already been ODR-used.
> - Diag(New->getLocation(), diag::err_late_asm_label_name) + Diag(New->getLocation(), diag::warn_late_asm_label_name) << isa<FunctionDecl>(Old)<< New->getAttr<AsmLabelAttr>()->getRange(); } } Index: include/clang/Basic/DiagnosticSemaKinds.td ===================================================================
> - include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -4266,9 +4266,11 @@ def err_conflicting_types : Error<"conflicting types for %0">; def err_different_pass_object_size_params : Error< "conflicting pass_object_size attributes on parameters">; -def err_late_asm_label_name : Error<
> - "cannot apply asm label to %select{variable|function}0 after its first use">; -def err_different_asm_label : Error<"conflicting asm label">; +def warn_late_asm_label_name : Warning< + "cannot apply asm label to %select{variable|function}0 after its first use">, + InGroup<MismatchedTags>; +def warn_different_asm_label : Warning<"conflicting asm label">, + InGroup<MismatchedTags>; def err_nested_redefinition : Error<"nested redefinition of %0">; def err_use_with_wrong_tag : Error< "use of %0 with tag type that does not match previous declaration">;
http://reviews.llvm.org/D16171
More information about the cfe-commits
mailing list