bugmake - Bugs: bug #63352, nested conditional wrongly reports...

 
 

bug #63352: nested conditional wrongly reports extraneous endif

Submitter:  None
Submitted:  Sat 12 Nov 2022 05:04:07 PM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Not A Bug Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  4.3 Operating System:  POSIX-Based
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 13 Nov 2022 10:22:16 PM UTC, comment #3: 

This is not a bug in GNU make.

Your makefile is malformed; make conditional statements must have a space after them in order to be recognized.  Your makefile:

ifneq (,)
  ifeq(,)
  endif
endif

is equivalent (to the GNU make parser) to this:

ifneq (,)
  yadayadayada
  endif
endif


As you can see, you DO have an extraneous endif here; you have one ifneq and two *endif*s.

The reason the issue "only manifests when the outer condition fails" is because when the outer condition fails, the contents of the if-statement are not parsed by the make parser so make doesn't realize that the text is invalid.  This is a feature, not a bug: many makefiles make use of this to allow content in a makefile that would otherwise be considered a syntax error.

If you change it so the outer condition succeeds, and make does parse the content, then you get an error which should point you to the problem:

$ cat Makefile
ifeq (,)
  ifeq(,)
  endif
endif

$ make
Makefile:2: *** missing separator.  Stop.


Obviously to make your original makefile correct, you just need to add a space after the ifeq:

ifneq (,)
  ifeq (,)
  endif
endif


Paul D. Smith <psmith>
Group administrator
Sun 13 Nov 2022 10:13:28 PM UTC, comment #2: 

Oh it looks like this one has the attached file and the other one doesn't so the other one should be closed as a duplicate.

Just to note, you don't have to file an entirely new bug just to add an attachment that you forgot.  Just add it to the bug.

Paul D. Smith <psmith>
Group administrator
Sun 13 Nov 2022 10:11:16 PM UTC, comment #1: 

Duplicate post for bug #63351

Paul D. Smith <psmith>
Group administrator
Sat 12 Nov 2022 05:04:07 PM UTC, original submission:  

The attached makefile causes GNU make 4.3 to produce the following erroneous output:

  "bug_nested_conditional.mk:5: * extraneous 'endif'.  Stop."


Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #53952:  bug_nested_conditional.mk added by None (182B - text/x-makefile)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by psmith (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-11-13 psmith StatusNone Not A Bug
        Open/ClosedOpen Closed
    2022-11-13 psmith StatusDuplicate None
        Open/ClosedClosed Open
    2022-11-13 psmith StatusNone Duplicate
        Open/ClosedOpen Closed
    2022-11-12 None Attached File- Added bug_nested_conditional.mk, #53952

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code